.Net: Bug: Gemini function calling fails with HTTP 400 when thinking is enabled (missing thoughtSignature support)
Describe the bug
When using Gemini 2.5 Pro or Gemini 3 Pro with thinking enabled (thinkingConfig), function calling fails with HTTP 400:
Function call is missing a thought_signature in functionCall parts
The Gemini connector does not preserve thoughtSignature tokens from API responses, which are mandatory for function calling when thinking is enabled.
To Reproduce
- Configure Gemini connector with Gemini 3 Pro (or 2.5 Pro with
thinkingConfigenabled) - Register a kernel function/tool
- Send a prompt that triggers function calling
- Model returns function call with
thoughtSignaturein response - Connector builds follow-up request with function result
- See HTTP 400 error: "Function call is missing a thought_signature in functionCall parts"
Expected behavior
Function calling should work correctly. The connector should:
- Capture
thoughtSignaturetokens from Gemini responses - Include them in subsequent requests when sending function results
This is required by the Gemini API Thought Signatures documentation.
Screenshots
N/A - API error response.
Platform
- Language: C#
- Source: NuGet package
Microsoft.SemanticKernel.Connectors.Google(latest) / main branch - AI model: Google Gemini 2.5 Pro, Gemini 3 Pro (any model with thinking enabled)
- IDE: Visual Studio / VS Code
- OS: Windows, Linux, Mac (all platforms affected)
Additional context
"When a model generates a response that includes thinking, it provides an encrypted representation of its thought process called a thought signature. This signature must be sent back with subsequent turns to maintain the reasoning context."
Current state:
thinkingConfigsupport added in PR #13383thoughtSignaturecapture from responses: NOT implementedthoughtSignaturerestore in requests: NOT implemented
API Behavior:
- For function calls:
thoughtSignatureis mandatory (HTTP 400 without it) - For text responses:
thoughtSignatureis recommended for optimal performance - Parallel function calls: Only the first
functionCallpart has athoughtSignature
Related: #13360 (IncludeThoughts / Thought Signatures)
Workaround: Disable thinking (loses reasoning quality benefits) or use custom Gemini client.
PR for an according fix is in the works, coming up real soon (tm).
This feature is very much needed. When interacting with the Gemini 3 series models, we are currently encountering abnormal behavior (400 Bad Request).
Same thing is happening with the latest Python version of SK (1.39.2) when trying to do a tool call with gemini-3-pro-preview Is this something being worked on ?