fix: filter Ollama models without native tool support #10735
+250
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
parseOllamaModel()wasn't checking if models report"tools"in their capabilities arraytool_call_endEvents:NativeOllamaHandleremittedtool_call_partialchunks but never emittedtool_call_endeventsSolution
"tools"capability inparseOllamaModel()- returnsnullfor incompatible modelstool_call_endevents after streaming completes inNativeOllamaHandlerFiles Changed
src/api/providers/fetchers/ollama.ts- Added capability checking in parseOllamaModelsrc/api/providers/native-ollama.ts- Added tool_call_end emissionsrc/api/providers/fetchers/__tests__/ollama.test.ts- Updated tests with tools capabilitysrc/api/providers/__tests__/native-ollama.spec.ts- New test for tool_call_end eventsTesting
ollama.test.tsnative-ollama.spec.tsLinear Issue
COM-487
Important
Fixes Ollama model handling by filtering models without tool support and ensuring proper event emissions.
parseOllamaModel()now filters out models without "tools" capability, returningnullfor such models.NativeOllamaHandleremitstool_call_endevents after streaming completes.ollama.ts: Added capability checking inparseOllamaModel().native-ollama.ts: Addedtool_call_endemission.ollama.test.tsandnative-ollama.spec.ts: Updated tests to cover new behavior.This description was created by
for 55caabd. You can customize this summary. It will automatically update as commits are pushed.