openclaw - 💡(How to fix) Fix gemini-3.1-flash-lite-preview fails on multi-turn tool use — missing thought_signature support [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#71725Fetched 2026-04-26 05:09:20
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
closed ×1commented ×1

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.

Error Message

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. Error response: "error": {

  • The error surfaces to users as "⚠️ Agent couldn't generate a response" — misleading, as the real cause is the missing thought_signature

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.

Fix Action

Fix / Workaround

  • 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)

Code Example

# 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": {
    "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"
  }
}
RAW_BUFFERClick to expand / collapse

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

extent analysis

TL;DR

The most likely fix is to update the OpenClaw Gemini API adapter to preserve and echo back the thought_signature field from the model's tool call response.

Guidance

  • Verify that the thought_signature field is being returned in the model's tool call response and identify where it is being lost in the OpenClaw Gemini API adapter.
  • Update the adapter to capture and forward the thought_signature field unchanged in the subsequent request turn.
  • Test the updated adapter with a tool-use conversation to ensure the 400 INVALID_ARGUMENT error is resolved.
  • Consider using the google/gemini-2.5-flash model as a temporary workaround until the adapter is updated.

Example

No code snippet is provided as the issue is related to the OpenClaw Gemini API adapter, which is not shown in the issue body.

Notes

The fix requires updating the OpenClaw Gemini API adapter, which may involve modifying the adapter's code to handle the thought_signature field correctly. The google/gemini-2.5-flash model can be used as a temporary workaround until the adapter is updated.

Recommendation

Apply workaround: use google/gemini-2.5-flash instead, as it is not affected by the issue and can be used until the OpenClaw Gemini API adapter is updated to handle the thought_signature field correctly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix gemini-3.1-flash-lite-preview fails on multi-turn tool use — missing thought_signature support [1 comments, 2 participants]