GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(agent): implement model tier selection with variant support for subagents by mcking-07 · Pull Request #11377 · anomalyco/opencode

Conversation

@mcking-07

@mcking-07 mcking-07 commented Jan 30, 2026

Copy link
Copy Markdown

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_tier parameter to Task tool with quick/standard/advanced values. You can configure tier-to-model mappings globally or per-agent, with agent-level overriding global when defined.

Resolution hierarchy:

  1. Agent's explicit model (if set, tier ignored)
  2. Agent-level model_tiers[tier] - if defined
  3. Global model_tiers[tier] - if defined
  4. Parent session model (fallback)

I also added optional variant support 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.json with model_tiers for build and plan agents with different variants. Called Task with different model_tier values daily and verified correct models were used. Confirmed agent tiers override global tiers as expected.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

TTTPOB and beefsack reacted with thumbs up emoji noname-oni, dreanzy, TimShilov, EmilioEsposito, noamk-hl, and beefsack reacted with rocket emoji
All reactions
  • 👍 2 reactions
  • 🚀 6 reactions
Mohammed Muzammil Anwar added 2 commits January 31, 2026 03:22
Mohammed Muzammil Anwar
feat(agent): implement model tier selection for agents and enhance co…
95fd6ea
…nfiguration parsing.
Mohammed Muzammil Anwar
chore(sdk): regenerate types and update schema.
3fdff64
@github-actions

