Repository navigation
Description
Summary
While using the built-in opencode provider with model big-pickle (Zen free), the connection can drop mid-stream with:
AI_APICallError: Cannot connect to API: The socket connection was closed unexpectedly ...
When this happens, the user reports that the UI effectively “loses the connection” without clearly surfacing the error (silent drop / no visible error state).
This appears to be the same class of problem as:
- bug: UI stuck on 'thinking' indefinitely after stream error, no error displayed or state recovery #32366 (UI stuck on thinking after stream error)
- Silent failure: opencode provider returns 500 errors but client drops response without showing error #38644 (silent failure after provider 500s)
…but this report is specifically the socket-closed failure mode on providerID=opencode modelID=big-pickle.
Environment
- OpenCode: 1.18.18 (from
~/.local/share/opencode/log/opencode.log) - OS: Linux (Ubuntu 24.04) / WSL2 environment
- Provider/model:
providerID=opencode modelID=big-pickle - Agents impacted:
plan,build,compaction(allsmall=false)
Evidence (last 5 minutes)
Log aggregation from ~/.local/share/opencode/log/opencode.log for the last 5 minutes (UTC):
stream_error_big_p_k_socket_closed: 2aborted: 6failed_fetch_models.dev: 1
Verbatim lines (UTC):
timestamp=2026-08-16T23:51:13.948Z level=ERROR run=042c53b4 message="stream error" providerID=opencode modelID=big-pickle session.id=ses_ff3194081ffebphxmz8WESfcYH small=false agent=build mode=primary error.error="AI_APICallError: Cannot connect to API: The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch() (cause: Error: The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch())"
timestamp=2026-08-16T23:53:54.387Z level=ERROR run=042c53b4 message="stream error" providerID=opencode modelID=big-pickle session.id=ses_ff3194081ffebphxmz8WESfcYH small=false agent=compaction mode=primary error.error="AI_APICallError: Cannot connect to API: The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch() (cause: Error: The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch())"
# After the above, multiple Aborted entries follow (examples):
# timestamp=2026-08-16T23:53:26.380Z level=ERROR ... error=Aborted
# timestamp=2026-08-16T23:54:32.494Z level=ERROR ... error=Aborted
Session creation line confirms version/model:
timestamp=2026-08-16T23:27:24.030Z level=INFO run=042c53b4 message=created id=ses_ff3194081ffebphxmz8WESfcYH ... version=1.18.18 ... agent=plan model.id=big-pickle model.providerID=opencode
Additional observation
In the same hour, the models catalog fetch briefly failed:
timestamp=2026-08-16T23:25:20.625Z level=ERROR run=84bab50d message="Failed to fetch models.dev" cause="... Transport error (GET https://models.opencode.ai/api.json) ..."
But immediately after, manual curl -I https://models.opencode.ai/api.json succeeded with HTTP/2 200 (so this may be transient connectivity/DNS, but it’s correlated in time).
Expected
- Stream transport errors (socket closed, 5xx, etc.) are always surfaced to the user.
- The UI must never remain in an ambiguous “thinking”/silent state.
- Provide clear recovery actions (Retry/Cancel) and a deterministic terminal state.
Actual
opencode/big-pickleintermittently throws socket-closed stream errors.- User-visible behavior: connection appears lost with no clear error surfaced on screen.
Related historical evidence
- In Silent failure: opencode provider returns 500 errors but client drops response without showing error #38644 (open), there is quantitative evidence of hundreds of
Internal server errorevents forproviderID=opencode modelID=big-pickleacross multiple days (see comment byaentrepreneur).
Ask
Can we:
- Ensure all
stream errorpaths transition the UI/session state to an explicit error (never silent). - Make retry/backoff behavior and timeouts consistent for
small=falseprimary agents. - Consider logging a clear “giving up after N retries” and surfacing it to the UI.
Activity
aentrepreneur commentedon Aug 17, 2026
Update: same session/run shows the same socket-closed stream error hitting the OpenAI provider too.
From
~/.local/share/opencode/log/opencode.log(OpenCode 1.18.18, Linux/WSL2), within the same run042c53b4/ sessionses_ff3194081ffebphxmz8WESfcYH:So this may be a broader transport/session handling problem (not only
opencode/big-picklebackend 500s), but the user-visible symptom is the same: connection drops and the UI doesn’t clearly surface a terminal error state/recovery action.aentrepreneur commentedon Aug 25, 2026
(Superseded) This comment got mangled by shell quoting when posted. Please ignore it and refer to the clean repost here:
#42950 (comment)
aentrepreneur commentedon Aug 25, 2026
Update (v1.18.22, Linux/WSL2) — still lots of disconnects + long reconnect loops on free models
Note: my previous comment (same timestamp) got mangled by shell quoting. Re-posting the clean data below.
Environment
Linux 6.18.33.2-microsoft-standard-WSL2)~/.local/share/opencode/log/opencode.logQuantitative summary (last 14 days)
I bucketed ERROR/stream-error lines into kinds:
rate_limitopencode/*-freeandopencode/big-picklesocket_closedopencode/big-pickleand alsoopenai/gpt-5.2in same environmentmodels_catalog_fetchFailed to fetch models.dev/GET https://models.opencode.ai/api.jsontimeouts/transportcannot_connectTop contributors observed in this window:
opencode/big-pickle:rate_limit=26,socket_closed=6opencode/hy3-free:rate_limit=9opencode/deepseek-v4-flash-free:rate_limit=8Representative log lines (verbatim)
1) Socket closed (Zen/free)
2) 429 / Rate limit exceeded (free models)
3) Models catalog fetch failures (still happening; contributes to long reconnect + picker/model listing degradation)
Related issues (same failure class)
opencode/big-pickle)Forbiddenon opencode-go)Ask / expected fix direction
ECONNRESET) — aligns with Sessions fail on transient network errors instead of retrying #30611.stream errortransitions UI/session to an explicit error state (avoid silent drops / infinite thinking) — aligns with bug: UI stuck on 'thinking' indefinitely after stream error, no error displayed or state recovery #32366/Silent failure: opencode provider returns 500 errors but client drops response without showing error #38644.models.opencode.ai/api.jsonfetch fails (avoid long reconnect loops).NewbSites commentedon Aug 31, 2026
The same root cause was observed on native Windows (win32, PowerShell); the existing reports are Linux/WSL2, so adding platform data.
opencode-go/glm-5.3-flasherror=Abortedentries in a single working sessionlevel=ERROR message=process session.id=… messageID=msg_… error=Aborted stack=undefinedHappy to provide full log excerpts or a session share link if useful.
aentrepreneur commentedon Sep 2, 2026
Cross-issue correlation from the same environment — and a log discriminator between this issue and #46030
Same setup as my previous updates (Ubuntu 24.04 / WSL2,
~/.local/share/opencode/log/opencode.log, full history through 2026-09-02).Updated totals:
message="stream error"entries now total 890 across the whole log (872 at my 2026-08-31 analysis). The embedded detail is consistentlyAI_APICallError: Cannot connect to API: Unable to connect. Is the computer able to access the url?, occasionally surfaced at process level aserror="Cannot connect to API: ...".Still live on the current build: latest burst 2026-09-01 21:54–21:55 UTC — 4 consecutive
stream errorentries within ~60 s onopencode/big-pickle(run344cbc38, 14 on that run overall) during normal interactive use, immediately followed by a process-levelCannot connect to API. The v1.18.26 release notes contain no changes touching provider transport/socket handling (Bedrock, Claude-thinking and Desktop fixes only).Log discriminator — two separable failure layers:
On 2026-08-28, run
a9c7879c(sessionses_ff3194081ffebphxmz8WESfcYH, agentbuild) logged 523opencode/big-picklestreams + 556 loop steps with zerostream error/ rate-limit / cannot-connect entries — a text-only autoregressive loop with no tool parts between streams (mechanism + minimal repro in #46030, comments from 2026-08-31).stream error,AI_APICallError: Cannot connect to API, the quantitative table in the v1.18.22 update aboveBoth can co-occur in the same session history, but they are separable by signature: the loop failure produces no transport errors, so a transport-side fix won't address it (and vice versa). Together with @NewbSites' native-Windows report on
opencode-go/glm-5.3-flash, the transport pattern spans platforms and bothopencode/*(free) andopencode-go/*(paid) endpoints — pointing at the provider/proxy side rather than any single model.Happy to re-measure the totals after any transport-side patch lands.
aentrepreneur commentedon Sep 13, 2026
Update (v1.18.30, 2026-09-12) — full-day clean session log; proposing re-evaluation / closure
Same environment (Ubuntu 24.04 / WSL2,
~/.local/share/opencode/log/opencode.log). Note: the log rotated, so the current file covers 2026-09-12 only; historical trend data beyond that is no longer locally available (I'm adding daily archival on my side so future deltas survive rotation).Current evidence (v1.18.30, 3 sessions,
opencode/big-pickle, main agents plan/build/compaction):message="stream error"Failed to fetch models.dev(catalog)error=Abortedmessage=cancel(user-initiated Esc), not silent drops274
streamcalls vs 1,568 tool/permission events → healthy tool interleaving (no sustained no-op bursts).Version note:
v1.18.27added "Default streamed chunk timeouts to five minutes", which addresses the silent-stall variant this issue overlapped with (#37580/#38644 class).Proposal: the socket/silent-drop class shows no recurrence on the current build. If no regression appears in the coming days, recommend closing as resolved on current stack. The remaining behavior class (text-only narration loop with clean logs, no transport errors, reproducible on 2026-08-28) is the discriminator we documented and is tracked separately in #46030.
aentrepreneur commentedon Sep 16, 2026
Update (v1.18.31, 2026-09-15 UTC) — no stream-error class observed today
Upgraded to v1.18.31 (log shows install at 2026-09-14T23:24Z; new session created 2026-09-15T01:06Z).
In my Ubuntu 24.04 / WSL2 environment (networkingMode=mirrored; DNS via
nameserver 10.255.255.254), today’s log window2026-09-15T00:00Z → 22:44Zshows:level=ERROR message="stream error": 0level=ERROR ... AI_APICallError: 0socket hang: 0level=ERROR ... error=Aborted: 2 (likely local cancels)I’ll keep monitoring and can share the full daily log slice if useful.
aentrepreneur commentedon Sep 28, 2026
Transport-class recurrence data point for the free
opencodegateway, on 1.18.32 (latest).Incident (2026-09-28, ~01:06–01:13 UTC):
opencode/big-pickle(build agent) was streaming a request when the connection dropped mid-stream.Unable to connect. Is the computer able to access the url?(×8) andWas there a typo in the url or port?(×4).Cannot connect to API: Unable to connect.... In-flight work was preserved (edits made before the drop stayed intact via the original messageID) and the session resumed normally afterwards.Local connectivity was NOT the cause: no other endpoint failed in the window, DNS resolves fine, and
https://api.opencode.ai/returns HTTP 200 in <1 s right now.Recurrence over the last 16 days (this error class only, from client logs):
models.opencode.ai— host-wide)All self-recovered within minutes; failures come in short bursts against the shared free gateway (
opencodeprovider ships an embedded gateway — no user auth entry). Seeing this class repeatedly across 1.18.30→1.18.32 points to gateway/network egress rather than client retry logic. Happy to grab more datapoints or run targeted probes if it helps debugging on your side.aentrepreneur commentedon Oct 5, 2026
Update (v1.18.34, 2026-10-04) — no recurrence of the transport class in 6 days; residual errors are quota, not transport
Same environment (Ubuntu 24.04 / WSL2, mirrored networking,
nameserver 10.255.255.254), live log through 2026-10-04.Transport class (
Cannot connect to API/ socket-closed on the freeopencodegateway):Remaining
AI_APICallErrorentries are NOT this class. Per-day totals remain (e.g. 34 on 09-29, 36 on 10-04) but they resolve to the free-tier quota subclass (Rate limit/Weekly usage limit reached, onopencode-gomodels) — distinct from the connect/socket transport failure tracked here, and unrelated to the client.Also: socket-closed total in the full live log is 4, all before 09-28;
ProviderHeaderTimeoutErroris 1-2/day (minor, separate).Releases 1.18.33/1.18.34 carry no transport/stream changes (timeouts for Cloudflare AI Gateway, namespaced session headers, macOS signing, TUI fixes), so the disappearance of this class since 09-28 is attributable to the gateway/network side recovering. If no recurrence in the coming weeks, consider this candidate for closure. Happy to post a negative follow-up if it reappears.
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 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊
aentrepreneur commentedon Oct 12, 2026
Update — the transport class recurred after my last check, so leaving it as resolved would be inaccurate.
2026-10-06 (post last comment): 4×
stream erroron the freeopencode-gogateway, modelglm-5.3-flash, single session (ses_f4aa76361ffefStlxVhC0hANGh), retry window 12:02:35→12:03:52 UTC — same signature as the 09-28 incident:AI_APICallError: Cannot connect to API: Unable to connect. Is the computer able to access the url?/Was there a typo in the url or port?. Session recovered afterward (no banner observed).So the correct history for this class on v1.18.x: 09-14 (9), 09-16 (2), 09-28 (14), 10-06 (4) — intermittent, minute-scale, off-and-on, never a sustained outage.
I understand this is being closed as part of the 1.x → 2.0 triage. Noted. I'll validate on 2.0 after migrating and will reopen or open a fresh 2.0 issue if it persists there. Keeping the data point here for completeness.