Skip to content

[Bug]: Gemini 3.x silent hang on subagent flows — thoughtSignature dropped on cross-provider replay (2026.5.3-1) #77566

Closed

Description

@jrex-jooni

Summary

google/gemini-3.1-pro-preview (thinkingLevel: high) reliably hangs after a few tool-call rounds in any flow where conversation history was authored by a different provider/model — e.g. subagents spawned from a Claude or GPT orchestrator. Failure mode: gateway logs LLM idle timeout (600s): no response from model and the run dies. Trivial single-turn calls to the same model with the same key work in 3 seconds.

This is the bug reported in #74244 and #72127 (and several earlier #58235, #63397). All were autoclosed by the clawsweeper bot citing a "no longer reproducible" or "already fixed" rationale. Original reporter @YouFoundJK pushed back in #74244 with a screenshot reproduction on gemini-3.1-pro-preview and posted a verified-working blueprint fix on 2026-04-29. No human maintainer ever responded; no PR was opened. The bug persists in 2026.5.3-1, which is the current latest stable release.

Status in shipped 2026.5.3-1

The exact code path @YouFoundJK identified as the problem is still present in the shipped dist:

// /app/dist/transport-stream-8H4N10uL.js:211, 231
...isSameProviderAndModel && block.textSignature ? { thoughtSignature: block.textSignature } : {}
...isSameProviderAndModel && block.thoughtSignature ? { thoughtSignature: block.thoughtSignature } : {}

isSameProviderAndModel gates signature forwarding. For any conversation where assistant turns were authored by a different provider or model than the one currently being called (subagents, model switches, fallback chains), thoughtSignature is silently dropped from the outbound functionCall parts. Gemini 3.x then hangs (per Google docs, missing-signature should be a 400 INVALID_ARGUMENT, but in practice it manifests as a silent stall).

