fix(gemini): set both camelCase and snake_case thought_signature in tool call request body#3136
Merged
Merged
Conversation
…ool call request body The Gemini HTTP API provider only set thoughtSignature (camelCase) when building tool call request bodies. Gemini 2.5 models accept camelCase, but Gemini 3.5 Flash Agentic reasoning requires thought_signature (snake_case) — matching the format it returns in API responses. When only the camelCase variant was sent, Gemini 3.5 Flash rejected the request with a 400 Bad Request for missing thought_signature. The fix sets both ThoughtSignature and ThoughtSignatureSnake in the geminiPart struct, matching the pattern already used in antigravity_provider.go. This ensures compatibility with both Gemini 2.x (camelCase) and Gemini 3.x Agentic (snake_case) models. Closes sipeed#3111
afjcjsbx
approved these changes
Jun 17, 2026
This was referenced Jun 18, 2026
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.
Summary
thoughtSignature(camelCase) when building tool call request bodiesthought_signature(snake_case) — matching the format it returns in API responsesthought_signatureThoughtSignatureandThoughtSignatureSnakein the geminiPart struct, matching the pattern already used inantigravity_provider.goVerification
go test ./pkg/providers/httpapi/... -count=1— all tests passTestGeminiProvider_BuildRequestBody_UsesCamelCaseThoughtSignatureOnlytoTestGeminiProvider_BuildRequestBody_SetsBothThoughtSignatureFormatsto validate both formats are presentReal behavior proof
Behavior addressed: Gemini 3.5 Flash Agentic tool calls no longer fail with 400 Bad Request for missing thought_signature; both camelCase and snake_case variants are now included in the request body
Environment tested: Go 1.25.10 on Linux amd64,
go test ./pkg/providers/httpapi/...Steps run after the patch: Ran targeted unit tests for the httpapi provider
Evidence after fix:
Observed result after the fix: All httpapi provider tests pass. Request body now contains both
"thoughtSignature":"sig-1"and"thought_signature":"sig-1", ensuring compatibility with both Gemini 2.x and Gemini 3.x Agentic models.Not tested: Live Gemini 3.5 Flash Agentic API request with real tool calls
Root Cause
part.ThoughtSignature(camelCase json tag) in the request body, without also settingpart.ThoughtSignatureSnake(snake_case json tag)Closes #3111