Skip to content

Commit 16a540c

Browse files
authored
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
1 parent a067fed commit 16a540c

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

core/llm/llms/Ollama.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class Ollama extends BaseLLM implements ModelInstaller {
161161
private static modelsBeingInstalledMutex = new Mutex();
162162

163163
private fimSupported: boolean = false;
164-
private templateSupportsTools: boolean | undefined = undefined;
164+
165165
private modelInfoPromise: Promise<void> | undefined = undefined;
166166
private explicitContextLength: boolean;
167167

@@ -240,11 +240,6 @@ class Ollama extends BaseLLM implements ModelInstaller {
240240
* it's a good indication the model supports FIM.
241241
*/
242242
this.fimSupported = !!body?.template?.includes(".Suffix");
243-
244-
// Check if model template supports tool calling (same pattern as .Suffix above)
245-
if (body?.template) {
246-
this.templateSupportsTools = body.template.includes(".Tools");
247-
}
248243
})
249244
.catch((e) => {
250245
// console.warn("Error calling the Ollama /api/show endpoint: ", e);
@@ -516,12 +511,7 @@ class Ollama extends BaseLLM implements ModelInstaller {
516511
stream: options.stream,
517512
// format: options.format, // Not currently in base completion options
518513
};
519-
// Only include tools with user messages, and only if the template supports them
520-
if (
521-
options.tools?.length &&
522-
ollamaMessages.at(-1)?.role === "user" &&
523-
this.templateSupportsTools !== false
524-
) {
514+
if (options.tools?.length && ollamaMessages.at(-1)?.role === "user") {
525515
chatOptions.tools = options.tools.map((tool) => ({
526516
type: "function",
527517
function: {

0 commit comments

Comments
 (0)