openclaw - 💡(How to fix) Fix Google Gemini models (3.1 Pro & 2.5 Pro) hang/timeout on all main sessions, but work fine via direct API & isolated subagents [2 comments, 3 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#78502Fetched 2026-05-07 03:36:11
View on GitHub
Comments
2
Participants
3
Timeline
2
Reactions
2
Timeline (top)
commented ×2

All Google Gemini models (gemini-3.1-pro-preview, gemini-2.5-pro) hang for ~300s and then timeout on every main OpenClaw session (TUI agent:main:main, dashboard, Telegram). There is no streaming progress at all — no first chunk — and then OpenClaw falls back to the next model (Opus, GPT, etc.).

However: -Direct calls to the Google API (via curl and @google/genai) work perfectly. -Isolated subagent sessions (minimal context) work perfectly on the same Gemini models.

This looks like a bug in OpenClaw’s Google provider / streaming pipeline for “full” session contexts.

Error Message

[diagnostic] lane task error%3A durationMs%3D320672 error%3D"FailoverError%3A LLM request timed out."

Root Cause

All Google Gemini models (gemini-3.1-pro-preview, gemini-2.5-pro) hang for ~300s and then timeout on every main OpenClaw session (TUI agent:main:main, dashboard, Telegram). There is no streaming progress at all — no first chunk — and then OpenClaw falls back to the next model (Opus, GPT, etc.).

However: -Direct calls to the Google API (via curl and @google/genai) work perfectly. -Isolated subagent sessions (minimal context) work perfectly on the same Gemini models.

This looks like a bug in OpenClaw’s Google provider / streaming pipeline for “full” session contexts.

Fix Action

Fix / Workaround

  1. @google/genai SDK tests (same machine, same key)
  • From /usr/lib/node_modules/openclaw, using the same API key • Full system prompt (workspace files) %2B 30 tools (functionDeclarations%2C parametersJsonSchema) %2B thinking %2B streaming • Various tests including anyOf%2C complex nested schemas%2C and OpenClaw-style dispatcher timeouts • All return first chunk within 3–7s%2C complete within ~7–13s

%23%23 Current workaround -Primary model%3A openai%2Fgpt-5.1 (same $%2FM as Gemini%2C 400K context) -Fallbacks%3A anthropic%2Fclaude-opus-4-6%2C google%2Fgemini-2.5-pro%2C ollama%2Fqwen...\n Gemini is currently disabled for main work and only used cautiously in isolated subagent runs.\n\n> Ask: guidance on diagnosing the Google provider pipeline for main sessions, and whether tool schema size / parametersJsonSchema + thinking could be causing silent hangs on initial streaming.">

RAW_BUFFERClick to expand / collapse

Environment

-OpenClaw: 2026.5.5 (b1abf9d) — also reproduced on 2026.5.3-1 -OS: WSL2, Linux 6.6.87.2-microsoft-standard-WSL2 (x64) -Node: v22.22.0 -Google SDK: @google/genai 1.52.0 (also reproduced on 1.51.0) -pi-ai: @mariozechner/pi-ai 0.73.0 -Google API Tier: Tier 3

Summary

All Google Gemini models (gemini-3.1-pro-preview, gemini-2.5-pro) hang for ~300s and then timeout on every main OpenClaw session (TUI agent:main:main, dashboard, Telegram). There is no streaming progress at all — no first chunk — and then OpenClaw falls back to the next model (Opus, GPT, etc.).

However: -Direct calls to the Google API (via curl and @google/genai) work perfectly. -Isolated subagent sessions (minimal context) work perfectly on the same Gemini models.

This looks like a bug in OpenClaw’s Google provider / streaming pipeline for “full” session contexts.

What works

  1. Direct API (curl) — fast, even with huge contexts
  • gemini-3.1-pro-preview:generateContent with ~25K tokens: ~3.6s
  • gemini-3.1-pro-preview:generateContent with ~266K tokens: ~11s
  • streamGenerateContent with tools + systemInstruction: ~6s
  1. @google/genai SDK tests (same machine, same key)
  • From /usr/lib/node_modules/openclaw, using the same API key • Full system prompt (workspace files) %2B 30 tools (functionDeclarations%2C parametersJsonSchema) %2B thinking %2B streaming • Various tests including anyOf%2C complex nested schemas%2C and OpenClaw-style dispatcher timeouts • All return first chunk within 3–7s%2C complete within ~7–13s
  1. Isolated subagents

sessions_spawn({ task%3A "Say 'GEMINI TEST SUCCESSFUL - model%3A [your model name]'"%2C model%3A "google%2Fgemini-3.1-pro-preview"%2C runTimeoutSeconds%3A 60 })

• Subagent completes in ~7 seconds • ~17K tokens (in 16.8K %2F out 295) • Model%3A google%2Fgemini-3.1-pro-preview

%23%23 What fails

  1. Main TUI session (agent%3Amain%3Amain)

• Any user message with Gemini set as primary stalls • Logs show repeated “stalled session” diagnostics%2C then a 300%2B second timeout%2C then fallback

  1. Dashboard %2Fnew sessions

• Creating a fresh dashboard session (no history) on Gemini 3.1 Pro or 2.5 Pro produces the same stall%2Ftimeout behavior • Even on a truly new session%2C first Gemini call never returns a chunk

  1. Telegram session (agent%3Amain%3Atelegram%3Adefault%3Adirect%3A8421240635)

• When pinned to Gemini%2C every message stalls and then falls back to Opus or GPT after ~300s • When pinned to 2.5 Pro%2C the same thing happens%3A 2.5 Pro stalls%2C then fallback to Opus

  1. Forked subagents (context%3A "fork")

• When we try to fork the full context%2C OpenClaw refuses and runs isolated instead (too large to fork)

%23%23 Representative logs Timeout %2F fallback sequence%3A

[agent%2Fembedded] Profile google%3Adefault timed out. Trying next account... [agent%2Fembedded] embedded run failover decision%3A stage%3Dassistant decision%3Dfallback_model reason%3Dtimeout from%3Dgoogle%2Fgemini-3.1-pro-preview [diagnostic] lane task error%3A durationMs%3D320672 error%3D"FailoverError%3A LLM request timed out." [model-fallback%2Fdecision] decision%3Dcandidate_failed requested%3Dgoogle%2Fgemini-3.1-pro-preview candidate%3Dgoogle%2Fgemini-3.1-pro-preview reason%3Dtimeout next%3Dgoogle%2Fgemini-2.5-pro detail%3DLLM request timed out. [5/6/2026 9:55 AM] Fred: Stall diagnostics%3A

%23%23 Context %26 tool sizes From systemPromptReport for a failing session%3A -System prompt%3A 38%2C812 chars (workspace files %2B runtime context) -Tool schemas%3A 29%2C833 chars (30 tools)%2C including%3A

• message%3A 7%2C431 schema chars%2C 113 properties • browser%3A 2%2C920 schema chars%2C 52 properties • video_generate%3A 3%2C785 schema chars%2C 21 properties [5/6/2026 9:55 AM] Fred: Total pre-conversation context (system prompt %2B tools) is ~68K chars. Combined with history%2C failing sessions are usually in the 70K–150K token range — well below 1M.

Standalone SDK tests with similar payloads (all OK)%3A -Workspace system prompt %2B 20–30 complex tools (parametersJsonSchema) %2B thinking %2B streaming \u2192 7–13s total.

%23%23 What we've ruled out -API key %2F auth%3A direct and SDK calls are 200 OK%2C fast. -Rate limits %2F 429s%3A spikes on May 4–5 during heavy traffic%2C but current tests show 200 OK%3B timeouts don't show 429s. -Model deprecation%3A gemini-3.1-pro-preview still listed and responds to direct calls. -Session history corruption%3A brand-new %2Fnew sessions with no history also stall. -WSL2 %2F IPv6%3A tested undici with autoSelectFamily%3A false%3B SDK calls still work. -SDK version%3A behaviour seen on %40google%2Fgenai%401.51.0 and 1.52.0.

%23%23 Current workaround -Primary model%3A openai%2Fgpt-5.1 (same $%2FM as Gemini%2C 400K context) -Fallbacks%3A anthropic%2Fclaude-opus-4-6%2C google%2Fgemini-2.5-pro%2C ollama%2Fqwen...\n Gemini is currently disabled for main work and only used cautiously in isolated subagent runs.\n\n> Ask: guidance on diagnosing the Google provider pipeline for main sessions, and whether tool schema size / parametersJsonSchema + thinking could be causing silent hangs on initial streaming.">

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 Google Gemini models (3.1 Pro & 2.5 Pro) hang/timeout on all main sessions, but work fine via direct API & isolated subagents [2 comments, 3 participants]