Skip to content

Commit 94eb30b

Browse files
committed
fix(task): respect agent task permission for nested sub-agents
The permission rework in #6319 removed the ability to override the default task tool restriction via agent frontmatter. This fix checks if the agent has any task permission rule defined. If so, we don't add our default deny - letting the agent's permission take effect. If not specified, the default deny behavior is preserved.
1 parent 05019da commit 94eb30b

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

packages/opencode/src/tool/task.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export const TaskTool = Tool.define("task", async (ctx) => {
5656

5757
const agent = await Agent.get(params.subagent_type)
5858
if (!agent) throw new Error(`Unknown agent type: ${params.subagent_type} is not a valid agent type`)
59+
60+
const hasTaskPermission = agent.permission.some((rule) => rule.permission === "task")
61+
5962
const session = await iife(async () => {
6063
if (params.session_id) {
6164
const found = await Session.get(params.session_id).catch(() => {})
@@ -76,11 +79,15 @@ export const TaskTool = Tool.define("task", async (ctx) => {
7679
pattern: "*",
7780
action: "deny",
7881
},
79-
{
80-
permission: "task",
81-
pattern: "*",
82-
action: "deny",
83-
},
82+
...(hasTaskPermission
83+
? []
84+
: [
85+
{
86+
permission: "task" as const,
87+
pattern: "*" as const,
88+
action: "deny" as const,
89+
},
90+
]),
8491
...(config.experimental?.primary_tools?.map((t) => ({
8592
pattern: "*",
8693
action: "allow" as const,
@@ -146,7 +153,7 @@ export const TaskTool = Tool.define("task", async (ctx) => {
146153
tools: {
147154
todowrite: false,
148155
todoread: false,
149-
task: false,
156+
...(hasTaskPermission ? {} : { task: false }),
150157
...Object.fromEntries((config.experimental?.primary_tools ?? []).map((t) => [t, false])),
151158
},
152159
parts: promptParts,

0 commit comments

Comments
 (0)