Repository navigation
bug: UI stuck on 'thinking' indefinitely after stream error, no error displayed or state recovery #32366
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Description
Issue
When a stream error occurs (e.g., AI_APICallError, socket closed unexpectedly), the desktop UI gets stuck showing "thinking..." indefinitely. No error message is displayed, no state recovery happens, and the session becomes unusable. The user must restart the app to recover.
Root Cause Analysis
After analyzing multiple server logs from debug dumps:
-
Stream errors are frequent but silently swallowed
AI_APICallError: <none>— empty error object, no details from the upstream APIAI_APICallError: The socket connection was closed unexpectedly— upstream proxy terminates the SSE stream mid-response- These errors are logged on the server side but never propagated to the UI
-
UI state machine never transitions out of 'thinking'
- After a stream error, the server logs show the session is dead (no further
streamevents) - But the desktop UI continues displaying "thinking..." with no cancel button or error indicator
- The frontend apparently waits for a stream event that will never come
- After a stream error, the server logs show the session is dead (no further
-
No automatic retry or timeout
- No retry mechanism after stream failure
- No client-side timeout to abort stuck states
- User must manually cancel or restart the app
-
Server log stops processing
- In one dump, the last log entry at
2026-06-15T01:46:02Zwas acancelevent - After that, zero log entries despite the UI showing "thinking"
- This confirms the server stopped processing but the UI never received this state change
- In one dump, the last log entry at
Server Log Evidence
# Frequent silent stream errors (no error detail)
level=ERROR message="stream error" providerID=YerPlan modelID=qwen3.6-plus error.error="AI_APICallError: <none>"
# Socket-level failures
level=ERROR message="stream error" error.error="AI_APICallError: Cannot connect to API: The socket connection was closed unexpectedly"
# After stream errors, server stops responding but UI stays 'thinking'
level=INFO message=cancel session.id=ses_13898e204ffemfGewCcp9BrPCN
# ← zero further log entries after this point (01:46 UTC)
Steps to Reproduce
- Connect opencode desktop to an API provider via an openai-compatible proxy (e.g.,
https://api.xxx.com/v1) - Use a worktree session on a local project directory
- Send a message that triggers a long-running response
- Wait for the upstream proxy to drop the connection (intermittent, but happens frequently with unstable proxies)
- Observe: UI stuck on "thinking...", no error shown, session unresponsive
Expected Behavior
- Display an error message when the stream fails (e.g., "Connection lost. Retry?")
- Provide a "Retry" or "Cancel" button
- Implement a client-side timeout to prevent indefinite stuck states
- Auto-recover when the server stops responding
Environment
- opencode: 1.17.7 (Desktop app)
- OS: macOS darwin arm64 (M-series)
- Electron: 42.3.3 / Chrome 148
- Provider: openai-compatible proxy (not direct Anthropic/OpenAI)
- Model: qwen3.6-plus (via proxy)
- Node: 24.15.0
Related Issues
- UI stuck on 'Thinking...' when tool output is pending #17655: UI stuck on 'Thinking...' when tool output is pending
- Build mode with Thinking enabled: UI freezes during thinking stream, incomplete output rendering #19512: Build mode with Thinking enabled — UI freezes during thinking stream
- Main & Sub-agents Randomly Freeze Indefinitely: Frontend Permanently Shows "thinking" with No Errors, While Actual LLM Inference Has Already Terminated Prematurely #24342: Main & Sub-agents Randomly Freeze Indefinitely: Frontend Permanently Shows "thinking"
- Critical bug: Opencode desktop get completly stuck #23481: Similar — agents stuck with frontend permanently showing "thinking", no errors
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
github-actions commentedon Jun 15, 2026
This issue might be a duplicate of existing issues. Please check:
time.completed) and proposes the same startup recovery fixSuperissac commentedon Jun 15, 2026
Updated findings after deep investigation
API works fine (direct curl test)
But opencode CLI gets stuck even with --pure (no plugins)
opencode --pure /Users/issac/ -m YerPlan/qwen3.6-plus # Stuck on "thinking..." forever, server logs show stream starts but never completesRoot cause hypothesis
The API returns stream chunks with
reasoning_contentin the delta:{"choices":[{"delta":{"content":null,"reasoning_content":"Here's a thinking process..."}}]}But
@ai-sdk/openai-compatiblemay be expecting reasoning in a different format (e.g., Anthropic-stylethinkingblocks or OpenAI-stylereasoningobject). The adapter likely never recognizes the stream as complete when processingreasoning_contentfrom Qwen models, causing the agent loop to hang indefinitely.This is NOT:
Likely fix
The
@ai-sdk/openai-compatibleadapter needs to properly handlereasoning_contentin stream chunks from qwen-compatible endpoints. The current implementation may treat it as an incomplete or malformed response type that never transitions to the text phase.marceloj commentedon Jul 6, 2026
I'm experiencing the same issue on OpenCode Desktop v1.17.13 on Windows. The UI gets stuck on "thinking..." indefinitely after a stream error, with no error message or recovery. The only way to fix it is to restart the app.
I've reproduced this with 3 different models/providers:
The issue happens with all of them, so it's not model-specific — it's a bug in the desktop app's stream error handling. The session becomes completely unresponsive and there's no cancel/retry option.
Happy to provide debug logs if needed.
H3XDaemon commentedon Jul 12, 2026
Hit this same permanently-stuck state from a different trigger (a database schema error, #35986) and traced the full path, which might be useful here since a frontend fix alone can't cover it.
The client sets
session_statusto busy optimistically on submit (packages/app/src/components/prompt-input/submit.ts).prompt_asyncreturns 204 and forks the actual work; when that fork fails, the catch inpackages/opencode/src/server/routes/instance/httpapi/handlers/session.tslogs the cause and publishesSession.Event.Error— but nothing on this path ever publishes an idle status. The only place that resets status on failure is the v1 processor'shaltchain (packages/opencode/src/session/processor.ts,catchCauseIf→halt→ error event +status.set idle), and failures that happen before the stream starts never reach it. The v2 runner side is worse: its coordinator only logs defects (packages/core/src/session/execution/local.ts) with no terminal event at all.So the spinner waits on a status change that no code path will ever send. In my case the session was also unrecoverable across restarts because the underlying SQL failure was deterministic — every new prompt died the same way. Log line for reference, note the error message itself is lost to serialization (that part is #35986):
JonatanGarbuyo commentedon Aug 4, 2026
I can reproduce the same stuck-state path with the direct OpenAI provider, not an OpenAI-compatible proxy.
Environment
1.18.11(currently1.18.13)openai/gpt-5.6-terraObserved sequence
AI_APICallError: <none>after about 43 seconds.Aborted.Sanitized log excerpt:
The automatic retry is noteworthy: it recovered the initial failed stream but could still leave the subsequent request permanently pending. A timeout/error transition after the retry, plus a visible retry/cancel action in TUI, would prevent the session from appearing unrecoverable.
aentrepreneur commentedon Aug 16, 2026
Confirming this occurs with the built-in
opencodeprovider too (not only openai-compatible proxies).OpenCode 1.18.18 (Linux/WSL2),
providerID=opencode modelID=big-pickleshows stream transport errors like:User-visible symptom: the session can “lose the connection” without a clear on-screen error (silent drop / no explicit terminal error state), matching the core bug described here.
I also opened a specific issue focused on
opencode/big-pickle+ socket-closed failures and linked it back here.session: recover from dropped model streams with no terminal event
andrew222651 commentedon Aug 23, 2026
The web interface has the same problem
Animo78 commentedon Oct 4, 2026
Got the same issue :(
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