File size: 2,082 Bytes
b4c665d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | # Subagent Configurations (Unit 4)
This directory demonstrates subagent patterns: fan-out/fan-in, pipeline, supervisor, and swarm.
## Fan-out / Fan-in Pattern
A parent agent distributes independent tasks to child agents that run in parallel,
then aggregates their results.
```json
{
"pattern": "fan-out-fan-in",
"parent": "research-orchestrator",
"subagents": [
{
"name": "backend-researcher",
"task": "Summarize backend architecture from docs/backend/",
"tools": ["read_file", "search"],
"isolation": "worktree"
},
{
"name": "frontend-researcher",
"task": "Summarize frontend architecture from docs/frontend/",
"tools": ["read_file", "search"],
"isolation": "worktree"
},
{
"name": "database-researcher",
"task": "Summarize database schema from docs/db/",
"tools": ["read_file", "search"],
"isolation": "worktree"
}
],
"aggregation": "combine-summaries"
}
```
## Pipeline Pattern
Sequential stages where each subagent's output feeds the next.
```json
{
"pattern": "pipeline",
"stages": [
{ "name": "design", "agent": "api-designer", "task": "Design REST API schema" },
{ "name": "implement", "agent": "code-writer", "task": "Implement API from schema", "depends_on": "design" },
{ "name": "test", "agent": "test-writer", "task": "Write tests for API", "depends_on": "implement" }
]
}
```
## Supervisor Pattern
A parent agent orchestrates, reviews, and decides next steps.
```json
{
"pattern": "supervisor",
"supervisor": "tech-lead",
"workers": ["implementer", "reviewer", "tester"],
"review_loop": true,
"max_iterations": 3
}
```
## When to Use Subagents
- Read 10+ files → fan-out
- 3+ independent tasks → parallel
- Need unbiased review → isolated verifier
- Sequential stages → pipeline
- Complex orchestration → supervisor
## When NOT to Use
- Sequential dependent work (B needs A's output)
- Same-file parallel edits (git conflicts)
- Small quick tasks (spawn overhead)
- More than 5 specialists (coordination chaos)
|