Skip to content

Task tool ignores per-target deny and allows self-dispatch recursion #11324

@HyunggyuJang

Description

@HyunggyuJang

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

  1. Define an agent sre with task permission allowing * but denying sre as a target.
# opencode.json (agent snippet)
permission:
  task:
    "*": allow
    sre: deny
  1. Start a session as @sre.
  2. 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/opencode main (date: 2026-01-31)
  • Configured via agent permissions (see snippet above)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions