fix: remove Ollama template-based tool support gate (#11905)

* fix: let explicit capabilities.tools override Ollama template tool detection

The Ollama provider checks the model template from /api/show for a
`.Tools` placeholder to decide whether to pass tools to the API. For
newer models (e.g. qwen3.5) whose templates may not yet include
`.Tools`, this silently strips tools from the request — even when the
user explicitly sets `capabilities: tools: true` in config.yaml.

Use nullish coalescing so an explicit capabilities.tools setting always
wins, with the template heuristic as a fallback.

* remove verbose comments

* remove templateSupportsTools check; trust upstream tool support detection

* fix: remove extra blank line to pass prettier check
This commit is contained in:
Dallin Romney 2026-03-26 16:52:20 -07:00 • committed by GitHub
parent a067fedfdc
commit 16a540c337
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -161,7 +161,7 @@ class Ollama extends BaseLLM implements ModelInstaller {
private static modelsBeingInstalledMutex = new Mutex();
private fimSupported: boolean = false;
private templateSupportsTools: boolean | undefined = undefined;
private modelInfoPromise: Promise<void> | undefined = undefined;
private explicitContextLength: boolean;
@ -240,11 +240,6 @@ class Ollama extends BaseLLM implements ModelInstaller {
* it's a good indication the model supports FIM.
*/
this.fimSupported = !!body?.template?.includes(".Suffix");
// Check if model template supports tool calling (same pattern as .Suffix above)
if (body?.template) {
this.templateSupportsTools = body.template.includes(".Tools");
}
})
.catch((e) => {
// console.warn("Error calling the Ollama /api/show endpoint: ", e);
@ -516,12 +511,7 @@ class Ollama extends BaseLLM implements ModelInstaller {
stream: options.stream,
// format: options.format, // Not currently in base completion options
};
// Only include tools with user messages, and only if the template supports them
if (
options.tools?.length &&
ollamaMessages.at(-1)?.role === "user" &&
this.templateSupportsTools !== false
) {
if (options.tools?.length && ollamaMessages.at(-1)?.role === "user") {
chatOptions.tools = options.tools.map((tool) => ({
type: "function",
function: {