Skip to content

BUG: exit code when an invalid model is passed #15558

Closed as not planned
Closed as not planned

Description

@grigio

Description

Following and example of the bug, and the reasoning of the AI model as it replied

$ opencode run --model "invalid-model-123" "test" 2>/dev/null ; echo "EXIT: $?"
EXIT: 0
Thinking: So opencode is returning exit code 0 even when it prints an error message! This is a bug in opencode itself (it prints errors to stderr but exits with 0). 
The fix for the harness should be to check if stderr has error content, not just exit code. Let me modify the runner to check stderr for error patterns:
The issue is that opencode returns exit code 0 even when it prints an error message. I need to modify runner.ts to check stderr for errors, not just exit code.

Plugins

none

OpenCode version

1.2.15

Steps to reproduce

$ opencode run --model "invalid-model-123" "test" 2>/dev/null ; echo "EXIT: $?"

Screenshot and/or share link

No response

Operating System

Linux / Archlinux

Terminal

zsh

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 1, 2026
  2. github-actions commented on Mar 1, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • The description contains what appears to be AI-generated internal reasoning/thinking text ("Thinking: So opencode is returning exit code 0...", "The fix for the harness should be...", "I need to modify runner.ts..."). Please replace this with a clear, human-written description of the bug.
    • Required fields are empty: OpenCode version, Steps to reproduce, Operating System, and Terminal — these help us reproduce and fix the bug.

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


    This issue might be related to an existing issue. Please check:

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

  3. github-actions commented on Mar 1, 2026

    @github-actions
    Contributor

    Thanks for updating the issue with your system info — that helps a lot.

    However, the Description field still contains AI-generated internal reasoning text that was not removed:

    Thinking: So opencode is returning exit code 0 even when it prints an error message! This is a bug in opencode itself...
    The fix for the harness should be to check if stderr has error content...
    I need to modify runner.ts to check stderr for errors...
    

    Please edit the Description to remove that text and replace it with a plain description of the bug in your own words — something like: "When passing an invalid model via --model, opencode prints an error to stderr but still exits with code 0 instead of a non-zero exit code."

    The needs:compliance label will remain until this is addressed.

  4. github-actions commented on Mar 1, 2026

    @github-actions
    Contributor

    Thanks for updating the issue! It now meets our contributing guidelines — the bug description, steps to reproduce, and system information are all present and clear. We appreciate you taking the time to improve it.

  5. added a commit that references this issue on Mar 3, 2026
    3406515
  6. github-actions commented on May 1, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions