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 model parameter to task tool for subagent model override by funkybooboo · Pull Request #26535 · anomalyco/opencode

Conversation

@funkybooboo

@funkybooboo funkybooboo commented May 9, 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

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, allowing callers to override which model a subagent uses at runtime. Accepts provider/model format (e.g. anthropic/claude-sonnet-4, openai/gpt-4o).

Model priority: params.model (task tool call) -> agent.model (agent config) -> parent session model (inherit)

Security: Model overrides are gated by model_override permission -- denied by default. Users must explicitly opt in via config. This prevents prompt injection from escalating to expensive models.

Example config:

{
  "permission": {
    "model_override": {
      "anthropic/*": "allow",
      "openai/gpt-4o": "allow"
    }
  }
}

Relationship to prior PRs

This PR addresses the same issue (#17595) as several other open PRs, with different tradeoffs:

PR Approach Status Key difference
#18528 model param + model_override permission Open, stalled Nearly identical approach. Uses zod schema and iife() helper; this PR uses Effect Schema and inline parsing. Both have the same permission gate.
#11217 @agent:provider/model syntax in prompt + TUI autocomplete + permission.model Open UI-driven approach with @ mention syntax. Much larger scope -- includes TUI and web UI changes.
#11377 model_tier param (quick/standard/advanced) + configurable tier-to-model mapping Open Tier abstraction layer rather than direct model selection. Adds a tier config system.
#17570 Config/UI-based agent-to-model assignment (assign-model command) Open Static config-only approach. No runtime model selection.

This PR takes the minimal, permission-gated approach from #18528 (which appears stalled since early May) with an Effect Schema implementation matching current codebase patterns.

Changes

packages/opencode/src/tool/task.ts -- Added model optional string param to Parameters schema. When provided:

  1. Validates the provider/model format (rejects missing / or empty parts with a clear error message)
  2. Asks model_override permission with the model and provider wildcard as patterns
  3. Parses into ProviderID/ModelID branded types using lightweight imports from provider/schema.ts
  4. Falls through to agent.model or parent session model when not provided

packages/opencode/src/tool/task.txt -- Added "Model selection" section documenting the new parameter and permission requirement.

packages/opencode/src/agent/agent.ts -- Added model_override: "deny" to default permission set for all agents.

packages/opencode/src/config/permission.ts -- Added model_override to the config permission schema so users can configure it in opencode.json.

packages/opencode/test/tool/task.test.ts -- Added 1 test verifying model param correctly overrides the model passed to the child session and prompt payload.

How did you verify your code works?

cd packages/opencode
bun test test/tool/task.test.ts   # 8 pass, 0 fail, 28 expect() calls
bun test test/permission/          # 85 pass, 0 fail, 130 expect() calls
bun typecheck                      # clean
bun run build                      # succeeds

Behavior change for users

Purely additive. The model parameter is optional and requires explicit permission. When omitted or denied, behavior is identical to before -- subagents inherit their model from agent config or the parent session.

Checklist

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

Sorry, something went wrong.

Uh oh!

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

All reactions
Copilot AI review requested due to automatic review settings May 9, 2026 15:46
@github-actions github-actions Bot added the needs:title label May 9, 2026
@github-actions

github-actions Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

Hey! Your PR title feat(tool/task): add model parameter to override subagent model doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 9, 2026
Copilot started reviewing on behalf of funkybooboo May 9, 2026 15:47
View session
@github-actions

github-actions Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

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

Based on my search, I found several related but older PRs that addressed similar features:

Potentially Related (Historical):

  • PR feat(task): add model override for subagents #18528 - feat(task): add model override for subagents - This appears to be a prior implementation of the same feature
  • PR feat: add assign-model feature for subagent model selection #17570 - feat: add assign-model feature for subagent model selection - Earlier model selection approach
  • PR feat(agent): implement model tier selection with variant support for subagents #11377 - feat(agent): implement model tier selection with variant support for subagents - Related model routing functionality
  • PR feat(task): allow @agent:provider/model model overrides #11217 - feat(task): allow @agent:provider/model model overrides - Similar override syntax

These are merged/closed PRs from the repository's history, so the current PR (26535) is not a duplicate of open PRs. However, you may want to verify:

  1. Whether the new implementation in PR feat(opencode): add model parameter to task tool for subagent model override #26535 builds on or supersedes the approach in PR feat(task): add model override for subagents #18528
  2. If there's a reason these prior implementations existed but the feature is being re-added now

No open duplicate PRs found - The current PR is not duplicating any actively open pull requests.

All reactions

Sorry, something went wrong.

Uh oh!

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

@funkybooboo funkybooboo changed the title feat(tool/task): add model parameter to override subagent model feat(opencode): add model parameter to task tool for subagent model override May 9, 2026
@funkybooboo funkybooboo mentioned this pull request May 9, 2026
feat(opencode): add model parameter to task tool for subagent model override #26536
Closed
@github-actions github-actions Bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:title labels May 9, 2026
@github-actions

github-actions Bot commented May 9, 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.

Copilot AI reviewed May 9, 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

Adds an optional model parameter to the task tool so callers can override which model a spawned subagent uses (taking priority over the agent’s configured model and the parent message/session model), and documents + tests the new behavior.

Changes:

  • Extend TaskTool parameters with optional model in provider/model format and apply it during subagent session/prompt creation.
  • Document “Model selection” for the task tool.
  • Add a test asserting the override propagates into the child session metadata and the prompt payload.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/opencode/src/tool/task.ts Adds model param and uses it to resolve the subagent model via Provider.parseModel() before falling back to agent/parent model.
packages/opencode/src/tool/task.txt Documents the new model parameter and intended usage.
packages/opencode/test/tool/task.test.ts Adds a test verifying model overrides the model used for the child prompt + returned metadata.

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

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.ts Resolved

Uh oh!

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

@funkybooboo
feat(opencode): add model parameter to task tool for subagent model o…
bf6215a
…verride

Adds an optional model parameter to the task tool that overrides which
model a subagent uses. Format: provider/model (e.g. anthropic/claude-sonnet-4).

Model priority: params.model > agent config > parent session model.

The model_override permission is denied by default, requiring users to
opt in via config (e.g. model_override: { anthropic/*: allow }).
This prevents prompt injection from escalating to expensive models.

Closes anomalyco#17595
@funkybooboo
funkybooboo force-pushed the feat/task-model-override branch from cae2d8d to bf6215a Compare May 9, 2026 16:28
@funkybooboo funkybooboo mentioned this pull request May 9, 2026
[FEATURE]: Runtime model override for task tool subagents #17595
Closed
1 task done
@kobicovaldev

kobicovaldev commented May 26, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Thanks for putting this together — this is exactly the behavior I was looking for as an opencode user. I tested a small local version of the same idea and confirmed the Task tool model parameter works well for orchestrator-driven subagent routing.

I took a look at why this seems stuck. GitHub currently reports the PR as conflicted/dirty against dev — the branch is far behind current dev, and the conflicts are mostly around the newer Task implementation/background-subagent code.

A few concrete notes from porting this locally onto current dev:

  • Keep the lightweight ModelID / ProviderID parsing approach from this PR rather than importing the full provider module.
  • Keep early provider/model validation before any permission prompt.
  • Ask model_override before the normal task permission prompt. Otherwise a user can approve/persist a task permission before the default-denied model override fails.
  • I suggest exact-model always scope, e.g. always: [modelOverride], rather than provider-wide anthropic/*, for least privilege. Provider-wide allow can still be configured explicitly by the user in config.
  • Additional useful tests: explicit override precedence, subagent-model fallback, parent-model fallback, invalid model rejected before asks, and model_override ask ordering before task.

I have a clean local port of this onto current dev with those tweaks if that would help. Validation I could run locally: git diff --check and lightweight Bun build checks for the touched files passed; full bun test/typecheck were blocked in my local checkout by missing @opentui/solid/preload and tsgo.

All reactions

Sorry, something went wrong.

Uh oh!

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

@kobicovaldev kobicovaldev mentioned this pull request May 26, 2026
feat(opencode): add task model override #29447
Closed
3 of 6 tasks
@kobicovaldev

kobicovaldev commented May 26, 2026

Copy link
Copy Markdown
Contributor

I opened a refreshed forward-port at #29447 to help unblock maintainers since this branch is conflicted/far behind dev.

I credited this PR and @funkybooboo in the new PR body and kept the same core design: optional Task model, model_override permission, early provider/model validation, and explicit model > subagent model > parent model precedence. I also included the permission-ordering/test coverage notes from my local port.

Happy to close mine if this branch gets refreshed first — mostly trying to move the existing work over the line.

All reactions

Sorry, something went wrong.

Uh oh!

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

@funkybooboo

funkybooboo commented May 28, 2026

Copy link
Copy Markdown
Author

@kobicovaldev thank you for keeping the work moving! I love what you have done and am happy to close this PR!

All reactions

Sorry, something went wrong.

Uh oh!

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

@funkybooboo funkybooboo closed this May 28, 2026
@github-actions github-actions Bot mentioned this pull request May 28, 2026
📊 AI CLI 工具社区动态日报 2026-05-28 ivanweng2077/big_model_radar#101
Open
@leoncheng57 leoncheng57 mentioned this pull request Aug 26, 2026
feat(task): allow selecting a model per task invocation (1.18.23 lineage) leoncheng57/opencode#4
Merged
3 of 6 tasks
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]: Runtime model override for task tool subagents

Uh oh!

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

3 participants

@funkybooboo @kobicovaldev
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.