Skip to content

AI Agent: Gemini 3 models fail with 'missing thought_signature' in function calling #7679

Description

@llabusch93

Description

When using Gemini 3 models (gemini-3-flash-preview, gemini-3-pro-preview) as the provider for a Windmill AI Agent step (type: ai_agent), function calling fails with a 400 error from the Google AI API:

API error: HTTP status client error (400 Bad Request) for url
(https://generativelanguage.googleapis.com/v1beta/models/gemini-3-flash-preview:streamGenerateContent?alt=sse)

{
  "error": {
    "code": 400,
    "message": "Function call is missing a thought_signature in functionCall parts.
     This is required for tools to work correctly, and missing thought_signature may
     lead to degraded model performance. Additional data, function call
     'default_api:get_purchase_taxes', position 3.
     Please refer to https://ai.google.dev/gemini-api/docs/thought-signatures for more details.",
    "status": "INVALID_ARGUMENT"
  }
}

The error occurs at ai_executor.rs:740:32.

Root Cause

Gemini 3 models require thought signatures for function calling. When the model responds with a functionCall part, it includes a thoughtSignature field. This signature must be echoed back in subsequent requests as part of the conversation history. Without it, the API returns a 400 error.

This is mandatory even when thinking is set to minimal. See: https://ai.google.dev/gemini-api/docs/thought-signatures

What needs to change

The AI agent executor (ai_executor.rs) needs to:

  1. Parse thoughtSignature fields from Gemini's functionCall response parts
  2. Include them when sending function results back to the API
  3. Preserve the order of parts (for parallel function calls, only the first part contains the signature)

The official Google SDKs (Python, Node, Java) handle this automatically when using chat history objects.

Reproduction

  1. Create a flow with an ai_agent step
  2. Configure provider: kind: googleai, model: gemini-3-flash-preview
  3. Add any script tool
  4. Run the flow — the AI agent will attempt a tool call and fail with the above error

Environment

  • Windmill version: v1.612.2 (EE)
  • Provider: Google AI (Gemini)
  • Models affected: gemini-3-flash-preview, gemini-3-pro-preview
  • Models NOT affected: gemini-2.0-flash (no thought signatures required)

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions