A supervisor agent plans subtasks, dispatches them to specialized workers, reviews each worker's output for quality, and retries with feedback if the result is inadequate. Implements a research workflow with search, analysis, and summary workers.
- Research tasks: Gather information, analyze it, and produce a summary
- Quality-critical workflows: When outputs must meet a quality bar before proceeding
- Complex queries: Tasks that benefit from decomposition into smaller subtasks
graph LR
Input[User Input] --> Supervisor[Supervisor<br/>planner + reviewer]
Supervisor -->|plan| Search[Search]
Search -->|review| Supervisor
Supervisor -->|plan| Analysis[Analysis]
Analysis -->|review| Supervisor
Supervisor -->|plan| Summary[Summary]
Summary -->|review| Supervisor
Supervisor --> Output[Final Output]
- Supervisor plans: Given the user's input, the supervisor generates a JSON plan with ordered subtasks, each assigned to a worker
- Worker execution: Each subtask is dispatched to its assigned worker. Workers receive the instruction plus context from previous workers
- Quality review: After each worker completes, the supervisor reviews the output and returns an
adequateboolean plus feedback - Retry loop: If output is inadequate, the worker retries with the supervisor's feedback appended to its instructions (up to 3 attempts)
- Final output: The last worker's accepted output becomes the pattern's result
agent_start {agent: "supervisor", role: "planner"}
chunk {agent: "supervisor", content: "Plan: search -> analysis -> summary"}
agent_end {agent: "supervisor", ...}
handoff {from: "supervisor", to: "search", reason: "Dispatching search task"}
agent_start {agent: "search", role: "information gatherer"}
chunk {agent: "search", content: "...findings..."}
agent_end {agent: "search", ...}
handoff {from: "search", to: "supervisor", reason: "Reviewing search output"}
agent_start {agent: "supervisor", role: "reviewer"}
chunk {agent: "supervisor", content: "Review of search: adequate. ..."}
agent_end {agent: "supervisor", ...}
handoff {from: "supervisor", to: "analysis", reason: "Dispatching analysis task"}
...
done {totalUsage: {...}}
| Worker | Role | Purpose |
|---|---|---|
search |
information gatherer | Finds facts, data, and sources |
analysis |
analyst | Identifies patterns, compares perspectives, draws insights |
summary |
summarizer | Produces clear, comprehensive reports |
- Quality assurance: Review loop catches poor outputs before they propagate
- Adaptive: Retry with feedback often produces better results on the second attempt
- Transparent: Each planning and review step is visible in the trace
- Higher latency: Review adds an LLM call after every worker, and retries multiply cost
- Max 3 iterations: The retry cap prevents infinite loops but may stop before quality is reached
- Planning reliability: The supervisor must produce valid JSON plans; malformed output causes errors