Sub-agents allow you to create modular, reusable agents that can be composed together. A parent agent can delegate specific tasks to specialized sub-agents through tool calls.
Sub-agents are automatically converted to tools that parent agents can call. Each sub-agent runs with a default limit of 50 steps.
---model: anthropic:claude-haiku-4-5---You are a research specialist. Find accurate, relevant information.## TaskResearch the requested topic and provide comprehensive findings.
The agent name is automatically derived from the filename (e.g., researcher.agentuse becomes researcher).
---model: anthropic:claude-sonnet-4-5subagents: - path: ./researcher.agentuse---You coordinate research tasks using specialized agents.## TaskWhen asked for information, use the researcher tool to gather data.
Sub-agents are called as tools using their filename (without .agentuse). The researcher.agentuse becomes available as the researcher tool.
---model: anthropic:claude-sonnet-4-5subagents: - path: ./agents/researcher.agentuse - path: ./agents/writer.agentuse - path: ./agents/editor.agentuse---You manage content creation using specialized agents.## Workflow1. Use researcher tool to gather information2. Use writer tool to create initial draft3. Use editor tool to polish and finalize
Sub-agents accept optional parameters when called as tools:
Copy
---model: anthropic:claude-sonnet-4-5subagents: - path: ./data-processor.agentuse---You analyze data using specialized processors.## TaskWhen given data:1. Call data_processor tool with task parameter and context2. Interpret the results3. Provide insightsExample: data_processor(task="Analyze sales data", context={"period": "Q4 2023"})
---model: anthropic:claude-sonnet-4-5subagents: - path: ./analyzer-1.agentuse - path: ./analyzer-2.agentuse - path: ./analyzer-3.agentuse---You process data in parallel using multiple analyzers.## TaskSplit the data and send parts to different analyzer tools.Combine their results for comprehensive analysis.You can call multiple tools in sequence or use them to analyze different aspects of the same data.
Sub-agents run sequentially, not in true parallel. The parent agent calls each sub-agent tool one at a time.
Sub-agents create their own isolated tool environments:
Copy
# parent.agentuse---model: anthropic:claude-sonnet-4-5mcpServers: database: command: "node" args: ["./database-server.js"] # Relative to parent.agentuse locationsubagents: - path: ./child.agentuse---# child.agentuse---model: anthropic:claude-haiku-4-5mcpServers: # Child defines its own MCP servers filesystem: command: "npx" args: ["@modelcontextprotocol/server-filesystem"] custom: command: "../tools/my-server" # Relative to child.agentuse location---
MCP server commands with relative paths are resolved from the agent file’s directory, ensuring consistent behavior across different execution contexts.
Each sub-agent manages its own MCP connections and tools. They don’t automatically inherit parent tools.
# support-system.agentuse---model: anthropic:claude-sonnet-4-5subagents: - path: ./agents/ticket-classifier.agentuse - path: ./agents/knowledge-base.agentuse - path: ./agents/escalation-handler.agentuse---You manage customer support requests.## Workflow1. Call ticket_classifier tool to categorize the issue2. Call knowledge_base tool to find solutions3. If unresolved, call escalation_handler toolEach tool returns structured output you can use to make decisions.
Copy
# ticket-classifier.agentuse---model: anthropic:claude-haiku-4-5---Classify support tickets into categories:- Technical issue- Billing question- Feature request- General inquiry
# Optimize model usage---model: anthropic:claude-sonnet-4-5 # Smart coordinatorsubagents: - path: ./simple-task.agentuse # Can use claude-3-5-haiku-latest - path: ./complex-task.agentuse # Can use anthropic:claude-opus-4-5---