anomalyco / anomalyco/opencode

agents: configured model variant ignored, session falls back to saved preference

Open
#47,071 1 comment 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Sep 3, 2026.

2.0
Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

Agent-configured model variant is silently ignored: build is configured
with variant low, but a fresh opencode2 session starts with medium.

Environment

  • opencode version: v0.0.0-beta-18999 (opencode2 --version)
  • OS: Linux 7.0.0-30-generic (linux x64)
  • Terminal: TERM=xterm-256color, COLORTERM=truecolor
  • Shell: /bin/bash
  • Install/channel: beta
  • Active plugins: none configured in ~/.config/opencode/opencode.jsonc

Reproduction

  1. Configure the agent with a valid catalog variant:
    "agents": {
      "build": { "model": "xai/grok-4.6", "variant": "low" },
    }
    
    (low is valid: /api/model lists xai/grok-4.6 variants as
    low, medium, high, xhigh.)
  2. Confirm the agent record picked it up:
    $ opencode2 api get /api/agent | python3 -c "
    import json,sys
    for a in json.load(sys.stdin)['data']:
      if a['id']=='build': print(json.dumps(a['model']))"
    {"id": "grok-4.6", "providerID": "xai", "variant": "low"}
    
  3. Start opencode2. The footer shows:
    Build · Grok 4.6 xAI · medium

Expected Behavior

Session uses the agent-configured variant low.

Actual Behavior

Session uses medium — the stale value from
~/.local/state/opencode/model.json ("xai/grok-4.6":"medium").
TUI variant resolution (packages/opencode/src/cli/cmd/run/variant.shared.ts
resolveVariant: CLI flag → saved preference → session history) never
consults the agent config, and session prompt creation
(packages/opencode/src/session/prompt.ts createUserMessage) only reads a
top-level agent.variant, while the agent record carries the variant nested
under model. Either syntax (provider/model#variant or "variant" field)
ends up ignored.

Additional Context

  • Explicit session variant works fine (POST /api/session/{id}/model with a
    variant sticks), so only the agent → session handoff drops it.
  • Reproducible consistently.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.