anomalyco / anomalyco/opencode

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

Open
#46,991 0 comments 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Sep 3, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.