Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/opencode/src/tool/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { iife } from "@/util/iife"
import { defer } from "@/util/defer"
import { Config } from "../config/config"
import { PermissionNext } from "@/permission/next"
import { Provider } from "../provider/provider"

const parameters = z.object({
description: z.string().describe("A short (3-5 words) description of the task"),
Expand All @@ -22,6 +23,12 @@ const parameters = z.object({
)
.optional(),
command: z.string().describe("The command that triggered this task").optional(),
model: z
.string()
.describe(
"Optional model to use for this task in the format 'provider/model' (e.g. 'github-copilot/claude-sonnet-4.6'). Overrides the agent's default model.",
)
.optional(),
})

export const TaskTool = Tool.define("task", async (ctx) => {
Expand Down Expand Up @@ -103,7 +110,7 @@ export const TaskTool = Tool.define("task", async (ctx) => {
const msg = await MessageV2.get({ sessionID: ctx.sessionID, messageID: ctx.messageID })
if (msg.info.role !== "assistant") throw new Error("Not an assistant message")

const model = agent.model ?? {
const model = (params.model ? Provider.parseModel(params.model) : undefined) ?? agent.model ?? {
modelID: msg.info.modelID,
providerID: msg.info.providerID,
}
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/tool/task.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ When NOT to use the Task tool:
Usage notes:
1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
2. When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result. The output includes a task_id you can reuse later to continue the same subagent session.
7. You can optionally specify a `model` parameter to override the agent's default model. The format is "provider/model" (e.g. "github-copilot/claude-sonnet-4.6"). This is useful when orchestrating agents that need different model tiers for different tasks.
3. Each agent invocation starts with a fresh context unless you provide task_id to resume the same subagent session (which continues with its previous messages and tool outputs). When starting fresh, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.
4. The agent's outputs should generally be trusted
5. Clearly tell the agent whether you expect it to write code or just to do research (search, file reads, web fetches, etc.), since it is not aware of the user's intent. Tell it how to verify its work if possible (e.g., relevant test commands).
Expand Down
Loading