-
Notifications
You must be signed in to change notification settings - Fork 481
Gemini: preserve thought signature across streaming tool calls for Gemini 3 #442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @cpunion, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on ensuring the consistent preservation of the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively adds support for preserving the thought_signature across streaming tool calls, which is a valuable enhancement. The changes are well-structured, and I appreciate the comprehensive test coverage added to verify this new behavior at different layers, including stream aggregation, request processing, and the database round-trip. The stabilization of database tests by pinning the timezone to UTC is also a great improvement for test reliability. I have a couple of suggestions to improve the robustness of the new JSON path parsing logic.
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This is a substantial and well-executed pull request that significantly enhances the handling of Gemini's streaming tool calls, with a key focus on preserving thought_signature. The refactoring of stream_aggregator.go is extensive and thoughtfully implemented to support complex scenarios like parallel and interleaved function calls. The accompanying test suite is exceptionally thorough, covering a wide range of edge cases and linking back to the official documentation, which adds a great deal of confidence in the changes. The improvement to stabilize database tests by setting a fixed timezone is also a welcome addition for test reliability. I have one suggestion regarding the new JSONPath parsing logic to improve its robustness.
e9a46b0 to
baca2bb
Compare
Problem
Gemini 3 validates
thought_signaturefor tool calling. In streaming mode the signature may arrive only on the first functionCall chunk or in an empty final text part, and signed parts must not be merged. Missing signatures or reordered parts can lead to 400s or degraded tool-calling quality.Summary
thought_signaturewhile aggregating streaming text, including empty final text parts.Closeif a stream ends unexpectedly.session/databasetests by pinningtime.Localto UTC (test-only).Doc Coverage / Scenarios (per test)
TestStreamAggregatorfinish_reasonis returned by the model."TestStreamAggregatorStreamingFunctionCallArgumentsfunctionCallobject withpartialArgsandwillContinuefields."TestStreamAggregatorFinalizesFunctionCallWhenEmptyChunkArrivesTestStreamAggregatorParallelFunctionCallsPreserveOrderAndSignaturethought_signatureis attached only to the firstfunctionCallpart."TestStreamAggregatorSequentialFunctionCallsPreserveSignaturesTestStreamAggregatorPreservesSignatureOnEmptyFinalTextPartTestStreamAggregatorDoesNotMergeSignedTextPartPartcontaining a signature with one that does not."TestStreamAggregatorInterleavedStreamingFunctionCallstrue, morepartialArgsare expected for the overall function call in subsequent streamed responses."TestStreamAggregatorInterleavedFunctionCallsWithoutIDsfunctionCallobject withpartialArgsandwillContinuefields."TestStreamAggregatorCloseFlushesMultiplePendingFunctionCallsTestStreamAggregatorMixedTextAndFunctionCallOrderTests
go test ./internal/llminternalNotes / Limitations