Skip to content

fix: run command exits with 0 on session errors #14551

Closed as not planned
Closed as not planned

Description

@kevinWangSheng

Problem

opencode run always exits with code 0 even when the AI session encounters errors (e.g., session.error events). This breaks CI/CD pipelines and scripts that rely on exit codes to detect failures.

Root Cause

In packages/opencode/src/cli/cmd/run.ts, the loop() promise that processes session events (and tracks the error variable) is not awaited. The execute function returns before the event loop completes, so the accumulated error state is never checked.

Expected Behavior

opencode run should exit with a non-zero exit code (1) when the session encounters errors.

Steps to Reproduce

  1. Run opencode run with a prompt that triggers a session error
  2. Check the exit code: echo $?
  3. Observe it is always 0 regardless of errors

Activity

  1. github-actions commented on Feb 21, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • The issue does not use one of the required issue templates (Bug Report, Feature Request, or Question). Please re-submit using the Bug Report template, which requires a Description field with reproduction context.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. added
    needs:compliance
    on Feb 21, 2026
  3. github-actions commented on Feb 21, 2026

    @github-actions
    Contributor

    This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

    Feel free to open a new issue that follows our issue templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

needs:compliance

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions