semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

.Net: Bug: Gemini function calling fails with HTTP 400 when thinking is enabled (missing thoughtSignature support)

Open Cozmopolit opened this issue 11 months ago • 3 comments

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

  1. Configure Gemini connector with Gemini 3 Pro (or 2.5 Pro with thinkingConfig enabled)
  2. Register a kernel function/tool
  3. Send a prompt that triggers function calling
  4. Model returns function call with thoughtSignature in response
  5. Connector builds follow-up request with function result
  6. See HTTP 400 error: "Function call is missing a thought_signature in functionCall parts"

Expected behavior

Function calling should work correctly. The connector should:

  1. Capture thoughtSignature tokens from Gemini responses
  2. 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

Per Google's documentation:

"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:

  • thinkingConfig support added in PR #13383
  • thoughtSignature capture from responses: NOT implemented
  • thoughtSignature restore in requests: NOT implemented

API Behavior:

  • For function calls: thoughtSignature is mandatory (HTTP 400 without it)
  • For text responses: thoughtSignature is recommended for optimal performance
  • Parallel function calls: Only the first functionCall part has a thoughtSignature

Related: #13360 (IncludeThoughts / Thought Signatures)

Workaround: Disable thinking (loses reasoning quality benefits) or use custom Gemini client.

Cozmopolit avatar Dec 13 '25 15:12 Cozmopolit

PR for an according fix is in the works, coming up real soon (tm).

Cozmopolit avatar Dec 13 '25 15:12 Cozmopolit

This feature is very much needed. When interacting with the Gemini 3 series models, we are currently encountering abnormal behavior (400 Bad Request).

bauann avatar Dec 31 '25 08:12 bauann

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 ?

dariusFTOS avatar Jan 28 '26 12:01 dariusFTOS