anomalyco / anomalyco/opencode

tui (v2): config default model ignored, falls back to first provider's model

Open
#43,055 0 comments 0 reactions 1 assignee View on GitHub

@kommander is already working on this.

Since Aug 17, 2026.

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

Description

Description

Bug in OpenCode v2 (opencode2), the beta build. The TUI ignores the
config-level default model and falls back to the first provider's model when
initializing the build agent. The displayed model is then sent with
session.create / session.prompt, so new sessions actually run on the wrong
model.

Repro: config sets "model": "custom-provider/my-default-model", but the TUI
shows and uses a model from a different provider that happens to be first in
the provider list (e.g. github-copilot/gemini-3.7-flash).

Root cause (client-side): sync.data.config is the raw array returned by
/api/config (an array of config sources), so sync.data.config.model is
always undefined and the if (sync.data.config.model) check in
packages/tui/src/context/local.tsx never matches. The fallback then picks
provider[0]'s default model.

TUI vs API code gap: the server/API path resolves the configured default
correctly — packages/core/src/session/runner/model.ts uses
catalog.model.default() when a session has no model, and GET /api/model/default
returns the configured model. The TUI client has no equivalent: it never
flattens the /api/config source array into a config object, so the
config-level model is invisible to the client-side default-model selection.
The server-side /api/model/default and the TUI's sync.data.config.model
therefore disagree.

Plugins

None

OpenCode version

opencode2 v0.0.0-beta-17519 (v2 beta)

Steps to reproduce
  1. Set "model": "custom-provider/my-default-model" in ~/.config/opencode/opencode.jsonc (any custom provider + model).
  2. Have the github-copilot provider registered (gh CLI authenticated, ~/.config/gh present) so it appears early in the provider list.
  3. Run opencode2 (TUI).
  4. Build agent's initial model shows the github-copilot model instead of the configured custom-provider/my-default-model.
  5. Send a prompt — the session runs on the github-copilot model (passed via session.prompt).
Screenshot and/or share link

N/A

Operating System

Ubuntu 24.04 (Linux 5.15.0-91-generic x86_64)

Terminal

tmux (TERM=xterm-256color)

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.