The recommended fallback string "skip_thought_signature_validator" (per Google's thought-signatures docs) is not present anywhere in /app/dist/ of 2026.5.3-1, so neither the original-signature path nor the fallback path covers cross-provider replay.

Reproduction fingerprint (5 captured runs)

Five subagent runs on google/gemini-3.1-pro-preview with thinkingLevel: high and a multi-step exec-tool task. All five hung identically. Captured directly from gateway-persisted JSONL transcripts:

run assistant turns tool calls thinking blocks blocks with thoughtSignature <think> text tags terminal error
1 3 3 2 0 0 LLM idle timeout (600s)
2 4 4 1 0 0 LLM idle timeout (600s)
3 3 2 2 0 0 request timed out
4 15 15 4 0 0 LLM idle timeout (600s)
5 5 5 2 0 0 LLM idle timeout (600s)

Persisted gateway error record from one run:

{
  "type": "custom",
  "customType": "openclaw:prompt-error",
  "data": {
    "provider": "google",
    "model": "gemini-3.1-pro-preview",
    "api": "google-generative-ai",
    "error": "LLM idle timeout (600s): no response from model"
  }
}

Every persisted thinking content block in the failing transcripts has type: "thinking" (native, not text-tagged), 300–600 chars of text, and no signature / thoughtSignature / thinkingSignature field on the persisted block.

What was checked / ruled out

This narrows the failure to the Gemini transport's outbound serialization of cross-provider assistant history — exactly what @YouFoundJK identified.

Asks

  1. Re-open [Bug]: Gemini API error (400): missing thought_signature #74244 (or supersede with this one). The clawsweeper autoclose was incorrect — code review missed the isSameProviderAndModel gate that strips signatures on cross-provider replay, and ignored the original reporter's request for human verification. Consider requiring a human re-check before autoclosing Gemini 3.x bug reports going forward.
  2. Land @YouFoundJK's blueprint fix (or an equivalent maintainer-cleaned version) covering all three gaps:
    • transport-message-transform.ts — stop stripping thoughtSignature from cross-provider history; let downstream transports decide.
    • transport-stream.ts — always include thoughtSignature on functionCall parts; use "skip_thought_signature_validator" fallback (per Google docs) when no captured signature is available.
    • openai-transport-stream.ts — collect signatures from all history (not just same-model).
  3. Make the failure mode loud. A silent 600 s idle timeout with no diagnostic about a known protocol gap is very hard to root-cause downstream. Either surface Google's 400 INVALID_ARGUMENT: missing thought_signature to the gateway log/error path, or fast-fail when an outbound Gemini call would emit a functionCall part with no signature.

Environment

  • OpenClaw 2026.5.3-1 (release tag, latest stable as of 2026-05-04)
  • google/gemini-3.1-pro-preview via Google AI Studio API key (no Vertex, no proxy)
  • Linux container, Node 24.14.0
  • thinkingDefault: medium globally; the affected reviewer agents run with thinkingLevel: high

Activity

  1. clawsweeper commented on May 4, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.

    Summary
    Keep open: current main still has source-level paths that drop or omit Gemini thoughtSignature during cross-provider/native replay, and the overlapping open PR #75713 is not merged and appears to cover only part of the gap reported here.

    Reproducibility: yes. by source inspection rather than live execution: current main can carry a Gemini-targeted assistant toolCall to native or OpenAI-compatible Google replay without a thoughtSignature, matching Google's documented 400 path and the reporter's timeout transcripts.

    Next step
    An overlapping open PR exists, but this issue identifies cross-provider transport gaps that may need maintainer-directed extension or replacement rather than a second uncoordinated repair PR.

    Review details

    Best possible solution:

    Land one focused repair that preserves real Gemini signatures through replay boundaries, uses Google's sentinel only for unsigned transferred function-call history, and adds regression coverage for native Google plus OpenAI-compatible cross-provider replay.

    Do we have a high-confidence way to reproduce the issue?

    Yes, by source inspection rather than live execution: current main can carry a Gemini-targeted assistant toolCall to native or OpenAI-compatible Google replay without a thoughtSignature, matching Google's documented 400 path and the reporter's timeout transcripts.

    Is this the best way to solve the issue?

    Yes on direction: fixing the replay serialization/sanitization boundary is the narrow maintainable solution, but the open PR should be reviewed against this issue because it appears incomplete for the cross-provider gates.

    Acceptance criteria:

    • pnpm test extensions/google/transport-stream.test.ts src/agents/transport-message-transform.test.ts src/agents/openai-transport-stream.test.ts src/agents/pi-embedded-runner.sanitize-session-history.test.ts
    • pnpm exec oxfmt --check --threads=1 extensions/google/transport-stream.ts extensions/google/transport-stream.test.ts src/agents/transport-message-transform.ts src/agents/transport-message-transform.test.ts src/agents/openai-transport-stream.ts src/agents/openai-transport-stream.test.ts src/agents/pi-embedded-helpers/google.ts src/agents/pi-embedded-runner/replay-history.ts src/agents/pi-embedded-runner.sanitize-session-history.test.ts CHANGELOG.md docs/reference/transcript-hygiene.md
    • pnpm check:changed

    What I checked:

    • Current transform drops cross-model signatures: transformTransportMessages computes same-provider/API/model identity, converts foreign thinking/text to plain text, and deletes toolCall.thoughtSignature from non-matching assistant history before transport replay. (src/agents/transport-message-transform.ts:67, f042b53782d9)
    • Native Google serializer only forwards same-provider/model tool-call signatures: buildGoogleGenerativeAiParams attaches thoughtSignature to functionCall parts only when isSameProviderAndModel is true, so a transferred or model-switched assistant tool call can serialize without a signature. (extensions/google/transport-stream.ts:412, f042b53782d9)
    • OpenAI-compatible Google path filters to exact same route: injectToolCallThoughtSignatures only collects signatures from assistant history whose API, provider, and model all match the current model; tests also assert no cross-API replay and no extra_content when no signature was captured. (src/agents/openai-transport-stream.ts:1784, f042b53782d9)
    • Current replay sanitizer has no Google sentinel repair: sanitizeSessionHistory returns provider-sanitized history directly or after Google turn ordering; the current Google helper only exposes API/model helpers and turn ordering, with no skip_thought_signature_validator sentinel repair on main. (src/agents/pi-embedded-runner/replay-history.ts:713, f042b53782d9)
    • Upstream contract supports the reported failure mode: Google's thought-signature docs state Gemini 3 enforces function-call thought signatures, omitting required signatures can return 400, and transferred non-API-generated function calls may use skip_thought_signature_validator as a last-resort dummy signature.
    • Prior reporter supplied a matching blueprint: The [Bug]: Gemini API error (400): missing thought_signature #74244 discussion includes YouFoundJK's follow-up after the bot close plus a blueprint naming the same three gaps: transform stripping, native Google transport gating/fallback, and OpenAI-compatible same-model collection.

    Likely related people:

    • steipete: GitHub commit history for the central replay-history and Google transport files shows recent maintenance of replay sanitization, Google transport movement into the plugin, strict provider replay, and invalid thinking signature handling. (role: recent replay-history and Google transport maintainer; confidence: high; commits: d80a8eb3adb6, 791ad0864aca, 85826c83e4a1; files: src/agents/pi-embedded-runner/replay-history.ts, src/agents/transcript-policy.ts, extensions/google/transport-stream.ts)
    • echoVic: The related native Google thoughtSignature sanitization work appears in commit 9176571 and is adjacent to the replay-signature behavior this issue exercises. (role: prior native Google thought-signature contributor; confidence: medium; commits: 9176571ec11c; files: src/agents/transcript-policy.ts)
    • zhangguiping-xydt: Recent Google transport work fixed Gemini 3.1 thoughtSignature-only stream hangs, which is adjacent to the native Gemini thinking/signature path involved here. (role: recent adjacent Gemini thinking-stream contributor; confidence: medium; commits: ea3416d8b520; files: extensions/google/transport-stream.ts, extensions/google/transport-stream.test.ts)
    • obviyus: The same recent Gemini thoughtSignature-only stream fix was committed/merged through obviyus, making them a useful routing candidate for Google transport regressions. (role: recent reviewer/merger for adjacent Gemini transport work; confidence: medium; commits: a55b2af7a5d3, ea3416d8b520; files: extensions/google/transport-stream.ts, extensions/google/transport-stream.test.ts)

    Remaining risk / open question:

    • I did not run a live Gemini 3.x subagent replay in this read-only sweep; the reproduction assessment is based on source inspection, upstream docs, and reporter transcripts.
    • PR fix(agents): add google tool call thought_signature #75713 overlaps this area, but because it is not merged and does not touch the reported cross-provider transport gates, maintainers should decide whether to extend it or replace it.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against f042b53782d9.

    Re-review progress:

  2. jrex-jooni commented on May 5, 2026

    @jrex-jooni
    Author

    Did a deeper code dive. The gap clawsweeper noted between this issue and PR #75713 is real — three separate cross-provider drop points strip real signatures before #75713's sanitizer runs:

    • src/agents/transport-message-transform.ts:97-99 (explicit delete normalizedToolCall.thoughtSignature)
    • extensions/google/transport-stream.ts:449-451 (isSameProviderAndModel gate)
    • src/agents/openai-transport-stream.ts:1784 (injectToolCallThoughtSignatures skips non-exact-match)

    Confirmed in shipped 2026.5.3-1. Posted full source-cited analysis with suggested layering on top of @YouFoundJK's #74244 blueprint over on PR #75713. Glad to send a follow-up PR once a maintainer signals which path they prefer.

  3. bo-blue commented on May 5, 2026

    @bo-blue

    Confirming this affects google/gemini-3-flash-preview as well as the gemini-3.1-pro-preview already discussed — same failure mode, same LLM idle timeout (120s): no response from model, same recovery path via /new. Worth tightening the title's "Gemini 3.x" scope statement to make the flash-preview branch explicit.

    Reproduction on shipped 2026.5.3-1 in a Telegram channel session today (2026-05-04, US/Pacific): bare text calls to gemini-3-flash-preview return cleanly in ~1s, but multi-turn flows with image inputs and mixed-provider conversation history hang at exactly 120s on repeat, eventually surfacing to the user as "⚠️ Something went wrong while processing your request. Please try again, or use /new to start a fresh session." That generic Telegram error is tracked separately as #74822 — same root cause, two issue surfaces. Likely a single fix closes both.

  4. steipete commented on May 7, 2026

    @steipete
    Contributor

    Fixed on current main in 85b914a.

    Proof:

    • extensions/google/transport-stream.ts now emits Google’s documented skip_thought_signature_validator fallback for Gemini 3 cross-provider tool-call replay when no reusable same-route signature exists.
    • src/agents/openai-transport-stream.ts applies the same fallback for Google OpenAI-compatible Gemini 3 tool-call replay.
    • Regression coverage: extensions/google/transport-stream.test.ts and src/agents/openai-transport-stream.test.ts.
    • Verified with the targeted test batch listed in [Bug]: MIME sniff maps PNG files to image/apng, causing Claude API rejection (400 ValidationException) #51881.

    Closing as fixed.

  5. locked as resolved and limited conversation to collaborators on May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions