[FEATURE] Enable Task tool for subagents with configurable depth limit

Resolved 💬 4 comments Opened Jan 1, 2026 by AlexZan Closed Feb 19, 2026

Problem Statement

Subagents spawned via the Task tool cannot themselves spawn additional subagents. The Task tool is intentionally excluded from subagents, preventing hierarchical agent orchestration patterns.

Why This Is Different From Existing Issues

| Issue | Status | Focus | Why Different |
|-------|--------|-------|---------------|
| #4182 | Closed as duplicate | Task tool not exposed to subagents | Closed without resolution, pointed to other closed issues |
| #5528 | Closed as duplicate | Sub-agent delegation pattern unusable | Same - closed without implementation |
| #1770 | Open | Parent-child monitoring/communication | About visibility, not spawning capability |
| #15487 | Open | Limit parallel agents | About resource limits, not enabling nested spawning |
| #4850 | Closed | OOM from infinite recursion | Bug report, not feature request with depth limits |

No open issue exists specifically requesting depth-limited recursive Task tool access.

Use Case: ATP:TDD Pipeline

I'm building an Agent Teams Pattern for Test-Driven Development where:

parent-director (orchestrator)
├── child-director-issue-123 (worktree-123/)
│   ├── test-architect
│   ├── dev-agent  
│   └── qa-agent
├── child-director-issue-124 (worktree-124/)
│   ├── test-architect
│   ├── dev-agent
│   └── qa-agent
└── merges worktrees when children complete

Each child-director runs an independent pipeline in its own git worktree. This enables parallel feature development with proper isolation.

Current limitation: The parent-director cannot spawn child-directors that themselves spawn workers, because subagents lack Task tool access.

Current Workaround

Spawning agents via Bash works but is suboptimal:

claude --agent child-director "Run pipeline for issue #123"

Problems with Bash workaround:

  • No progress tracking or ability to interrupt
  • No structured output handling - errors buried in bash output
  • Each spawned process has independent context (no parent visibility)
  • No integration with Task tool's monitoring capabilities

Proposed Solution

  1. Enable Task tool for subagents with a configurable depth limit
  2. Default depth: 2 levels (parent → child → grandchild)
  3. Configuration:
{
  "maxAgentDepth": 2,
  "maxParallelAgents": 10
}
  1. Clear error when depth exceeded: "Maximum agent depth (2) reached. Cannot spawn further subagents."

Benefits

  • Enables sophisticated orchestration patterns
  • Prevents infinite recursion via depth limit
  • Proper progress tracking and structured output
  • Pairs well with #15487 (maxParallelAgents) for resource control

Environment

  • Claude Code version: Latest
  • Subscription: Claude Max
  • OS: Windows 11

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