opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Add default variant config per agent

Open opencode-agent[bot] opened this issue 1 week ago • 5 comments

All changes are in place. Let me create a summary of the implementation:

Summary

I've implemented the default variant configuration per agent feature as specified in the issue. Here are the changes made:

Files Modified

  1. packages/opencode/src/config/config.ts (lines 481, 497):

    • Added variant field to Config.Agent schema with description
    • Added variant to knownKeys set for proper parsing
  2. packages/opencode/src/agent/agent.ts (lines 37, 194):

    • Added variant field to Agent.Info type
    • Added parsing logic to read variant from config during agent state initialization
  3. packages/opencode/src/session/llm.ts (lines 86-87):

    • Updated variant resolution to use input.user.variant ?? input.agent.variant as the variant key
    • This implements the priority order: explicit user selection > agent's configured default > none
  4. packages/opencode/src/tool/task.ts (line 135):

    • Pass agent.variant to subagent sessions so they use their own configured variant

Usage

Users can now configure a default variant for each agent:

{
  "agent": {
    "build": {
      "model": "anthropic/claude-sonnet-4-5-thinking",
      "variant": "high"
    },
    "explore": {
      "model": "google/gemini-3-flash",
      "variant": "low"
    }
  }
}

Variant Priority Order

  1. Explicit user selection (--variant flag or ctrl+t)
  2. Agent's configured default variant (agent.variant)
  3. None (model's base behavior)

Subagent Behavior

Subagents now use their own configured agent.variant rather than inheriting the parent's --variant override, respecting explicit per-agent configuration.

Closes #7138

New%20session%20-%202026-01-06T23%3A49%3A15.558Z opencode session  |  github run

opencode-agent[bot] avatar Jan 06 '26 23:01 opencode-agent[bot]