Repository navigation
fix(mistral): stream tool calls whole instead of fragmented - #7
Merged
JulienRabault merged 1 commit intoSep 24, 2026
Merged
JulienRabault merged 1 commit into
JulienRabault merged 1 commit into
Conversation
The real Mistral API sends each tool call whole with complete arguments and groups parallel tool calls into a single delta. - Add `fragment_tool_calls: bool = True` parameter to `openai_chat_chunks` and `openai_stream`. - Pass `fragment_tool_calls=False` in the Mistral router so tool calls arrive whole in one chunk with index and full arguments. - Add `test_mistral_streaming_tool_calls_arrive_whole` in `tests/test_mistral.py`. Signed-off-by: Efe <efe@rexcode.co.uk>
JulienRabault
approved these changes
Sep 24, 2026
JulienRabault
left a comment
Owner
There was a problem hiding this comment.
Thanks! Matches what the real API sends, the OpenAI-compatible providers keep fragmenting, and CI is green on all platforms.
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
/mistral/v1/chat/completionswith tool calls, stream each tool call whole with its completearguments,id,name, andindex, grouping parallel tool calls into a single delta.langchain-mistralaiwhich expect complete tool calls./mistral/v1/chat/completions) is affected; other OpenAI-compatible endpoints continue to stream tool call argument fragments.Fixes #6
Validation
python -m ruff check llmock tests examples/retry_with_openai.pypytest -qtest_mistral_streaming_tool_calls_arrive_wholeintests/test_mistral.pyRisks
fragment_tool_calls: bool = True.