Skip to content

cli: opencode models prints empty list with exit 0 on a cold server #53724

Closed as duplicate

Description

@sanjusss

Summary

opencode models silently prints nothing (empty list, exit code 0) when run against a freshly spawned server. Model/provider lists load asynchronously, and the command queries before loading finishes, so it always reports zero models on a cold server.

Environment

  • opencode version: 2.0.24
  • OS: Linux x86_64, kernel 6.8.0-110-generic (Ubuntu)
  • Terminal: TERM=xterm-256color, TERM_PROGRAM=vscode, COLORTERM=truecolor
  • Shell: /bin/bash
  • Install/channel: npm global @opencode/cli via nvm-managed Node v25.3.0, channel=latest
  • Active plugins: none

Reproduction

  1. Disable the shared background service: opencode service set disabled true (or just use --standalone below)
  2. Run opencode models --standalone
  3. Observe: no output at all, exit code 0 (reproduced 3/3 times)
  4. Contrast: start opencode serve --port <port>, wait ~2 minutes, then run opencode models --server http://localhost:<port> — the full model list prints instantly
  5. On the fresh server, GET /api/model returns {"data":[]} right after boot and the complete list a couple of minutes later; /api/provider likewise shows only built-in integrations at first

Expected Behavior

opencode models waits for the initial provider/model load (bounded by a timeout), or prints a warning when the resulting list is empty, instead of silently succeeding with no output.

Actual Behavior

Prints nothing and exits 0. Looks like "no models configured" even though the config is valid.

Additional Context

Config defines one custom provider (redacted):

{
  "model": "<provider>/<model>",
  "provider": {
    "<provider>": {
      "npm": "@ai-sdk/openai-compatible",
      "options": { "apiKey": "<redacted>", "baseURL": "https://<private-proxy>/v1" },
      "models": { /* ~20 manually declared models with limits */ }
    }
  }
}

~/.config/opencode/service.json contains {"disabled": true}, so every CLI invocation spawns a private stdio server and hits the cold-start path. The TUI in the same directory works fine because it stays connected and models finish loading in the background. Slow model-list fetching (network latency) makes the race essentially deterministic here.

Activity

  1. github-actions commented on Oct 7, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. opencode-agent commented on Oct 7, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report. I can reproduce this on v2.0.24 on Linux with no plugins and a custom @ai-sdk/openai-compatible provider declared in config:

    1. opencode2 models --standalone prints nothing and exits 0 every time.
    2. Against a freshly started opencode2 serve, GET /api/model returns {"data":[]} right after boot, and opencode2 models --server … likewise prints nothing with exit 0.
    3. A few seconds later both return the full list, custom models included.

    In my environment the catalog finished loading in about 6 seconds rather than ~2 minutes, likely because of network differences, but it's the same race: the command reads the model list once, before the initial load has finished, and treats an empty result as success. The server-side part (catalog endpoints not waiting for readiness) is also tracked in #36117.

  3. neriousy commented on Oct 20, 2026

    @neriousy
    Member

    Thanks for the report. We're tracking cold-start model and provider reads returning incomplete catalogs in #36117, so I'm closing this as a duplicate. Please follow that issue for updates.

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