fix(gemini): stop splitting one tool call into two when signature arrives late - #88149
Open
Ricardo-M-L wants to merge 1 commit into
Open
fix(gemini): stop splitting one tool call into two when signature arrives late#88149Ricardo-M-L wants to merge 1 commit into
Ricardo-M-L wants to merge 1 commit into
Conversation
…ives late
translate_stream_event() in agent/gemini_native_adapter.py keys
tool_call slots on (part_index, name, thought_signature). Because the
thought_signature is part of the dedup key, a single tool call whose
chunks carry the signature inconsistently (e.g., empty on early chunks,
present on a later one — which Gemini 3 thinking models do) is split
into two separate slots:
- slot 0: built from the early chunks → no signature, partial args
- slot 1: built from the later chunk → has signature, fuller args
Both slots are emitted as deltas, so the agent records *two* tool calls
for what was logically one. On the next turn the slot without a
signature is replayed back to Gemini, which 400s with:
Function call is missing a thought_signature in functionCall parts.
Fix: dedup on (part_index, name) only. The signature is still surfaced
through the per-chunk extra_content field, and the downstream
streaming accumulator (run_agent.py) already does latest-non-None-wins
on extra_content per slot — so whichever chunk carried the signature
gets it merged into the single slot.
Adds a regression test that fails on main and passes here:
test_stream_event_translation_does_not_split_slot_when_signature_arrives_late
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Collaborator
Duplicate of #28438: both PRs make the identical call-key change and carry the same late-thoughtSignature regression coverage. |
2 tasks
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.
This PR addresses: fix(gemini): stop splitting one tool call into two when signature arrives late