fix(google): attach thought_signature to FunctionResponse parts#297
Closed
Cidan wants to merge 1 commit into
Closed
fix(google): attach thought_signature to FunctionResponse parts#297Cidan wants to merge 1 commit into
Cidan wants to merge 1 commit into
Conversation
Contributor
Author
|
I misidentified the root cause during testing. Closing. |
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.
Gemini models with reasoning enabled return a `thought_signature` alongside a `FunctionCall`. The Google API enforces that the subsequent `FunctionResponse` part must include this same `thought_signature`, or it will reject the request with a 400 `INVALID_ARGUMENT` (or 400 `bad request` on AI Studio).
This patch ensures that when mapping `MessageRoleTool` (ToolResults) into `FunctionResponse` parts, we search the conversation history for the matching `ReasoningContent` block and copy its `thought_signature` onto the `genai.Part`.
Fixes a crash when using tools with Gemini 3.1 Pro Preview and reasoning enabled.