anomalyco / anomalyco/opencode

Expose stream timeout/retry state to users — silent infinite retry leaves UI stuck on "thinking" for 20+ min (opencode-go/hy3, Desktop v1.18.23)

Open
#45,514 0 comments 0 reactions 1 assignee View on GitHub

@Brendonovich is already working on this.

Since Aug 27, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
Avg merge
7h 2m
Merged PRs (30d)
384

Description

Summary

When an LLM stream fails with Headers Timeout Error (upstream returns no headers within the ~5 min default limit), the desktop UI keeps showing "thinking…" while the client silently retries with no backoff and no max attempts. Users cannot tell whether the model is reasoning, the network is slow, or the service is down — the error is only discoverable via logs.

Environment

  • OpenCode Desktop v1.18.23 (Windows)
  • Provider: opencode-go · Model: opencode-go/hy3 (orchestrator)
  • "部署在中国的模型" toggle: enabled
  • Account: subscribed, quota healthy (5h usage ~6%)

Repro

  1. Send a message with hy3 as orchestrator → UI shows "thinking…"
  2. Every ~5m07s the log records AI_APICallError: Cannot connect to API: Headers Timeout Error (HeadersTimeoutError), then auto-retries immediately — the loop repeats indefinitely
  3. After 20+ minutes of silent waiting, the user manually cancels; only then does checking ~/.local/share/opencode/log/opencode.log reveal the errors
  4. Switching to opencode-go/deepseek-v4-flash in the same session works instantly

Timeline (2026-08-27, one session)

Time (UTC+8) Event
13:58:41 Request #1 (hy3)
14:03:48 Headers Timeout Error (5m07s wait) → auto retry
14:08:57 Timeout #2 (5m06s) → auto retry
14:14:09 Timeout #3 (5m07s) → auto retry
14:19:26 Timeout #4 (5m08s) → auto retry
14:21:57 User manually cancels
14:22:53 Switch to opencode-go/deepseek-v4-flash → instant, normal responses

Log excerpt (sanitized)

timestamp=2026-08-27T05:58:41.318Z level=INFO message="llm runtime selected" llm.runtime=ai-sdk llm.provider=opencode-go llm.model=hy3
timestamp=2026-08-27T06:03:48.830Z level=ERROR message="stream error" providerID=opencode-go modelID=hy3 agent=orchestrator mode=primary error.error="AI_APICallError: Cannot connect to API: Headers Timeout Error (cause: HeadersTimeoutError: Headers Timeout Error)"
timestamp=2026-08-27T06:03:51.240Z level=INFO message=stream providerID=opencode-go modelID=hy3 ...   # auto retry
timestamp=2026-08-27T06:08:57.666Z level=ERROR message="stream error" ... error.error="AI_APICallError: Cannot connect to API: Headers Timeout Error ..."
timestamp=2026-08-27T06:09:02.270Z level=INFO message=stream ...                            # auto retry
# ... repeats at 06:14:09, 06:19:26 ...
timestamp=2026-08-27T06:21:57.481Z level=INFO message=cancel ...                         # user cancels

Expected behavior

  1. Surface the failure to the user. On the first stream failure, show a visible status/error in the UI (e.g. banner or notification: "Model service timed out, retrying (1/N)…") instead of continuing to show "thinking…"
  2. Bound the retries. Add max attempts + exponential backoff; after exhausting them, present a clear error with actionable choices (retry / switch model / stop)
  3. Notify on recoverable timeouts. Route server-side stream timeouts into the existing error-notification channel (Settings > General > System Notifications > Errors) so background sessions alert the user in time

Related issues

  • #41848 — LLM retry has no max attempts: stream errors cause infinite retry loop, UI stuck on Thinking
  • #32366 — UI stuck on 'thinking' indefinitely after stream error, no error displayed or state recovery
  • #38951 — API 404 error silently hangs session in 'thinking' state with no error recovery
  • #41365 — Desktop: conversation freezes mid-"thinking", no error, must abort and resend — missing watchdog/retry UX
  • #37412 — Feature: Add automatic retry with exponential backoff for LLM API timeouts
  • #43596 — Configurable retry policy: expose maxRetries / initialDelay / backoffFactor / maxDelay via config
  • #26602 — Desktop hits 5-minute Headers Timeout Error with slow local providers
  • #20119 — HeadersTimeoutError after 5 minutes when using @opencode-ai/sdk versions > 1.3.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.