opencode
opencode copied to clipboard
Add default variant config per agent
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
-
packages/opencode/src/config/config.ts(lines 481, 497):- Added
variantfield toConfig.Agentschema with description - Added
varianttoknownKeysset for proper parsing
- Added
-
packages/opencode/src/agent/agent.ts(lines 37, 194):- Added
variantfield toAgent.Infotype - Added parsing logic to read
variantfrom config during agent state initialization
- Added
-
packages/opencode/src/session/llm.ts(lines 86-87):- Updated variant resolution to use
input.user.variant ?? input.agent.variantas the variant key - This implements the priority order: explicit user selection > agent's configured default > none
- Updated variant resolution to use
-
packages/opencode/src/tool/task.ts(line 135):- Pass
agent.variantto subagent sessions so they use their own configured variant
- Pass
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
- Explicit user selection (
--variantflag orctrl+t) - Agent's configured default variant (
agent.variant) - 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
opencode session | github run