From 66a56551beb9299b0de694e5070afe22ab6bcad9 Mon Sep 17 00:00:00 2001 From: Ariane Emory <97994360+ariane-emory@users.noreply.github.com> Date: Wed, 25 Mar 2026 16:18:52 -0400 Subject: [PATCH] fix(task): respect agent permission config for todowrite tool (#19125) --- packages/opencode/src/tool/task.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/opencode/src/tool/task.ts b/packages/opencode/src/tool/task.ts index f2a83507fa..af130a70d9 100644 --- a/packages/opencode/src/tool/task.ts +++ b/packages/opencode/src/tool/task.ts @@ -64,6 +64,7 @@ export const TaskTool = Tool.define("task", async (ctx) => { if (!agent) throw new Error(`Unknown agent type: ${params.subagent_type} is not a valid agent type`) const hasTaskPermission = agent.permission.some((rule) => rule.permission === "task") + const hasTodoWritePermission = agent.permission.some((rule) => rule.permission === "todowrite") const session = await iife(async () => { if (params.task_id) { @@ -75,11 +76,15 @@ export const TaskTool = Tool.define("task", async (ctx) => { parentID: ctx.sessionID, title: params.description + ` (@${agent.name} subagent)`, permission: [ - { - permission: "todowrite", - pattern: "*", - action: "deny", - }, + ...(hasTodoWritePermission + ? [] + : [ + { + permission: "todowrite" as const, + pattern: "*" as const, + action: "deny" as const, + }, + ]), ...(hasTaskPermission ? [] : [ @@ -131,7 +136,7 @@ export const TaskTool = Tool.define("task", async (ctx) => { }, agent: agent.name, tools: { - todowrite: false, + ...(hasTodoWritePermission ? {} : { todowrite: false }), ...(hasTaskPermission ? {} : { task: false }), ...Object.fromEntries((config.experimental?.primary_tools ?? []).map((t) => [t, false])), },