Skip to content

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

@Cozmopolit

Description

@Cozmopolit

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETIssue or Pull requests regarding .NET codebugSomething isn't workingtriage

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions