Skip to content

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

Description

@dhruvkej9

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwindows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions