anomalyco / anomalyco/opencode
Session run defects are silently dropped — UI shows no error, session just goes idle
@jlongster is already working on this.
Since Aug 13, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Title: Session run defects are silently dropped — UI shows no error, session just goes idle
Problem
When a session run fails with an unexpected defect (e.g. a tool-load failure, a resolver error, a provider bug), no error is surfaced in the UI at all. The session transitions to idle as if it succeeded — the user gets no error message, nothing to indicate the run failed.
Repro
- Set up a project whose tool load fails (a
.opencode/tool/broken.tsimporting a nonexistent package). - In the web UI, open a session in that project and send any prompt.
- Observed (before fix): the assistant turn ends, the session goes idle, and no error is shown — the real
ResolveMessagenever appears anywhere in the UI.
(With opencode run in a terminal the failure does surface, but only as the generic masked fallback Unexpected server error. Check server logs for details. — the real cause is still lost.)
Root cause
The session.error event is published after the session.status idle event, so UI consumers that stop processing on idle never render it.
packages/opencode/src/effect/runner.ts — finishRun (line ~70) publishes the session's idle status (via the onIdle hook → session.status idle) before completing the run's Deferred. The failure then propagates out of ensureRunning to the HTTP handler, whose catchCause publishes session.error. The SSE ordering is therefore always:
session.status busy → session.status idle → session.error (error arrives too late)
Clients that stop consuming on idle never see the error, and the web session renderer marks the turn complete when idle arrives — so the error is never displayed.
Expected
The real error message must reach the UI. The session.error event should be published before the idle status so consumers that stop on idle still receive and render it.
Notes
- I hit this using headless opencode via the web browser (the
opencode serveAPI driven from a browser session); I did not test or investigate the TUI. - Related to the companion issue about tool files that fail to load: the broken-tool repro is the easiest way to trigger this, but this issue covers any unexpected session-run defect.
- The masking boundary lives in
packages/opencode/src/server/routes/instance/httpapi/middleware/error.ts(defect-only 500s →NamedError.Unknownwithref); the core problem here is ordering, not just the mask.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.