Summary
opencode run -s <session-id> with a session id that doesn't exist locally exits with code 0 and produces zero stdout, after only writing a NotFoundError to stderr. For consumers that script around opencode and rely on exit codes to decide success vs. failure, this looks indistinguishable from a successful no-op run.
Version
opencode 1.14.19 (Linux x64, installed via packaged binary in a Daytona sandbox).
Repro
# Use any session id that doesn't exist on this machine:
echo "hi" | opencode run --format json -m amazon-bedrock/us.anthropic.claude-sonnet-4-6 --variant low -s ses_doesnotexist 2>stderr.log
echo "exit=$?"
cat stderr.log
Observed:
exit=0
NotFoundError: NotFoundError
data: {
message: "Session not found: ses_doesnotexist",
},
at <anonymous> (/$bunfs/root/chunk-1q2thjd0.js:684:105806)
at ~effect/Effect/successCont (/$bunfs/root/chunk-t65044z0.js:25:7738)
...
Expected
opencode run -s <missing> should exit with a non-zero status (e.g. 2 for "not found" or 1 for any error). Ideally also emit a single JSON event on stdout when --format json is set, so JSON-stream consumers can detect the failure without parsing stderr.
Why it matters
We script around opencode run --format json -s <prior-session> to resume agent conversations. Stale ids happen routinely (sandboxes get recycled, machines change, sessions get cleaned up). With exit code 0 + zero stdout + stderr-only error, the only way to distinguish "session resume failed" from "agent ran and intentionally produced no output" is to grep stderr for NotFoundError, which is brittle.
Context
Found while debugging a repeated silent failure in our agent orchestrator. Diagnosis writeup: https://linear.app/goldsky/issue/INFRA-3766 (internal, but referenced for traceability).
Suggested fix
In the run command's session-lookup path, treat "session not found" as a fatal error: return non-zero. Optionally accept --no-fail-on-missing-session for callers that prefer today's behavior.
Happy to PR if useful — pointer to the relevant lookup site appreciated.
Summary
opencode run -s <session-id>with a session id that doesn't exist locally exits with code 0 and produces zero stdout, after only writing aNotFoundErrorto stderr. For consumers that script around opencode and rely on exit codes to decide success vs. failure, this looks indistinguishable from a successful no-op run.Version
opencode 1.14.19(Linux x64, installed via packaged binary in a Daytona sandbox).Repro
Observed:
Expected
opencode run -s <missing>should exit with a non-zero status (e.g.2for "not found" or1for any error). Ideally also emit a single JSON event on stdout when--format jsonis set, so JSON-stream consumers can detect the failure without parsing stderr.Why it matters
We script around
opencode run --format json -s <prior-session>to resume agent conversations. Stale ids happen routinely (sandboxes get recycled, machines change, sessions get cleaned up). With exit code 0 + zero stdout + stderr-only error, the only way to distinguish "session resume failed" from "agent ran and intentionally produced no output" is to grep stderr forNotFoundError, which is brittle.Context
Found while debugging a repeated silent failure in our agent orchestrator. Diagnosis writeup: https://linear.app/goldsky/issue/INFRA-3766 (internal, but referenced for traceability).
Suggested fix
In the
runcommand's session-lookup path, treat "session not found" as a fatal error: return non-zero. Optionally accept--no-fail-on-missing-sessionfor callers that prefer today's behavior.Happy to PR if useful — pointer to the relevant lookup site appreciated.