opencode
opencode copied to clipboard
feat: add variant support for subagents (#7138) [alt of #7140]
What does this PR do?
Adds agent-level default variant configuration, allowing users to set reasoning effort (e.g., "low", "medium", "high") per agent. This is an alternative to #7140 with broader scope: full desktop/web support, dynamic Task tool overrides, and TUI CLI parity.
Why this matters: Orchestrator agents can now spawn subagents with different model/variant combinations dynamically — no need to duplicate agent configs for each reasoning level.
Changes
Core backend
-
variantfield in agent config schema - Resolution order: user input > agent config
- Resolved variant stored in message metadata (not
undefinedwhen using agent default) - Subagents use their own configured variant, not inherited from parent
Task tool dynamic override (addresses @terwey's feedback on #7140)
- Optional
modelandvariantparams added to Task tool schema - Priority: param override > agent config > parent context (model) / undefined (variant)
TUI
- Effective variant displayed in prompt bar and agent picker
- Added
--variantCLI flag for parity with headlessruncommand
Desktop/web app
- Effective variant displayed in prompt bar and agent selector
SDK
- Updated
types.gen.tsandopenapi.json
Comparison with #7140
| Feature | #7140 | This PR |
|---|---|---|
| Core backend | Yes | Yes |
| TUI display | Yes | Yes |
| Desktop/web app | No | Yes |
| Message metadata | undefined when agent default used |
Resolved variant stored |
| Task tool model/variant override | No | Yes |
TUI --variant CLI flag |
No | Yes |
| Files changed | 9 | 18 |
Example usage
Agent config:
# .opencode/agent/oracle.md
---
model: anthropic/claude-sonnet-4
variant: "high"
---
Task tool override:
{
"description": "Refactor auth module",
"prompt": "Refactor the auth module to use OAuth2",
"subagent_type": "implementer",
"model": "anthropic/claude-sonnet-4-20250514",
"variant": "low"
}
TUI CLI:
opencode --variant high
Closes #7138