Skip to content

fix: keep parallel Gemini tool calls when replaying thought signatures - #4167

Open
L00PLeGeNd wants to merge 1 commit into
deepset-ai:mainfrom
L00PLeGeNd:fix/google-genai-thought-signature-parallel-tools
Open

L00PLeGeNd wants to merge 1 commit into
deepset-ai:mainfrom
L00PLeGeNd:fix/google-genai-thought-signature-parallel-tools

Conversation

@L00PLeGeNd

Copy link
Copy Markdown

Possible Risk/Impact

Without this fix, Gemini agent loops that use thinking + parallel tool calls fail on the second request: the replayed model turn omits unsigned sibling function calls (and unsigned text), so function-call / function-response counts diverge.

How to handle those risks to be safer?

Unit tests cover:

  • replaying an assistant message where only the first of two parallel tool calls has a thought signature
  • accumulating thought_signature_deltas across streaming chunks instead of keeping only the last chunk

How to test it?

cd integrations/google_genai && hatch run test:unit -- tests/test_chat_generator_utils.py (45 passed locally).

Notes for the reviewer / relevant issues for details when applicable

Fixes #4120

Related streaming parallel-tool work: #4141 / #4121 (separate bug).

Google GenAI attaches a thought signature to only the first function call
in a parallel batch. Replaying signed parts alone dropped the remaining
calls (and unsigned text), so the following tool-response turn mismatched.
Also accumulate streaming signature deltas across chunks instead of
keeping only the last chunk's set.

Fixes deepset-ai#4120
@L00PLeGeNd
L00PLeGeNd requested a review from a team as a code owner October 27, 2026 11:27
@L00PLeGeNd
L00PLeGeNd requested review from anakin87 and removed request for a team October 27, 2026 11:27
@github-actions

Copy link
Copy Markdown
Contributor

Heads-up for maintainers

This PR is from a fork and touches integrations whose integration tests require API keys.
Those tests are skipped in CI because fork PRs don't have access to repo secrets for security reasons.

Affected integrations:

  • google_genai

Please run the integration tests locally (hatch run test:integration inside each folder) before approving.

@CLAassistant

CLAassistant commented Oct 27, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added the type:documentation Improvements or additions to documentation label Oct 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (google_genai)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/google_genai/src/haystack_integrations/components/generators/google_genai/chat
  utils.py
Project Total  

This report was generated by python-coverage-comment-action

@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @L00PLeGeNd, thanks a lot for your contribution! 🙏

We noticed that the Contributor License Agreement (CLA) check (license/cla) hasn't passed yet, so we've temporarily moved this PR to draft and paused the review assignment.

To get your PR reviewed, please sign the CLA via the link in the license/cla check below (or in the CLA bot comment). As soon as the check turns green, this PR will automatically be marked ready for review again and a reviewer will be re-assigned.

@HaystackBot
HaystackBot removed the request for review from anakin87 October 27, 2026 12:43
@HaystackBot HaystackBot added the cla-pending PR is in draft until the contributor signs the CLA label Oct 27, 2026
@HaystackBot
HaystackBot marked this pull request as draft October 27, 2026 12:43
@L00PLeGeNd
L00PLeGeNd marked this pull request as ready for review October 27, 2026 14:26
@HaystackBot
HaystackBot requested a review from anakin87 October 27, 2026 14:28
@HaystackBot HaystackBot removed the cla-pending PR is in draft until the contributor signs the CLA label Oct 27, 2026
@HaystackBot

Copy link
Copy Markdown
Contributor

Thanks for signing the CLA, @L00PLeGeNd! 🎉 This PR is now ready for review again and the reviewer has been re-assigned.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:google-genai type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

google_genai: replaying a Gemini turn with thought signatures drops parallel function calls

3 participants