diff options
| author | M. Adel Alhashemi <[email protected]> | 2026-01-13 05:37:42 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-01-12 20:37:42 -0600 |
| commit | 5d37e58d3477ecf9783cf28bf952b16b4e1ee044 (patch) | |
| tree | b72b8b3a40104439f2889a864b8680077b69d3f2 | |
| parent | 20088a87b0ef37f769eb8096faac89dd4a190af3 (diff) | |
| download | opencode-5d37e58d3477ecf9783cf28bf952b16b4e1ee044.tar.gz opencode-5d37e58d3477ecf9783cf28bf952b16b4e1ee044.zip | |
fix(task): respect agent task permission for nested sub-agents (#8111)
| -rw-r--r-- | packages/opencode/src/tool/task.ts | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/packages/opencode/src/tool/task.ts b/packages/opencode/src/tool/task.ts index 53b501ba9..170d44480 100644 --- a/packages/opencode/src/tool/task.ts +++ b/packages/opencode/src/tool/task.ts @@ -56,6 +56,9 @@ export const TaskTool = Tool.define("task", async (ctx) => { const agent = await Agent.get(params.subagent_type) 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 session = await iife(async () => { if (params.session_id) { const found = await Session.get(params.session_id).catch(() => {}) @@ -76,11 +79,15 @@ export const TaskTool = Tool.define("task", async (ctx) => { pattern: "*", action: "deny", }, - { - permission: "task", - pattern: "*", - action: "deny", - }, + ...(hasTaskPermission + ? [] + : [ + { + permission: "task" as const, + pattern: "*" as const, + action: "deny" as const, + }, + ]), ...(config.experimental?.primary_tools?.map((t) => ({ pattern: "*", action: "allow" as const, @@ -146,7 +153,7 @@ export const TaskTool = Tool.define("task", async (ctx) => { tools: { todowrite: false, todoread: false, - task: false, + ...(hasTaskPermission ? {} : { task: false }), ...Object.fromEntries((config.experimental?.primary_tools ?? []).map((t) => [t, false])), }, parts: promptParts, |
