Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Jan 14, 2026

Summary

Fixes an issue where Ollama models without native tool support (like qwen2.5-coder:7b) would output tool-call JSON as text instead of triggering native tool calls, causing an infinite loop with the error: "The model provided text/reasoning but did not call any of the required tools."

Root Causes

  1. Missing Capability Detection: parseOllamaModel() wasn't checking if models report "tools" in their capabilities array
  2. Missing tool_call_end Events: NativeOllamaHandler emitted tool_call_partial chunks but never emitted tool_call_end events

Solution

  1. Filter out models without "tools" capability in parseOllamaModel() - returns null for incompatible models
  2. Emit tool_call_end events after streaming completes in NativeOllamaHandler

Files Changed

  • src/api/providers/fetchers/ollama.ts - Added capability checking in parseOllamaModel
  • src/api/providers/native-ollama.ts - Added tool_call_end emission
  • src/api/providers/fetchers/__tests__/ollama.test.ts - Updated tests with tools capability
  • src/api/providers/__tests__/native-ollama.spec.ts - New test for tool_call_end events

Testing

  • ✅ 13/13 tests pass in ollama.test.ts
  • ✅ 15/15 tests pass in native-ollama.spec.ts
  • ✅ Full test suite: 5242 tests pass

Linear Issue

COM-487


Important

Fixes Ollama model handling by filtering models without tool support and ensuring proper event emissions.

  • Behavior:
    • parseOllamaModel() now filters out models without "tools" capability, returning null for such models.
    • NativeOllamaHandler emits tool_call_end events after streaming completes.
  • Files Changed:
    • ollama.ts: Added capability checking in parseOllamaModel().
    • native-ollama.ts: Added tool_call_end emission.
    • ollama.test.ts and native-ollama.spec.ts: Updated tests to cover new behavior.
  • Testing:
    • All tests pass, including new tests for tool capability and event emissions.

This description was created by Ellipsis for 55caabd. You can customize this summary. It will automatically update as commits are pushed.

- parseOllamaModel() now returns null for models without 'tools' capability
- NativeOllamaHandler now emits tool_call_end events after streaming
- Prevents infinite loop with models like qwen2.5-coder that output JSON text
- Added comprehensive tests for capability filtering and tool_call_end emission

Fixes COM-487
@daniel-lxs daniel-lxs requested review from cte, jr and mrubens as code owners January 14, 2026 22:50
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Jan 14, 2026
@roomote
Copy link
Contributor

roomote bot commented Jan 14, 2026

Rooviewer Clock   See task on Roo Cloud

Reviewed the changes. This PR correctly addresses the infinite loop issue by:

  1. Filtering out Ollama models without native tool support ("tools" capability)
  2. Emitting tool_call_end events after streaming completes in NativeOllamaHandler

The implementation follows established patterns from other providers and has comprehensive test coverage. No issues found.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: PR [Needs Review]

Development

Successfully merging this pull request may close these issues.

2 participants