Repository navigation
fix(streaming): join tool-call fragments that have no index - #474
Open
pcbeingused333 wants to merge 2 commits into
Open
pcbeingused333 wants to merge 2 commits into
pcbeingused333 wants to merge 2 commits into
Conversation
merge_lists only merged tool-call chunks by their int `index`. Servers that omit it left every argument fragment as its own tool call, and an indexed chunk after an unindexed element raised KeyError. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md
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.
merge_listsmerges streamed list items only when they carry an intindex(this is howtool_callsfragments are joined inOpenAICompletionsProvider.stream_merge_chunks, and so in every provider built on it). When a server omitsindex, each argument fragment was appended as its own tool call, so the turn ended up with calls like{"id": "call_1", "function": {"name": "f", "arguments": ""}}followed by several nameless ones with partial JSON. Separately, if an indexed chunk arrived after an element withoutindex,e_left["index"]raisedKeyError.What changed
index,idandfunction.nameis merged into the previous tool call. An item with anidor a name still starts a new call, so parallel calls stay separate..get("index")instead of["index"].Related: #436 reorders the
merge_dictsbranches; this change is independent of it.Tests. Four cases in
tests/test_utils_merge.py: fragments joined into one call, two un-indexed calls with different ids kept separate, theKeyErrorcase, and a fragment arriving when the list is still empty. The first and theKeyErrorcase fail on main; the empty-list case pins the guard on the new branch. No request was made to a live API.This change was made with Claude Code.
🤖 Generated with Claude Code