Conversation
…res attach Signed-off-by: lEWFkRAD <SJWATTS89@outlook.com> Co-Authored-By: Hermes Agent <agent@nousresearch.com>
Contributor
Duplicate of #88149 — same one-line change (drop |
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.
Problem
On the native Gemini streaming path, parallel tool calls arrive glued together: one call's
argumentsis{...}{...}(two JSON objects concatenated), which fails to parse and breaks the turn. Reproduced deterministically againstorigin/main—json.decoder.JSONDecodeError: Extra data: line 1 column 19.Root cause
translate_stream_eventkeys its per-call accumulator slots withjson.dumps({"part_index", "name", "thought_signature"}). Gemini delivers afunctionCallpart first without athoughtSignature, then re-delivers the same part once the turn's thought signatures are attached. When that happens the key changes mid-stream ("thought_signature": ""→ the real signature), so the second delivery does not find the existing slot: it opens a phantom second slot at a new index and re-emits the full arguments. The consumer (chat_completion_helpers, which appends streamedargumentsfragments per call index) therefore appends the complete args a second time onto the first call's slot — producing{"a":1}{"b":2}on one call and a spurious duplicate on the other.Fix
Make the slot key stable for the life of one call:
(part_index, name)only. The signature is excluded from the key and still rides to the consumer viaextra_content(unchanged), so round-tripping signatures back to Gemini on the next request is unaffected.TDD
test_stream_signature_attach_keeps_parallel_call_slotsstreams the exact issue shape (tworead_filecalls, signature attached on the second delivery) and asserts every slot parses as single JSON.origin/main(6327930):1 failed — json.decoder.JSONDecodeError: Extra data: line 1 column 19 (char 18)1 passed; full file29 passed, 1 deselected(the deselectedtest_async_native_client_...fails identically on cleanorigin/main— pre-existing event-loop flake, unrelated).tests/run_agent/test_repair_tool_call_arguments.py,test_streaming_tool_call_repair.py,tests/agent/test_gemini_schema.py→14 passed.Linked issue
Closes #102787