Feature Request: Advanced Agent Orchestration with Hierarchical Delegation and Persistent Agents
Title: Feature Request: Advanced Agent Orchestration with Hierarchical Delegation and Persistent Agents
Is your feature request related to a problem? Please describe.
The current subagent system is powerful for delegating specific tasks but is limited by its flat, "hub-and-spoke" architecture. The main Claude Code instance can invoke a subagent using the Task tool, but that subagent cannot delegate further. This architectural constraint presents several problems:
- Limited Autonomy: For any complex, multi-stage task (e.g., "implement a new feature"), the user must manually act as the central orchestrator, breaking the problem down and invoking a sequence of different agents. This defeats the purpose of having an autonomous agent that can manage a complex goal from start to finish.
- Lack of Modularity: It forces the creation of large, monolithic subagents that must handle diverse responsibilities (e.g., backend, frontend, database, testing) within a single context, making them difficult to maintain, reuse, and scale.
- Context Pollution: The main agent's context window becomes cluttered with the details of every sub-task, reducing its ability to maintain a high-level focus on the overall objective.
- No Long-Running Tasks: The current model is transactional; agents are invoked for a specific task and then terminate. There is no way to launch an agent to perform a persistent, long-running background task, such as monitoring logs or watching a repository for new pull requests.
Describe the solution you'd like
I propose a significant enhancement to the agent framework to enable advanced orchestration through two primary features: Hierarchical Delegation and Persistent, User-Initiated Agents.
1. Hierarchical Agent Delegation (Agents Managing Agents)
This is the core of the request. Subagents should be able to invoke and manage other subagents, creating a hierarchical or networked structure that mirrors a real-world development team.
This could be implemented by:
- Granting the
Tasktool to all subagents, allowing them to delegate tasks just as the main agent can. - Enabling a "manager" or "orchestrator" agent pattern. This agent would receive a high-level goal, create a plan, and then use the
Tasktool to delegate sub-tasks to specialized "worker" agents. - Supporting both synchronous and asynchronous delegation. A manager agent should be able to await the result of a child agent's task or launch multiple agents in parallel to work on different parts of a problem concurrently.
- Allowing the manager agent to receive and synthesize the results from child agents to produce a final, integrated solution.
2. Persistent, User-Initiated Agents
To provide more direct control and support for long-running tasks, we propose a new set of agent management capabilities.
- Direct Agent Launch: Introduce a slash command for users to directly invoke a specific agent with a prompt, bypassing the main agent's conversational flow.
- Example:
/launch <agent-name> [prompt](e.g.,/launch code-reviewer "Check my recent changes for security flaws.")
- Example:
- Persistent Background Agents: Extend the
/launchcommand to support long-running, background agent sessions that do not block the user's terminal./agents-ps: List all currently running persistent agent sessions and their status./agent-attach <session-id>: Attach to a running agent's session to view its live output and interact with it./agent-kill <session-id>: Terminate a running agent session.
Use Case Examples
Use Case 1: Autonomous Full-Stack Feature Implementation (Hierarchical Delegation)
A user prompts: > Use the 'feature-lead' agent to implement a new user dashboard as described in JIRA-123.
- The top-level
feature-leadagent is invoked. It uses another agent to read the Jira ticket and formulates a plan. - It then orchestrates a team of specialized agents in parallel:
Task(prompt="Design and write the database schema migration for dashboard analytics", subagent_type="db-architect-agent")Task(prompt="Create secure backend API endpoints to serve the dashboard data", subagent_type="api-developer-agent")Task(prompt="Build the frontend dashboard UI in React based on the Figma mockups", subagent_type="ui-specialist-agent")
- As the
api-developer-agentfinishes its code, it can invoke another, more granular agent:Task(prompt="Review the new API endpoints for security vulnerabilities and adherence to our style guide", subagent_type="code-reviewer-agent"). - The
feature-leadagent monitors the progress, integrates the completed work from all child agents, and presents the final, tested, and reviewed feature.
Use Case 2: Proactive Codebase Monitoring (Persistent Agents)
A user wants an agent to continuously monitor their repository.
- The user runs:
/launch pr-watcher-agent "Watch for new PRs in this repo and post initial feedback based on our style guide in CLAUDE.md" - The
pr-watcher-agentstarts as a background process. The user can continue their work in the terminal. - The user can check on the agent's status by running
/agents-ps. - When a new PR is opened, the agent autonomously performs its review task, demonstrating a proactive, long-running capability that is not possible today.
Describe alternatives you've considered
- Creating larger, monolithic agents: This is the current workaround. It is less scalable, harder to maintain, and does not promote the reusability of specialized agent skills.
- Manual user-driven orchestration: Requiring the user to manually chain agent commands in a single, complex prompt is inefficient, brittle, requires constant intervention, and defeats the purpose of an autonomous system.
Why is this important?
This set of features would be a transformative step for Claude Code, elevating it from a powerful pair-programmer to a true agentic system capable of managing complex projects like an AI development team. It would:
- Enable Greater Complexity: Allow the autonomous handling of large-scale, multi-faceted software engineering challenges.
- Promote Modularity: Encourage the creation of small, focused, and reusable specialist agents.
- Improve Context Management: Isolate sub-tasks into their own context windows, keeping the primary conversation focused and efficient.
- Unlock New Capabilities: Enable proactive, long-running tasks like monitoring, CI/CD integration, and automated code maintenance.
I'm curious if you've tried using a custom slash command in place of the top level agent described here?
👍
I'm worried that the phrasing of this issue makes it sound like a bigger deal than it is, e.g., the complexity:high automatic label. The main incremental change here, allowing agents to invoke other agents, would simply be to give subagents the ability that already exists for the primary thread. I assume that Anthropic made an explicit choice not to allow that to prevent infinite looping and other runaway behavior, but that can also be limited by adding simple "countdown style" delegation limits.
It would be hugely beneficial to allow a subagent to invoke a subagent.
I’ve built an MCP server wrapper using SubAgents, and it works great so far. However, I’ve found it inconvenient that I can’t call this SubAgent from another SubAgent that handles other tasks. It would be really helpful if SubAgents could invoke each other — that would unlock more modular and autonomous workflows.
Thanks for the awesome work on this feature!
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.