Skip to content

Commit aca39a6

Browse files
committed
fix(plan): deny plan_exit and plan_enter in subagent sessions
1 parent 46f243f commit aca39a6

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

packages/opencode/src/tool/task.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ export const TaskTool = Tool.defineEffect(
5555

5656
const canTask = next.permission.some((rule) => rule.permission === id)
5757
const canTodo = next.permission.some((rule) => rule.permission === "todowrite")
58+
const canPlanExit = next.permission.some((rule) => rule.permission === "plan_exit")
59+
const canPlanEnter = next.permission.some((rule) => rule.permission === "plan_enter")
5860

5961
const taskID = params.task_id
6062
const session = taskID
@@ -79,6 +81,24 @@ export const TaskTool = Tool.defineEffect(
7981
action: "deny" as const,
8082
},
8183
]),
84+
...(canPlanExit
85+
? []
86+
: [
87+
{
88+
permission: "plan_exit" as const,
89+
pattern: "*" as const,
90+
action: "deny" as const,
91+
},
92+
]),
93+
...(canPlanEnter
94+
? []
95+
: [
96+
{
97+
permission: "plan_enter" as const,
98+
pattern: "*" as const,
99+
action: "deny" as const,
100+
},
101+
]),
82102
...(canTask
83103
? []
84104
: [
@@ -137,6 +157,8 @@ export const TaskTool = Tool.defineEffect(
137157
agent: next.name,
138158
tools: {
139159
...(canTodo ? {} : { todowrite: false }),
160+
plan_exit: false,
161+
plan_enter: false,
140162
...(canTask ? {} : { task: false }),
141163
...Object.fromEntries((cfg.experimental?.primary_tools ?? []).map((item) => [item, false])),
142164
},

0 commit comments

Comments
 (0)