Skip to content

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

Closed as not planned

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

  1. github-actions commented on Feb 15, 2026

    @github-actions
    Contributor

    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:

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

  2. dhruvkej9 commented on Feb 15, 2026

    @dhruvkej9
    Author

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

  3. demian85 commented on Feb 25, 2026

    @demian85

    Variants are not respected in both TUI and desktop, even though they are configured in opencode.json:

      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "openai": {
          "models": {
            "gpt-5.3-codex": {
              "variants": {
                "low": {
                  "reasoningEffort": "low",
                  "reasoningSummary": "auto",
                  "textVerbosity": "medium",
                  "disabled": false
                },
                "medium": {
                  "reasoningEffort": "medium",
                  "reasoningSummary": "auto",
                  "textVerbosity": "medium",
                  "disabled": false
                },
                "high": {
                  "reasoningEffort": "high",
                  "reasoningSummary": "auto",
                  "textVerbosity": "medium",
                  "disabled": false
                }
              }
            }
          }
        }
      },
      "agent": {
        "build": {
          "model": "openai/gpt-5.3-codex",
          "variant": "medium"
        },
        "plan": {
          "model": "openai/gpt-5.3-codex",
          "variant": "high"
        }
      }
    }
    

    When changing agents, the default variant is not used.

  4. github-actions commented on Apr 27, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  5. dhruvkej9 commented on Apr 27, 2026

    @dhruvkej9
    Author

    @rekram1-node
    The issue is clear and shouldn't be closed without any feedback as this is a bug issue not a feature so it can't be closed as "not planned"

  6. tarurar commented on Apr 28, 2026

    @tarurar

    Completely agree. There is related one #16034

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