You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
opencode run -s <missing-session-id> exits 0 with zero stdout instead of failing #27559
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.
Activity
github-actions commentedon May 14, 2026
This issue might be a duplicate of existing issues. Please check:
opencode runexits with code 0 when an error occurs (invalid model in that case, missing session in yours)If these are the same underlying exit-code handling issue, it may make sense to consolidate.
github-actions commentedon Jul 14, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.