feat(agent): implement model tier selection with variant support for subagents #11377
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Closes #6651
The issue is that subagents called via Task tool can't dynamically select models based on task complexity. Users end up creating duplicate agents (
explore-quick,explore-standard, etc.) just to vary models, or waste money using powerful models for simple tasks.I implemented the unified approach (Solution C) from the issue: added
model_tierparameter to Task tool withquick/standard/advancedvalues. You can configure tier-to-model mappings globally or per-agent, with agent-level overriding global when defined.Resolution hierarchy:
I also added optional
variantsupport to tier configurations (as noted in a later comment on the issue), allowing models to use different reasoning modes.See #6651 for detailed implementation discussion and configuration examples.
How did you verify your code works?
Tests: Added comprehensive tests covering model tier resolution and variant extraction - 720 total pass, with 12 new tests for the feature (agent tier priority, global tier fallback, variant parsing, and resolution hierarchy).
Manual testing: Have been using this setup locally for about 2 weeks for development work. Configured
opencode.jsonwithmodel_tiersfor build and plan agents with different variants. Called Task with differentmodel_tiervalues daily and verified correct models were used. Confirmed agent tiers override global tiers as expected.