Skip to content

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

Merged
RomneyDa merged 4 commits into
mainfrom
fix/ollama-tool-capabilities-override
Mar 26, 2026
Merged

fix: remove Ollama template-based tool support gate#11905
RomneyDa merged 4 commits into
mainfrom
fix/ollama-tool-capabilities-override

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The Ollama provider was checking the model template (via /api/show) for a .Tools placeholder to decide whether to pass tools to the API
  • This silently stripped tools for newer models (e.g. qwen3.5:9b) whose templates don't yet include .Tools, even when toolSupport.ts or explicit config said the model supports tools
  • Removed the templateSupportsTools check entirely — if options.tools is non-empty, the upstream (capabilities.tools from config or toolSupport.ts heuristic) already decided the model supports tools

Test plan

  • Configure an Ollama model (e.g. qwen3.5:9b) and verify tools are passed to the API
  • Verify models that don't match toolSupport.ts heuristics still don't receive tools

…tection

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.
@RomneyDa
RomneyDa requested a review from a team as a code owner March 26, 2026 22:53
@RomneyDa
RomneyDa requested review from Patrick-Erichsen and removed request for a team March 26, 2026 22:53
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 26, 2026
@continue

continue Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Documentation Review

No documentation updates needed for this PR.

Reason: This is an internal bug fix that makes the existing documented behavior work correctly. The documentation already instructs users to explicitly set capabilities: [tool_use] when auto-detection fails (see Ollama provider docs and Model Capabilities guide).

This PR fixes the code to properly honor those explicit capability settings for Ollama models—the user-facing configuration and recommended workflow remain unchanged.

@continue

continue Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Test Coverage Review

This PR introduces new logic where capabilities.tools can explicitly override the template-based tool detection in Ollama. The following test cases should be added to core/llm/llms/Ollama.test.ts:

Suggested Test Cases

  1. capabilities.tools = true overrides template detection: When capabilities.tools is explicitly true, tools should be included in chatOptions even if templateSupportsTools is false.

  2. capabilities.tools = false overrides template detection: When capabilities.tools is explicitly false, tools should NOT be included even if templateSupportsTools is true.

  3. capabilities.tools = undefined preserves existing behavior: When capabilities.tools is not set, the existing templateSupportsTools !== false logic should apply.

Example Test Structure

describe('_streamChat tool capability handling', () => {
  it('should include tools when capabilities.tools is explicitly true', () => {
    // Set capabilities.tools = true, templateSupportsTools = false
    // Verify tools are included in chatOptions
  });

  it('should exclude tools when capabilities.tools is explicitly false', () => {
    // Set capabilities.tools = false, templateSupportsTools = true  
    // Verify tools are NOT included in chatOptions
  });

  it('should use templateSupportsTools when capabilities.tools is undefined', () => {
    // Set capabilities.tools = undefined, templateSupportsTools = true
    // Verify tools ARE included (existing behavior)
  });
});

These tests would provide regression coverage for the bug this PR fixes and ensure the capability override precedence logic works correctly.


Automated test coverage check

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Mar 26, 2026
@RomneyDa RomneyDa mentioned this pull request Mar 26, 2026
4 tasks
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Mar 26, 2026
@RomneyDa RomneyDa changed the title fix: let explicit capabilities.tools override Ollama template tool detection fix: remove Ollama template-based tool support gate Mar 26, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Mar 26, 2026
@RomneyDa
RomneyDa merged commit 16a540c into main Mar 26, 2026
91 of 95 checks passed
@RomneyDa
RomneyDa deleted the fix/ollama-tool-capabilities-override branch March 26, 2026 23:52
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants