Sub-Agent Complete Guide: From Basics to Pitfalls in 5 Minutes
· 4 min read
Core takeaways from the official Multi Sub-Agent Recommendations and Use Cases, for quick reference and decision-making.
Created: 2026-03-09
Last revised: 2026-03-09
30-Second Overview
- What is Sub-Agent: Offload long tasks to child sessions; the main session responds immediately; child tasks report back via announce when done
- When to use: Long tasks, parallel processing, cost layering, session isolation → use Sub-Agent; few types, small batches, prioritize lower ops → consider single Agent + Skills
- Relation to Skills: Complementary, not either/or; Sub-Agent handles session and execution, Skills handle capability and orchestration
- Key config:
model(cheaper model saves cost),runTimeoutSeconds(300–900),maxSpawnDepth(recommend 2) - Must-know limits: announce is best-effort; child Agent only gets AGENTS.md + TOOLS.md; timeout ≠ archive
Quick Decision Tree
Check this table before choosing Sub-Agent vs Skills:
| Your need | Better approach |
|---|---|
| Multi-source, multi-type, batch processing; main session needs fast response and parallel extraction | Main Agent + multiple Sub-Agents |
| Few types, single/small batch, latency-insensitive, prioritize lower ops | Single Agent + multiple Skills |
| Validate flow before adopting Sub-Agent | Single Agent + Skills first → then split by type into Sub-Agents |
1. Official Positioning (One Sentence)
Sub-Agent is the standard way to "offload long tasks and keep the main session responsive": Heavy work is delegated to child sessions; the main session gets immediate feedback; when child tasks finish, summaries are sent back via announce; you can configure cheaper models for child agents to control cost.
2. Recommended vs Not Recommended
| Recommended for Sub-Agent | Not recommended as replacement |
|---|---|
| Long / heavy tasks | Using "single Agent + multiple Skills" instead of Sub-Agent |
| Dispatching by task type (bidding, enterprise, policy, etc.) | Skills do not provide independent sessions, async callback, or parallel child tasks |
| Need parallel execution, higher throughput | |
| Cost layering (strong model for orchestration, cheaper model for execution) | |
| Session and context isolation |
3. Sub-Agent vs Skills
| Layer | Responsibility |
|---|---|
| Sub-Agent | Session and execution isolation: independent session, async announce, parallel child tasks, configurable cheaper model |
| Skills | Capability description and orchestration: teach Agent when and how to use tools and flows |
Complementary, not either/or: Main Agent and Sub-Agents can all mount Skills; the main Agent dispatches and aggregates; Sub-Agents execute specific logic per Skill in their own sessions.
4. Core Config Parameters Quick Reference
4.1 Global defaults agents.defaults.subagents
| Parameter | Purpose | Suggestion |
|---|---|---|
| model | Default model for child tasks | Set to a cheaper model to save cost |
| runTimeoutSeconds | Child task timeout (seconds) | 300–900 recommended, avoid infinite hangs |
| maxChildrenPerAgent | Max active child sessions per session | Default 5, range 1–20 |
| maxConcurrent | Global subagent concurrency limit | Default 8 |
| archiveAfterMinutes | Auto-archive time for child sessions | Default 60 minutes |
| maxSpawnDepth | Nesting depth | Recommend 2 (main → orchestrator → leaf) |
Minimal example:
agents:
defaults:
subagents:
model: "gpt-4o-mini" # cheaper model for child tasks
runTimeoutSeconds: 600 # 10 min timeout
maxSpawnDepth: 2
4.2 Cross-Agent dispatch permission
- Configure
allowAgents: ["main-agent-id"]on the child Agent being dispatched - Main Agent does not need to "register" a dispatch list; permission is declared only on the child Agent side
4.3 sessions_spawn tool essentials
- Non-blocking: Call returns immediately with
{ status: "accepted", runId, childSessionKey } - Callback: Child task reports back via announce when done (best-effort; may be lost on Gateway restart)
- Required:
task; optional:agentId,model,runTimeoutSeconds,cleanup, etc.
5. Important Limits and Boundaries
- announce is best-effort: For critical results, have the main Agent use
sessions_historyor transcript for a second fetch - Child Agent context: Only AGENTS.md + TOOLS.md are injected (no SOUL, IDENTITY, USER, etc.)
- runTimeoutSeconds: Only stops execution, does not auto-archive; archiving is controlled by
archiveAfterMinutesorcleanup: "delete"
6. Common Pitfalls
| Pitfall | Description | Mitigation |
|---|---|---|
| announce lost | Best-effort callback may be lost on Gateway restart | Use sessions_history or transcript for critical results |
| Incomplete child Agent context | Only AGENTS.md + TOOLS.md injected, no SOUL, IDENTITY, USER | Put required info explicitly in task |
| Timeout ≠ archive | runTimeoutSeconds only stops run, does not delete session | Use archiveAfterMinutes or cleanup: "delete" for archiving |
| Wrong permission config | Main Agent dispatch fails | Configure allowAgents: ["main-agent-id"] on the child Agent being dispatched |
7. Selection Quick Reference (with Typical Scenarios)
| Need | Typical scenario | Better approach |
|---|---|---|
| Multi-source, multi-type, batch; main session needs fast response, parallel extraction | Multi-source bidding extraction, enterprise info batch collection | Main Agent + multiple Sub-Agents |
| Few types, single/small batch, latency-insensitive, prioritize lower ops | Single-doc Q&A, simple classification | Single Agent + multiple Skills |
| Validate flow before Sub-Agent | Building from scratch | Single Agent + Skills first → then split by type into Sub-Agents |
8. References and Next Steps
- Full version: Multi Sub-Agent Official Recommendations and Use Cases — after this quick guide, read the full version for design details and more scenarios
- Official docs: Sub-Agents, Configuration Reference