Skip to content

Bug: Model variant is not preserved after being cleared — resets to previous value on mode switch #214

Closed as not planned

Description

@alexzoo

Description

When a model variant is explicitly cleared (set to none/default), it keeps coming back after switching modes or switching to another model and back.

Steps to Reproduce

  1. Select a model (e.g. gpt-5.4).
  2. Set variant to medium.
  3. Explicitly clear the variant (set to none / no variant).
  4. Switch to another mode (e.g. from build to plan) or switch model and back.

Expected Behavior

Variant stays cleared — since the user explicitly removed it, it should not be auto-reapplied.

Actual Behavior

Variant medium is automatically re-selected for gpt-5.4 after switching. The user has to manually clear it every time.

Environment

  • oh-my-opencode-slim: latest version

Notes

This makes working with models that have variants very frustrating as it requires constant manual corrections. Looks like the last-used variant is "remembered" and re-applied even after an explicit user clear.

Activity

  1. ReqX commented on Mar 31, 2026

    @ReqX
    Collaborator

    Hey, I traced this through both codebases, to me it's an upstream OpenCode core bug, not something omo-slim can work around. I actually confirmed it still happens with omo-slim deactivated (plan/build build-in agents).

    TL;DR: Two independent variant stores (UI vs API session) get out of sync. Clearing the variant in the UI only updates the UI side, so the API session keeps sending the old one. The next response overwrites your cleared variant right back — ghost variant.


    Analysis 🐇

    Two stores, one source of truth problem:

    Store Where Controls
    TUI local model store ~/.opencode/model.json Dialog display
    ACP session state session.variant (in-memory) Actual API calls

    The flow:

    1. Set variant to medium → both stores updated ✓
    2. Clear it in the dialog → local store updated, ACP session still holds "medium"
    3. Switch mode → setSessionMode() doesn't touch variant
    4. Next prompt → stale "medium" goes to the API
    5. Response echoes msg.variant = "medium" → prompt/index.tsx:200 syncs it back to the UI, undoing the clear

    Smoking gun:

    // cli/cmd/tui/component/prompt/index.tsx:200
    if (msg.variant) local.model.variant.set(msg.variant)

    Why omo-slim can't fix this: Variant handling there is config-time only (sets agent.config.variant at startup). Runtime hooks have no access to the ACP session manager. Suppressing it in message transforms would strip it from the API call too — wrong behavior.

    Quick way to verify: Disable omo-slim entirely and reproduce — the bug persists, confirming it's upstream.

    Fix in OpenCode core:

    1. dialog-variant.tsx — on "Default" selection, propagate the clear to the ACP session (setVariant() at acp/session.ts:103 exists but is never called from the TUI clear path)
    2. prompt/index.tsx:200 — stop blindly overwriting the local variant from the response

    Note: High confidence on the desync mechanism, but worth noting the "mode switch" trigger could also partly be per-session variant persistence if that mode was previously used with the same model+variant. Needs proper reproduction to confirm the exact trigger path.

  2. alexzoo commented on Mar 31, 2026

    @alexzoo
    Author

    Thanks for the investigation, I've passed it on to the OpenCode team

  3. mhenke commented on Jul 9, 2026

    @mhenke
    Collaborator

    This was generated by AI during triage.

    Triage Result: upstream OpenCode bug (not fixable in this plugin)

    Thanks for the report (and to ReqX for the thorough trace). This is an OpenCode core bug, not something oh-my-opencode-slim can fix:

    • The root cause is a desync between two variant stores: the TUI's local model store (~/.opencode/model.json) and the ACP session state (session.variant). Clearing the variant in the UI updates only the local store; the ACP session keeps the old value, and the next response re-syncs the stale variant back into the UI — the "ghost variant."
    • oh-my-opencode-slim only sets a variant at config time (when building agent configs / applying presets). It has no runtime access to the ACP session manager, so it cannot propagate a UI clear to the session or suppress the re-sync without also stripping the variant from the actual API call (wrong behavior).
    • ReqX confirmed the bug reproduces with oh-my-opencode-slim deactivated, and you've already forwarded it to the OpenCode team.

    Because the fix belongs in OpenCode core (propagate the clear to the ACP session on "Default" selection, and stop blindly overwriting the local variant from the response), we're closing this as outside our scope. We'll revisit if OpenCode ships a hook/API that lets a plugin participate in variant state.

    If you'd like, you can link the upstream OpenCode issue here so others can track it.

  4. added
    bugSomething isn't working
    wontfixThis will not be worked on
    on Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwontfixThis will not be worked on

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions