Implement thought_signature preservation in transformations#14
Open
felipebarcelospro wants to merge 1 commit intokiyo-e:mainfrom
Open
Implement thought_signature preservation in transformations#14felipebarcelospro wants to merge 1 commit intokiyo-e:mainfrom
felipebarcelospro wants to merge 1 commit intokiyo-e:mainfrom
Conversation
This commit adds full support for Gemini 3.0's thought_signature requirement in tool calling. Changes: - Added transformOpenAIResponseToClaude() to capture thought_signature from Gemini responses - Added addThoughtSignaturesToToolResults() to inject signatures back into tool results - Signatures are preserved in a Map structure (tool_call_id -> signature) - Handles both OpenAI format (role='tool') and Claude format (content.type='tool_result') This fixes the 400 error "Function call is missing a thought_signature" when using Gemini 3.0 models with tool calling. Reference: https://ai.google.dev/gemini-api/docs/thought-signatures
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 commit adds full support for Gemini 3.0's thought_signature requirement in tool calling.
Changes:
Problem
When using Gemini 3.0 models (gemini-3-flash-preview, gemini-3-pro-preview) with tool calling through the proxy, requests fail with a 400 error:
Gemini 3.0 requires
thought_signatureto be preserved and returned with tool results for proper function calling flow. The current implementation doesn't capture or re-inject these signatures.Solution
This PR adds full support for Gemini 3.0's
thought_signaturerequirement:Changes
transformOpenAIResponseToClaude(): Capturesthought_signaturefrom Gemini responses when tool_calls are presentaddThoughtSignaturesToToolResults(): Injects stored signatures back into tool results before sending to GeminiMap<string, string>structure (tool_call_id → signature) to preserve signatures across request/response cyclesrole='tool') and Claude format (content.type='tool_result')Testing
Tested with Gemini 3.0 Flash and Pro models with Claude Code using MCP tools. Tool calling now works without 400 errors.
Reference
Breaking Changes
None - these are additive functions that don't affect existing functionality.- Handles both OpenAI format (role='tool') and Claude format (content.type='tool_result')
This fixes the 400 error "Function call is missing a thought_signature" when using Gemini 3.0 models with tool calling.
Reference: https://ai.google.dev/gemini-api/docs/thought-signatures