anomalyco / anomalyco/opencode

[BUG]:`opencode run` returns {UnknownError} when the configured default model is deprecated

Open
#46,760 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

opencode run returns an opaque server error when the configured default model becomes deprecated.

OpenCode documentation directs users to models.dev for built-in provider and model IDs. I selected x-preview-f-free from the OpenCode Zen provider page and configured it using the documented provider_id/model_id format:

"model": "opencode/x-preview-f-free"

This model worked previously. It is still displayed on the models.dev OpenCode Zen provider page with no visible deprecation warning, but its current API entry contains:

"status": "deprecated"

After the model became deprecated, opencode run began failing with:

Error: {
  "name": "UnknownError",
  "data": {
    "message": "Unexpected server error. Check server logs for details.",
    "ref": "err_1024fb4c"
  }
}

Expected behavior

OpenCode should validate the configured model against the refreshed catalog before creating the session.

If the model is deprecated or unavailable, the CLI should return a specific error such as:

Configured model opencode/x-preview-f-free is deprecated or unavailable. Select another model with opencode models.

It should not return an internal HTTP 500 or direct CLI users to unspecified server logs.

OpenCode should not silently select another model because that could unexpectedly use a paid model.

The models.dev OpenCode Zen provider page also displays this model without showing its deprecated status. Because OpenCode documentation directs users to models.dev for model IDs, provider pages should clearly label deprecated models. I placed the resulting model ID in ~/.config/opencode/opencode.jsonc.

Environment

Related issues

  • #33766
  • #45395
  • anomalyco/models.dev#3850
Plugins

Local oc-supermemory-redux (.js bundle), local WakaTime (.js bundle)

OpenCode version

1.18.25

Steps to reproduce

Reproduction

Add the following to ~/.config/opencode/opencode.jsonc:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "opencode/x-preview-f-free"    \\or any deprecated model
}

Then run:

opencode models --refresh
opencode run "test"
CLI impact

I normally call opencode run through this Fish function:

function ? --wraps='opencode run' --description 'alias ?=opencode run'
    opencode run $argv
end

A previously working command such as this now fails:

? 'test'

The wrapper is not the cause. It directly passes its string arguments to opencode run. properly encapsulated in single quotations for fish shell compatibility.

This also affects scripts and other noninteractive uses of the CLI because the error does not identify the configured model as the problem.

Screenshot and/or share link

https://opncd.ai/share/fgqcdZ1l

Operating System

Garuda Linux x86_64 (Arch-based)

Terminal

Yakuake 26.08.0 with Fish 4.8.1

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.

Research direction

Start by tracing the opencode run entry point and its handling of the configured model after opencode models --refresh. Reproduce with opencode/x-preview-f-free and inspect how the session responds to a deprecated model. Done means the CLI identifies the configured model as deprecated or unavailable without returning an opaque server error or silently selecting another model.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ai, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.