fix(ollama): add streamToolCalls fallback for tool calling#5783
Open
deepmehta11 wants to merge 5 commits intoopenclaw:mainfrom
Open
fix(ollama): add streamToolCalls fallback for tool calling#5783deepmehta11 wants to merge 5 commits intoopenclaw:mainfrom
deepmehta11 wants to merge 5 commits intoopenclaw:mainfrom
Conversation
Ollama and some other local models don't properly emit tool_calls delta chunks when streaming is enabled. This causes tool calls to be silently lost, breaking all tool functionality for local models. This fix adds: - `streamToolCalls` config option for providers (set to `false` to disable streaming when tools are present) - Ollama provider now defaults to `streamToolCalls: false` - Non-streaming fallback uses `complete()` instead of `streamSimple()` when tools are in the context When `streamToolCalls: false` is set and tools are present, the agent uses a non-streaming API call and wraps the response in a stream format for compatibility with the existing architecture. Fixes openclaw#5769
- Only wrap streamFn when streamToolCalls is disabled (P2) - Pass through all options to completeSimple() (P1) - Properly map stopReason to valid done event reasons (P0)
|
This pull request has been automatically marked as stale due to inactivity. |
bfc1ccb to
f92900f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
streamToolCallsconfig option for providers to disable streaming when tools are presentstreamToolCalls: falsecomplete()instead ofstreamSimple()when tools are in the contextOllama's streaming implementation doesn't properly emit
tool_callsdelta chunks, causing tool calls to be silently lost. This fix detects when tools are present and uses non-streaming requests for affected providers.Test plan
isOllamaProvider(),shouldDisableStreamingForTools(), andcreateOllamaAwareStreamFn()pi-embedded-runnertests still passFixes #5769
Greptile Overview
Greptile Summary
This PR introduces a
streamToolCallsprovider config flag (defaulting tofalsefor Ollama) and adds an Ollama-awareStreamFnwrapper that switches to non-streamingcomplete()when tools are present, working around Ollama streaming not emitting tool-call deltas. It integrates the wrapper into the embedded runner’s stream function setup and adds unit tests for the new helper logic.Main concerns are around the fallback stream event semantics and option parity between
streamSimple()and thecomplete()-based path (potentially changing stop reasons and dropping some options only when tools are present).Confidence Score: 3/5
(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!