Build variant in config gets ignored by TUI due persisted per-model variant state #9389

Open
opened 2026-02-16 18:12:20 -05:00 by yindo · 2 comments
Owner

Originally created by @dhruvkej9 on GitHub (Feb 15, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

Hey team, I found a variant precedence issue that is pretty confusing in day-to-day usage.

I set agent.build.variant in ~/.config/opencode/opencode.json to medium, but when I start opencode in TUI it still opens with high for openai/gpt-5.3-codex.

This happens because TUI restores variant from persisted state (~/.local/state/opencode/model.json) and submits that explicit variant, so config fallback never gets used.

I can reproduce this reliably and also confirmed by checking stored message data in opencode.db.

Expected behavior (for a new session):

  • If no CLI --variant is passed, config agent.build.variant should be respected.
  • Persisted UI variant should not silently override config unless there is an explicit “remember last variant” mode.

Actual behavior:

  • Persisted per-model variant wins (ex: high) even when config says medium.
  • opencode -s <session> also restores last message variant and keeps forcing that value.

This makes config changes feel broken because they don’t take effect in fresh TUI usage.

Plugins

opencode-antigravity-auth@latest, @mohak34/opencode-notifier@latest

OpenCode version

1.2.4

Steps to reproduce

  1. Set agent.build.variant to medium in ~/.config/opencode/opencode.json
  2. Ensure ~/.local/state/opencode/model.json has variant["openai/gpt-5.3-codex"] = "high"
  3. Start TUI with opencode
  4. Observe header shows Build ... high
  5. Send a prompt and inspect opencode.db message data: variant is stored as high

Also with session resume:
6. Run opencode -s <existing-session-id> where last message variant was high
7. Observe resumed session keeps high even after config changed to medium

Relevant code paths:

  • packages/opencode/src/cli/cmd/tui/context/local.tsx (loads/saves model.json variant map)
  • packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx (submits explicit variant)
  • packages/opencode/src/session/prompt.ts (uses input.variant first, config variant only as fallback)

Screenshot and/or share link

No share link; validated with runtime behavior + DB inspection (opencode.db) and source reading.

Operating System

WSL2 (Ubuntu 24.04)

Terminal

Windows Terminal

Originally created by @dhruvkej9 on GitHub (Feb 15, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description Hey team, I found a variant precedence issue that is pretty confusing in day-to-day usage. I set `agent.build.variant` in `~/.config/opencode/opencode.json` to `medium`, but when I start `opencode` in TUI it still opens with `high` for `openai/gpt-5.3-codex`. This happens because TUI restores variant from persisted state (`~/.local/state/opencode/model.json`) and submits that explicit variant, so config fallback never gets used. I can reproduce this reliably and also confirmed by checking stored message data in `opencode.db`. Expected behavior (for a new session): - If no CLI `--variant` is passed, config `agent.build.variant` should be respected. - Persisted UI variant should not silently override config unless there is an explicit “remember last variant” mode. Actual behavior: - Persisted per-model variant wins (ex: `high`) even when config says `medium`. - `opencode -s <session>` also restores last message variant and keeps forcing that value. This makes config changes feel broken because they don’t take effect in fresh TUI usage. ### Plugins opencode-antigravity-auth@latest, @mohak34/opencode-notifier@latest ### OpenCode version 1.2.4 ### Steps to reproduce 1. Set `agent.build.variant` to `medium` in `~/.config/opencode/opencode.json` 2. Ensure `~/.local/state/opencode/model.json` has `variant["openai/gpt-5.3-codex"] = "high"` 3. Start TUI with `opencode` 4. Observe header shows `Build ... high` 5. Send a prompt and inspect `opencode.db` message data: variant is stored as `high` Also with session resume: 6. Run `opencode -s <existing-session-id>` where last message variant was `high` 7. Observe resumed session keeps `high` even after config changed to `medium` Relevant code paths: - `packages/opencode/src/cli/cmd/tui/context/local.tsx` (loads/saves model.json variant map) - `packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx` (submits explicit variant) - `packages/opencode/src/session/prompt.ts` (uses input.variant first, config variant only as fallback) ### Screenshot and/or share link No share link; validated with runtime behavior + DB inspection (`opencode.db`) and source reading. ### Operating System WSL2 (Ubuntu 24.04) ### Terminal Windows Terminal
yindo added the windowsbug labels 2026-02-16 18:12:20 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 15, 2026):

This issue might be a duplicate of or related to #13456: TUI model selection gets overwritten by agent default model.

Both issues involve state persisted in ~/.local/state/opencode/model.json inappropriately overriding configuration settings:

  • #13456 focuses on model selection being overwritten by agent defaults
  • #13718 focuses on build variant being overwritten by persisted per-model state

While they affect different aspects (model vs variant), they likely share the same root cause regarding state precedence and could potentially be fixed together.

@github-actions[bot] commented on GitHub (Feb 15, 2026): This issue might be a duplicate of or related to #13456: **TUI model selection gets overwritten by agent default model**. Both issues involve state persisted in `~/.local/state/opencode/model.json` inappropriately overriding configuration settings: - #13456 focuses on model selection being overwritten by agent defaults - #13718 focuses on build variant being overwritten by persisted per-model state While they affect different aspects (model vs variant), they likely share the same root cause regarding state precedence and could potentially be fixed together.
Author
Owner

@dhruvkej9 commented on GitHub (Feb 15, 2026):

@rekram1-node Can you check this? It is on the latest version, I just tried many times and it is 100% reproducible

@dhruvkej9 commented on GitHub (Feb 15, 2026): @rekram1-node Can you check this? It is on the latest version, I just tried many times and it is 100% reproducible
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9389