github-actions Bot commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potentially Related PRs Found:

  1. Add default variant config per agent (Add default variant config per agent #7140)

    • Add default variant config per agent #7140
    • Relation: Addresses variant configuration for agents, which is related to the variant support being added in this PR.
  2. feat: add variant support for subagents (feat: add agent default variant handling in TUI and desktop #7156)

    • feat: add agent default variant handling in TUI and desktop #7156
    • Relation: Previous work on variant support for subagents; this PR builds upon variant functionality.
  3. feat: add variant support for commands (feat: add variant support for commands (#7713) #7907)

    • feat: add variant support for commands (#7713) #7907
    • Relation: Related variant support implementation for commands; may have similar patterns to consider.
  4. feat(task): Add subagent-to-subagent delegation with budgets, persistent sessions, and hierarchical session navigation (feat(task): Add subagent-to-subagent delegation with budgets, persistent sessions, and hierarchical session navigation #7756)

    • feat(task): Add subagent-to-subagent delegation with budgets, persistent sessions, and hierarchical session navigation #7756
    • Relation: Earlier work on task delegation and subagent handling; may interact with the model tier selection feature.

These are historical variants/subagent work rather than current duplicates. The current PR (11377) appears to be the primary implementation for model tier selection.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcking-07 mcking-07 mentioned this pull request Jan 30, 2026
[FEATURE]: Dynamic model selection for subagents via Task tool #6651
Closed
1 task done
@github-actions github-actions Bot mentioned this pull request Feb 6, 2026
feat(core): Set variant in assistant messages too #12531
Merged
@mugnimaestra mugnimaestra mentioned this pull request Feb 7, 2026
feat(task): pass variant to subagent so it inherits parent's thinking level #12567
Closed
@Steffen025 Steffen025 mentioned this pull request Feb 10, 2026
feat: True Multi-Provider Agent System with Model Tiers Steffen025/pai-opencode#19
Closed
7 tasks
@RicardoMonteiroSimoes

RicardoMonteiroSimoes commented Feb 17, 2026

Copy link
Copy Markdown

If I understand this correctly, it just allows us to define levels for the same model, and allow references of it in agent definitions, right?
Something like a hierarchical selection of (depending on whats available) models isn't possible, as a simple example:

models: [opus, sonnet, gpt-5.3]

Which would enable per project provider locks but still allow transferability of agents across projects?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@albahrani albahrani mentioned this pull request Feb 24, 2026
feat: add model parameter to Task tool for dynamic subagent model selection #14961
Closed
3 of 6 tasks
@github-actions github-actions Bot mentioned this pull request Mar 5, 2026
fix(app): improve agent selection logic passing in configured models and variants correctly #16072
Merged
4 of 6 tasks
@mcking-07

mcking-07 commented Mar 12, 2026

Copy link
Copy Markdown
Author

Hey @RicardoMonteiroSimoes, sorry, missed this! This PR implements tier-based model selection, not fallback chains. Here's the distinction:

What this PR does:

  • Define 3 tiers (quick, standard, advanced) mapped to specific models in config
  • Agents use model_tier parameter to select appropriate capability/cost level
  • Agent-level tiers override global tiers for customization
"model_tiers": {
  "quick": { "model": "anthropic/claude-haiku-4-5" },
  "standard": { "model": "anthropic/claude-sonnet-4-5" },
  "advanced": { "model": "anthropic/claude-opus-4-5" }
}

What you're describing (fallback chains):

"models": ["opus", "sonnet", "gpt-5.3"]

This would try models in order if earlier ones fail/unavailable.

Why tiers vs fallback chains:

Tiers solve a different problem - cost optimization through capability matching. A file search uses quick (Haiku), architecture review uses advanced (Opus). Same agent, different task complexity = different model.

Your fallback chain idea is valuable for provider redundancy! It's just out of scope for this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Mohammed Muzammil Anwar added 2 commits March 13, 2026 02:54
Mohammed Muzammil Anwar
Merge branch 'dev' of https://github.com/anomalyco/opencode into feat…
8ccdd76
…ure/subagent-model-and-variant-selection-via-model-tiers
Mohammed Muzammil Anwar
refactor: update model reference types to use schema definitions, and…
d9e0890
… enhance task tool descriptions.
Copilot AI review requested due to automatic review settings March 13, 2026 00:49
Copilot started reviewing on behalf of mcking-07 March 13, 2026 00:49
View session
Copilot AI reviewed Mar 13, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds model tier selection to subagents spawned via the Task tool, allowing callers to choose between quick / standard / advanced tiers (with optional variant) and resolves the final model via a defined precedence order (agent explicit model → agent tier → global tier → parent session/default).

Changes:

  • Add model_tier parameter to the Task tool and resolve the effective model via a new Agent.resolveModel(...) helper.
  • Introduce model_tiers config at both global and per-agent levels, including optional variant per tier.
  • Update SDK schemas/types and add unit tests covering parsing and resolution behavior.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/sdk/openapi.json Adds model_tiers to config + modelTiers to agent schema in the public OpenAPI spec.
packages/sdk/js/src/v2/gen/types.gen.ts Updates generated JS SDK types for the new config/agent tier fields.
packages/opencode/test/tool/task.test.ts Adds parameter-schema tests for model_tier validation on Task tool.
packages/opencode/test/config/config.test.ts Adds config parsing tests + Provider.parseTierConfig tests (variant extraction).
packages/opencode/test/agent/agent.test.ts Adds tests for model tier resolution hierarchy and variant precedence.
packages/opencode/src/tool/task.txt Documents model_tier usage for the Task tool.
packages/opencode/src/tool/task.ts Implements model tier plumbing in Task execution (calls Agent.resolveModel).
packages/opencode/src/provider/provider.ts Adds tier parsing types/helpers (ModelTier, ModelTierConfig, parseTierConfig).
packages/opencode/src/config/config.ts Adds model_tiers to config schema (global + per-agent).
packages/opencode/src/agent/agent.ts Parses per-agent tier config into modelTiers and adds resolveModel(...).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/opencode/src/tool/task.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/src/tool/task.txt Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/src/config/config.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/src/config/config.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/src/agent/agent.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Mohammed Muzammil Anwar added 2 commits March 13, 2026 11:17
Mohammed Muzammil Anwar
fix: update model tier definitions to use ModelId and enhance task ex…
4323b87
…amples.
Mohammed Muzammil Anwar
fix: update model tiers assignment to use inferred type.
3837efa
This was referenced Mar 15, 2026
feat: add assign-model feature for subagent model selection #17570
Closed
feat(opencode): add native dynamic subagent task support #18588
Closed
@mcking-07
resolve conflicts.
08c67a2
@opencode-agent
opencode-agent Bot force-pushed the dev branch from 2f2ed11 to 9f201d6 Compare April 16, 2026 21:55
This was referenced May 5, 2026
feat(task-tool): Add model parameter for subagent LLM routing #25881
Closed
feat(opencode): add model parameter to task tool for subagent model override #26535
Closed
@funkybooboo funkybooboo mentioned this pull request May 9, 2026
[FEATURE]: Runtime model override for task tool subagents #17595
Closed
1 task done
@github-actions github-actions Bot mentioned this pull request May 24, 2026
fix(opencode): preserve subagent model variants #29066
Closed
3 of 6 tasks
@github-actions github-actions Bot mentioned this pull request Jun 25, 2026
fix(tui): respect per-agent variant when TAB-cycling shared models #33960
Closed
@connor-kress

connor-kress commented Jul 11, 2026

Copy link
Copy Markdown

#34947 seems to be a more up to date implementation of this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Jul 24, 2026
feat(tui): show model variant in subagent footer #38772
Closed
3 of 6 tasks
@ArthurFranckPat ArthurFranckPat mentioned this pull request Aug 8, 2026
feat(opencode): add dispatch controls to the task tool #34947
Closed
3 tasks done
@github-actions github-actions Bot mentioned this pull request Aug 22, 2026
feat(opencode): model capability tiers for small/local models #44242
Closed
3 of 6 tasks
@yanglinfang yanglinfang mentioned this pull request Aug 26, 2026
[FEATURE]: Model capability class in metadata — size-appropriate prompts and tool behavior for small/local models #41372
Closed
1 task done
@github-actions github-actions Bot mentioned this pull request Sep 22, 2026
feat(config): support custom cost tiers #50717
Closed
3 of 6 tasks
@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thdxr thdxr closed this Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Dynamic model selection for subagents via Task tool

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@mcking-07 @RicardoMonteiroSimoes @connor-kress @thdxr
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.