Skip to content

gemini-3.1-flash-lite-preview fails on multi-turn tool use — missing thought_signature support #71725

@packwood

Description

@packwood

Summary

gemini-3.1-flash-lite-preview (and likely other Gemini 3.1 thinking-class models) are broken for any agentic task involving tool calls. The model works fine for single-turn generation but throws a 400 INVALID_ARGUMENT error on the second turn of any tool-use conversation.

Root Cause

Google's Gemini 3.1 thinking models now require a thought_signature field to be preserved from the model's tool call response and echoed back verbatim when submitting the tool result. OpenClaw's Gemini API adapter does not capture or forward this field.

Reproduction

# Turn 1 — model responds with a function call (works fine)
# Turn 2 — submit tool result (FAILS)
POST /v1beta/models/gemini-3.1-flash-lite-preview:generateContent

{
  "contents": [
    {"role": "user",   "parts": [{"text": "Run: echo hello. Then reply NO_REPLY if output is hello."}]},
    {"role": "model",  "parts": [{"functionCall": {"name": "exec", "args": {"command": "echo hello"}, "id": "abc123"}}]},
    {"role": "user",   "parts": [{"functionResponse": {"name": "exec", "id": "abc123", "response": {"output": "hello\n", "exitCode": 0}}}]}
  ]
}

Error response:

{
  "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:exec`, position 2. Please refer to https://ai.google.dev/gemini-api/docs/thought-signatures for more details.",
    "status": "INVALID_ARGUMENT"
  }
}

Expected Fix

When the Gemini API returns a functionCall part that includes a thought_signature, the adapter must preserve it and include it unchanged in the subsequent request turn. See Google's documentation: https://ai.google.dev/gemini-api/docs/thought-signatures

Impact

  • All cron/agentic jobs configured to use gemini-3.1-flash-lite-preview silently fail or time out at the tool-result step
  • The error surfaces to users as "⚠️ Agent couldn't generate a response" — misleading, as the real cause is the missing thought_signature
  • Single-turn generation (no tools) works correctly — so basic testing would not catch this
  • Workaround: use google/gemini-2.5-flash instead (not affected)

Environment

  • OpenClaw version: 2026.4.22 (00bd2cf)
  • Provider: google (Gemini API via google-generative-ai)
  • Model: gemini-3.1-flash-lite-preview
  • Confirmed broken: 2026-04-22 through 2026-04-25
  • Confirmed working model as replacement: gemini-2.5-flash

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions