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

feat(opencode): add model parameter to task tool for subagent model override #26535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
funkybooboo wants to merge 1 commit into anomalyco:dev from funkybooboo:feat/task-model-override

Uh oh!

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

Closed

feat(opencode): add model parameter to task tool for subagent model override #26535

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
bf6215a
feat(opencode): add model parameter to task tool for subagent model o…
funkybooboo May 9, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

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

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

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

Diff view
Diff view

There are no files selected for viewing

1 change: 1 addition & 0 deletions 1 packages/opencode/src/agent/agent.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const layer = Layer.effect(
const defaults = Permission.fromConfig({
"*": "allow",
doom_loop: "ask",
model_override: "deny",
external_directory: {
"*": "ask",
...Object.fromEntries(whitelistedDirs.map((dir) => [dir, "allow"])),
Expand Down
1 change: 1 addition & 0 deletions 1 packages/opencode/src/config/permission.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const InputObject = Schema.StructWithRest(
codesearch: Schema.optional(Action),
repo_clone: Schema.optional(Rule),
repo_overview: Schema.optional(Rule),
model_override: Schema.optional(Rule),
lsp: Schema.optional(Rule),
doom_loop: Schema.optional(Action),
skill: Schema.optional(Rule),
Expand Down
37 changes: 34 additions & 3 deletions 37 packages/opencode/src/tool/task.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { MessageV2 } from "../session/message-v2"
import { Agent } from "../agent/agent"
import type { SessionPrompt } from "../session/prompt"
import { Config } from "@/config/config"
import { ModelID, ProviderID } from "../provider/schema"
import { Effect, Exit, Schema } from "effect"
import { EffectBridge } from "@/effect/bridge"

Expand All @@ -21,6 +22,10 @@ export const Parameters = Schema.Struct({
description: Schema.String.annotate({ description: "A short (3-5 words) description of the task" }),
prompt: Schema.String.annotate({ description: "The task for the agent to perform" }),
subagent_type: Schema.String.annotate({ description: "The type of specialized agent to use for this task" }),
model: Schema.optional(Schema.String).annotate({
description:
"Override the model for this subagent. Format: provider/model (e.g. anthropic/claude-sonnet-4, openai/gpt-4o). Takes precedence over the agent's configured model.",
}),
task_id: Schema.optional(Schema.String).annotate({
description:
"This should only be set if you mean to resume a previous task (you can pass a prior task_id and the task will continue the same subagent session as before instead of creating a fresh one)",
Expand Down Expand Up @@ -104,9 +109,35 @@ export const TaskTool = Tool.define(
const msg = yield* Effect.sync(() => MessageV2.get({ sessionID: ctx.sessionID, messageID: ctx.messageID }))
if (msg.info.role !== "assistant") return yield* Effect.fail(new Error("Not an assistant message"))

const model = next.model ?? {
modelID: msg.info.modelID,
providerID: msg.info.providerID,
let model: { modelID: ModelID; providerID: ProviderID }
if (params.model) {
const slash = params.model.indexOf("/")
if (slash <= 0 || slash === params.model.length - 1) {
return yield* Effect.fail(
new Error(
`Invalid model format: "${params.model}". Expected provider/model (e.g. anthropic/claude-sonnet-4)`,
),
)
}
yield* ctx.ask({
permission: "model_override",
patterns: [params.model],
always: [params.model.slice(0, slash + 1) + "*"],
metadata: {
description: params.description,
subagent_type: params.subagent_type,
model: params.model,
},
})
model = {
providerID: ProviderID.make(params.model.slice(0, slash)),
modelID: ModelID.make(params.model.slice(slash + 1)),
}
} else {
model = next.model ?? {
modelID: msg.info.modelID,
providerID: msg.info.providerID,
}
}

yield* ctx.metadata({
Expand Down
5 changes: 5 additions & 0 deletions 5 packages/opencode/src/tool/task.txt
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ When NOT to use the Task tool:
- If you are searching for code within a specific file or set of 2-3 files, use the Read tool instead of the Task tool, to find the match more quickly
- Other tasks that are not related to the agent descriptions above

Model selection:
- Each agent has a default model (usually inherited from the parent session).
- You can override the model by passing the `model` parameter in `provider/model` format (e.g. `anthropic/claude-sonnet-4`, `openai/gpt-4o`, `google/gemini-2.5-pro`).
- Model overrides require the `model_override` permission. By default this permission is denied and the user will be asked to approve. The user can allow specific models or providers in their config (e.g. `"model_override": { "anthropic/*": "allow" }`).
- Use the `model` parameter to run a subagent on a different model than the parent session. This is useful for leveraging different model strengths (e.g., sending research tasks to a faster/cheaper model, or routing code generation to a more capable model).

Usage notes:
1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
Expand Down
34 changes: 34 additions & 0 deletions 34 packages/opencode/test/tool/task.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -432,4 +432,38 @@ describe("tool.task", () => {
},
},
)

it.instance("execute uses model parameter to override subagent model", () =>
Effect.gen(function* () {
const { chat, assistant } = yield* seed()
const tool = yield* TaskTool
const def = yield* tool.init()
let seen: SessionPrompt.PromptInput | undefined
const promptOps = stubOps({ onPrompt: (input) => (seen = input) })

const result = yield* def.execute(
{
description: "inspect bug",
prompt: "look into the cache key path",
subagent_type: "general",
model: "anthropic/claude-sonnet-4",
},
{
sessionID: chat.id,
messageID: assistant.id,
agent: "build",
abort: new AbortController().signal,
extra: { promptOps },
messages: [],
metadata: () => Effect.void,
ask: () => Effect.void,
},
)

expect(result.metadata.model.providerID as string).toBe("anthropic")
expect(result.metadata.model.modelID as string).toBe("claude-sonnet-4")
expect((seen?.model?.providerID ?? "") as string).toBe("anthropic")
expect((seen?.model?.modelID ?? "") as string).toBe("claude-sonnet-4")
}),
)
})
Loading
Oops, something went wrong.

Uh oh!

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

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.