Skip to content

run -m with an unqualified model id fails after session start with "Unexpected server error" #46991

Closed as not planned

Description

@chernistry

What happens

opencode run -m <model-id> with an id that carries no provider/ prefix creates a session and then fails on the first turn with:

UnknownError: Unexpected server error

Nothing is written to the server log, --print-logs adds nothing, and the exit status is the same one a genuine provider error produces. The same invocation with -m <provider>/<model-id> works.

Why this is hard to diagnose

The failure happens after session creation, so it does not read as an argument problem. In a headless run driving several agents, the visible symptom is that the top-level process works and every child dies with an opaque error, which sends you looking at the provider, the model, or concurrency rather than at the flag.

There is a second path into it that is easy to hit: a config file can carry a model id per role. If the top-level -m is qualified but a role's id is bare, the run starts, the first agent answers, and every subsequent agent dies. Nothing in the output distinguishes that from a provider outage.

Reproduce

  1. Configure any OpenAI-compatible provider in opencode.jsonc, for example a provider named acme with one model my-model.
  2. opencode run -m my-model --format json 'say ok' → session is created, then UnknownError: Unexpected server error.
  3. opencode run -m acme/my-model --format json 'say ok' → works.

Version: 1.18.27, headless, Linux container.

Suggested fix

Resolve -m before the session is created and fail with a message naming the problem, e.g. model id "my-model" is not qualified; use "<provider>/my-model" and list the configured providers. Resolving an unqualified id against a single configured provider would also be reasonable, but the explicit error is the part that matters — the current behaviour spends a whole run to say nothing.

Activity

  1. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions