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(opencode): add runtime model override for task tool subagents by pratikranaa · Pull Request #35800 · anomalyco/opencode

Conversation

@pratikranaa

@pratikranaa pratikranaa commented Jul 7, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Issue for this PR

Closes #17595, #32730

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds an optional model parameter to the task tool so a primary agent can pick a subagent model at runtime using provider/model-id format.

Model priority: explicit model param → subagent configured model frontmatter → parent assistant message model.

Explicit overrides are gated behind a new model_override permission (defaults to ask) to prevent prompt-injection escalation to expensive models.

How did you verify your code works?

  • 25 tests in test/tool/task.test.ts (7 new) — all pass
  • bunx tsc --noEmit clean on changed files
  • Tests cover: per-agent model resolution, cross-provider models, parent fallback, variant clearing, runtime override, override priority over configured model, invalid format rejection, permission prompting

Screenshots / recordings

N/A — backend logic change, no UI.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Note: #29447 implements the same feature but has been waiting for review since May. This is an independent implementation.

Sorry, something went wrong.

Uh oh!

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

TTTPOB, colinmollenhour, Paatricious, and Wood9264 reacted with thumbs up emoji
All reactions
  • 👍 4 reactions
@pratikranaa
feat(opencode): add runtime model override for task tool subagents
869f24a
Add an optional model parameter to the task tool so a primary agent can
choose a subagent model at runtime using "provider/model-id" format.

Model selection order: explicit task model -> subagent configured model ->
parent assistant message model. Explicit overrides are gated behind a new
model_override permission that defaults to "ask", so users control which
models agents can switch to without a prompt-injection escalation risk.

Also adds test coverage for the existing per-agent model feature (frontmatter
model field) which previously had no tests, and tests for the new runtime
override including format validation, permission checking, and priority over
the agent configured model.

Closes anomalyco#17595, anomalyco#32730
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

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

Potential Duplicate Found

PR #29447: feat(opencode): add task model override
#29447

Why it's related: This is the exact same feature mentioned in the PR description. PR #29447 has been waiting for review since May and implements the same task tool model override functionality. The current PR (35800) is an independent implementation of the same feature.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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 9, 2026
feat: add OPENCODE_SUBAGENT_MODEL env var to override subagent model #36146
Closed
3 of 6 tasks
@TTTPOB

TTTPOB commented Jul 16, 2026

Copy link
Copy Markdown

really need this, i don't have to write a bunch of special agent def files if this get merged.

colinmollenhour reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

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

@colinmollenhour

colinmollenhour commented Jul 20, 2026

Copy link
Copy Markdown

@pratikranaa It's not clear to me skimming the code if the variant can also be overridden? I think definitely all of these should be possible:

  • Call subagent with different model - default variant
  • Call subagent with different model - specific variant
  • Call subagent with same model - specific other variant

For example, the parent model could be "xhigh" and call a "low" subagent or vice versa. If this is possible already, I think the docs/tool should be updated so it's more visible.

All reactions

Sorry, something went wrong.

Uh oh!

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

hunterchristian added a commit to chipp-ai/opencode that referenced this pull request Sep 23, 2026
@hunterchristian @claude
feat(opencode): add per-call subagent model selection to the Task tool
98df7b5
The primary agent can now override which model a specific task
dispatch uses (model: "provider/model-id", plus an optional variant),
instead of every dispatch always using the subagent's statically-
configured model.

Ported from upstream anomalyco#6651 (86 reactions/44
comments -- a contested, actively-discussed ask). At least 6
independent implementations exist over ~8 months, all unmerged;
PR anomalyco#34947 (open since July, 13 files) is the consolidated,
community-endorsed design, but PR anomalyco#35800 (open, 4 files, smaller
focused variant) is the actual primary source here: its single
ctx.ask permission gate and override-first model resolution (reusing
the existing Provider.parseModel) is the core mechanism. The variant
parameter and its "always allow" behavior come from anomalyco#34947. anomalyco#34947
defaulted the new permission to "deny"; this fork defaults to "ask"
so the feature works without extra config.

New model_override permission (default "ask", pre-allowable per
pattern, e.g. {"model_override": {"anthropic/*": "allow"}}).

Known gaps: the override model isn't validated up front (a
nonexistent model fails only when the subagent runs); no typed config
key yet (works as a free-form permission key); a resumed task doesn't
remember a prior override; no TUI for picking a model per dispatch;
only the legacy V1 Task-tool path is covered, not V2 SessionRunner/
AgentV2 dispatch; slug task IDs, resume, timeout, fallback_model
(would overlap with this fork's own model-fallback feature), metadata,
and cancelRun from anomalyco#34947's fuller scope were left out.

New tests in packages/opencode/test/tool/task.test.ts (10 cases) plus
a default-permission test in test/agent/agent.test.ts. Verified
against this fork's current dev (not just the agent's own stale
worktree base): bun typecheck clean; full packages/opencode suite
3613 pass, only the 4 pre-existing, confirmed-unrelated cf-ai-gateway
failures.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@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

No reviews

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]: Runtime model override for task tool subagents

Uh oh!

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

4 participants

@pratikranaa @TTTPOB @colinmollenhour @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.