anomalyco / anomalyco/opencode
agents: configured model variant ignored, session falls back to saved preference
@jlongster is already working on this.
Since Sep 3, 2026.
- 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
- Configure the agent with a valid catalog variant:
("agents": { "build": { "model": "xai/grok-4.6", "variant": "low" }, }lowis valid:/api/modellistsxai/grok-4.6variants as
low, medium, high, xhigh.) - 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"} - 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}/modelwith a
variant sticks), so only the agent → session handoff drops it. - Reproducible consistently.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.