Skip to content

Non deterministic behaviour of variants passed into agents in the opencode.json config #16034

Closed as not planned

Description

@OpeOginni

Description

Even when passing in variants to agents, these don not still get used, switching to another variant makes that the new default and ignores what has been set in the config.

I tested using this config

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {

  },
  "agent": {
    "build": {
      "model": "opencode/gpt-5.1-codex",
      "variant": "medium"
    },
    "plan": {
      "model": "opencode/gpt-5.3-codex",
      "variant": "high"
    }
  }
}

Video below

Plugins

None

OpenCode version

1.2.17

Steps to reproduce

  1. Use the config provided
  2. Try to update the variant of the build agent, and make request
  3. Cycle round back to the build agent, notice the last variant is used rather than what is set in the config, same thing happens if you close the TUI and open again.

Screenshot and/or share link

Screen.Recording.2026-03-04.at.19.01.00.mov

Operating System

macOS

Terminal

Ghostty

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 4, 2026
  2. github-actions commented on Mar 4, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  3. mmack commented on Mar 15, 2026

    @mmack

    Same problem here

  4. OpeOginni commented on Mar 15, 2026

    @OpeOginni
    ContributorAuthor

    @mmack got a PR that fixes it, hopefully it gets merged or reviewed!

  5. alexzoo commented on Mar 31, 2026

    @alexzoo

    Leaving this here as it seems to be the same root cause. A collaborator (@ReqX) from the oh-my-opencode-slim repo traced this through both codebases and confirmed it's an upstream OpenCode core bug — still happens with oh-my-opencode-slim fully deactivated (plan/build built-in agents only).

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


    Analysis by @ReqX

    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/switch variant in dialog → only local UI store is updated, ACP session still holds "medium".
    3. Switch mode (e.g. build → plan → build) — session variant is NOT cleared on mode switch.
    4. Next prompt sends stale variant to API.
    5. Response echoes msg.variant = "medium", and prompt/index.tsx:200 syncs that back into the local model store — undoing the clear.

    Why this can't be fixed at the plugin level:
    Plugin-level hooks only have access to agent.config.variant at startup. Runtime access to ACP session manager is not exposed, so any fix needs to happen in core.

    Suggested fix areas in core:

    • dialog-variant.tsx: when user selects "Default", propagate that to ACP session via setVariant() in acp/session.ts:103.
    • prompt/index.tsx:200: stop unconditionally syncing msg.variant from API response back into local model store.

    Original report + full analysis: alvinunreal/oh-my-opencode-slim#214

  6. assigned and unassigned on Apr 26, 2026
  7. tarurar commented on Apr 28, 2026

    @tarurar

    Same issue, I see there is an open pull request already: #18013.

  8. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  9. github-actions commented on Jul 5, 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.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions