Repository navigation
fix(cli): report terminal outcomes for noninteractive runs - #60508
rekram1-node wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Recovered runs now exit 0, and I found no blocking issues.
I ran the #50062 repro from source on both checkouts. On the base it emits a provider.transport error event and exits 1 even though the retried step finishes with stop. With this PR the same scenario has no error event and exits 0. One caveat: with the original 300 ms socket drop, the PR runs happened to drop before any output arrived, so core retried quietly. I delayed the drop to 1500 ms so the recovered-after-output path actually ran; the base still exits 1 under that timing. bun test test/run: 24 pass. tsc -b in packages/cli: no errors.
A step failure that core does not retry still ends in an execution failure, so real failures still exit 1. Interrupt (130), permission rejection and V1 behaviour are unchanged.
Public API: no SDK, HTTP, plugin or config changes, and no new event types. The changes are in what opencode run outputs and its exit codes: --format json no longer emits an error event for a recovered step (and default format no longer prints it to stderr); a cancelled form that isn't a question now emits one error event explaining why (it already exited 1); and a run only counts as successful if the execution itself succeeded, not just its last step. Consumers that parse error events are affected but won't break.
Related: #39573
Problem
opencode run --format=jsoncan exit 1 and emit anerroreven when an interrupted model response recovers and the execution succeeds. Scripts and CI consumers cannot distinguish a recovered step from a failed run.Fixes #50062.
Change
Keep V1 behavior, real execution failures, SIGINT, and local cancellation exit codes. Wait for the terminal event when the idle marker has not projected yet, even if an assistant already responded. Non-question forms still fail non-interactive runs, now with an explicit diagnostic; question cancellation remains recoverable.
Related: #52885 addresses exit status. This also removes recovered-step JSON errors and uses execution markers, not the last assistant, when terminal events lag or are missing.
Out of scope
No model retry policy, Core/API changes, or new JSON event types. Step usage reconciliation is unchanged.
Verification
bun test test/run --timeout 30000 --rerun-each 10 --only-failures: 240 pass.bun test --timeout 30000 --only-failures: 364 pass, 9 skip, 0 fail across 54 files.bun typecheck: pass.bun run typecheck:tsc: pass.bun run check: pass with existing lint warnings.Visual
Added by the opencode bot (AI-generated).
Related: #39573
Public API:
opencode run: noerrorevent or exit 1 for recovered steps; adds an explanatoryerrorfor cancelled non-question forms (event types unchanged, backwards compatible)