From 16a540c3378b833931429db9bcb3ce7c98bd7a36 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 26 Mar 2026 16:52:20 -0700 Subject: [PATCH] fix: remove Ollama template-based tool support gate (#11905) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- core/llm/llms/Ollama.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/core/llm/llms/Ollama.ts b/core/llm/llms/Ollama.ts index c9142206a..4bcd9fb1e 100644 --- a/core/llm/llms/Ollama.ts +++ b/core/llm/llms/Ollama.ts @@ -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 | 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: {