anomalyco / anomalyco/opencode

opencode run exits 1 after auto-compaction recovers from a provider 413

Open
#39,573 0 comments 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Jul 29, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

opencode run exits 1 (and the TUI shows an error toast) when a provider rejects a request for size (HTTP 413 / ContextOverflowError), even though auto-compaction recovers: the session compacts, retries, and produces a complete correct answer. Anything scripting opencode run or tailing --format json sees the run as failed.

Cause: the auto-compact branch in processor.ts halt() publishes Session.Event.Error before attempting recovery:

ctx.needsCompaction = true
yield* events.publish(Session.Event.Error, { sessionID: ctx.sessionID, error })
return

Consumers (cli/cmd/run.ts, tui/app.tsx, app/context/notification.tsx) all treat session.error as the run's outcome. This publish is inconsistent with the rest of the codebase: it doesn't set message.error (the durable message says no error), it isn't followed by idle or a throw, and nothing consumes it — compaction is triggered by the "compact" return value. Retried 429s and the proactive overflow check are both silent.

Steps to reproduce
  1. Run a non-interactive prompt against a session large enough that the provider returns 413, with auto-compaction enabled
  2. Compaction recovers and the final answer is produced
  3. opencode run exits 1; --format json stdout contains an error event

Reproducible with the test-LLM harness: push a 413 (request_too_large), then two text replies; opencode run --format json exits 1 despite emitting the recovered output.

OpenCode version

dev (processor.ts:616)

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.