anomalyco / anomalyco/opencode
run -m with an unqualified model id fails after session start with "Unexpected server error"
@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
- Configure any OpenAI-compatible provider in
opencode.jsonc, for example a provider namedacmewith one modelmy-model. opencode run -m my-model --format json 'say ok'→ session is created, thenUnknownError: Unexpected server error.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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.