ISLAM-PO's picture
Add context engineering toolkit (Units 1-5)
b4c665d verified
|
Raw History Blame Contribute Delete
2.08 kB
# 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)