anomalyco / anomalyco/opencode
tui (v2): config default model ignored, falls back to first provider's model
@kommander is already working on this.
Since Aug 17, 2026.
- 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
- Set
"model": "custom-provider/my-default-model"in~/.config/opencode/opencode.jsonc(any custom provider + model). - Have the
github-copilotprovider registered (gh CLI authenticated,~/.config/ghpresent) so it appears early in the provider list. - Run
opencode2(TUI). - Build agent's initial model shows the github-copilot model instead of the configured
custom-provider/my-default-model. - 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
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.