Repository navigation
fix(ollama): run every tool call of a streamed step - #1059
Open
skybleak333 wants to merge 1 commit into
Open
skybleak333 wants to merge 1 commit into
skybleak333 wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Description
When an Ollama model called several tools in one streamed step, only the last one ran. Ollama sends each call in its own chunk, always at position 0 of
message.tool_calls, and numbers it withfunction.index(left out for the first call).extractToolCalls()keyed the calls by that position, so the second call overwrote the first.The repo's own recording shows it: in
ollama/stream-with-tools-1.sse, qwen3:14b asks forweatherand then, in the next chunk, forsearchwith"index":1. Onlysearchran, so the recorded second step asks for the weather again.Calls are now keyed by
function.index, and a call without one that starts a new call (it has a name) gets the next free key, so Ollama versions that don't send the index work too.The existing tools test asserted 2 tool calls; with the same recordings it now sees
weatherandsearchin the first step andweatheragain in the second, so I changed its expectation to that. A new test with two calls in separate chunks checks both run in the first step and both results go back in the next request; it fails without the change. The full suite, PHPStan, Pint and Rector pass.