Skip to content

Commit eea422d

Browse files
ariane-emorycainiao1992
authored andcommitted
fix(task): respect agent permission config for todowrite tool (anomalyco#19125)
1 parent e760eb9 commit eea422d

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

packages/opencode/src/tool/task.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export const TaskTool = Tool.define("task", async (ctx) => {
6464
if (!agent) throw new Error(`Unknown agent type: ${params.subagent_type} is not a valid agent type`)
6565

6666
const hasTaskPermission = agent.permission.some((rule) => rule.permission === "task")
67+
const hasTodoWritePermission = agent.permission.some((rule) => rule.permission === "todowrite")
6768

6869
const session = await iife(async () => {
6970
if (params.task_id) {
@@ -75,11 +76,15 @@ export const TaskTool = Tool.define("task", async (ctx) => {
7576
parentID: ctx.sessionID,
7677
title: params.description + ` (@${agent.name} subagent)`,
7778
permission: [
78-
{
79-
permission: "todowrite",
80-
pattern: "*",
81-
action: "deny",
82-
},
79+
...(hasTodoWritePermission
80+
? []
81+
: [
82+
{
83+
permission: "todowrite" as const,
84+
pattern: "*" as const,
85+
action: "deny" as const,
86+
},
87+
]),
8388
...(hasTaskPermission
8489
? []
8590
: [
@@ -131,7 +136,7 @@ export const TaskTool = Tool.define("task", async (ctx) => {
131136
},
132137
agent: agent.name,
133138
tools: {
134-
todowrite: false,
139+
...(hasTodoWritePermission ? {} : { todowrite: false }),
135140
...(hasTaskPermission ? {} : { task: false }),
136141
...Object.fromEntries((config.experimental?.primary_tools ?? []).map((t) => [t, false])),
137142
},

0 commit comments

Comments
 (0)