Skip to content

fix(gemini): stop splitting one tool call into two when signature arrives late - #88149

Open
Ricardo-M-L wants to merge 1 commit into
NousResearch:mainfrom
Ricardo-M-L:fix/gemini-stream-signature-dedup-key
Open

fix(gemini): stop splitting one tool call into two when signature arrives late#88149
Ricardo-M-L wants to merge 1 commit into
NousResearch:mainfrom
Ricardo-M-L:fix/gemini-stream-signature-dedup-key

Conversation

@Ricardo-M-L

Copy link
Copy Markdown
Contributor

This PR addresses: fix(gemini): stop splitting one tool call into two when signature arrives late

…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>
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/gemini Google Gemini (AI Studio, Cloud Code) P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels Aug 17, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #28438: both PRs make the identical call-key change and carry the same late-thoughtSignature regression coverage.

@Ricardo-M-L Ricardo-M-L changed the title fix: fix(gemini): stop splitting one tool call into two when signature arrives late fix(gemini): stop splitting one tool call into two when signature arrives late Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists provider/gemini Google Gemini (AI Studio, Cloud Code) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants