-
Notifications
You must be signed in to change notification settings - Fork 9.9k
Open
Description
Summary
Task tool ignores per-target deny rules and allows an agent to dispatch itself. This enables recursive subagent spawning (self-dispatch loop) even when permission.task denies that target.
Steps to reproduce
- Define an agent
srewith task permission allowing*but denyingsreas a target.
# opencode.json (agent snippet)
permission:
task:
"*": allow
sre: deny- Start a session as
@sre. - Invoke the Task tool with
subagent_type: "sre".
Example payload:
{
"tool": "task",
"arguments": {
"subagent_type": "sre",
"prompt": "...",
"description": "..."
}
}Expected
The Task tool call is rejected with a permission error because the target sre is denied.
Actual
The Task tool call succeeds and spawns @sre again, enabling recursive self-dispatch loops.
Impact
- Deny rules for specific subagent targets are not enforced at execution time.
- Self-dispatch loops can create runaway subagent chains.
Workaround
Add a custom guard in tool.execute.before to reject Task calls when the current agent is sre and subagent_type is sre.
Environment
- Observed on macOS with current
anomalyco/opencodemain (date: 2026-01-31) - Configured via agent permissions (see snippet above)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels