Task Decomposition
Two ways to decompose (design guidance, from Anthropic's published agent patterns)
| Fixed pipeline (workflow) | Dynamic decomposition (agent) | |
|---|---|---|
| Who decides the steps | Your code | The model, as it goes |
| Fits | Predictable tasks with known stages | Open-ended tasks where the next step depends on what is found |
| Predictability and cost | Higher and lower | Lower and higher |
Common workflow patterns: prompt chaining (sequential steps, optional gates between them), routing (classify, then send to a specialised path), parallelisation (independent subtasks, or the same task several times), orchestrator-workers (a coordinator splits dynamically and delegates), evaluator-optimizer (generate, critique, revise).
Prefer the simplest design that works: a single well-prompted call, then a workflow, then an agent.
Decomposing large reviews (design guidance)
For a large change set, review in two kinds of passes:
- Per-unit pass: each file (or module) analysed on its own with a focused prompt, so attention is not diluted across many files.
- Cross-unit pass: a separate pass for interactions between units (shared interfaces, data flow, duplicated logic).
One giant prompt over everything tends to give shallow, inconsistent feedback.
Choosing granularity
- Too coarse: context overload, missed details.
- Too fine: coordination overhead, lost cross-cutting issues, higher cost.
- Make subtasks independent and verifiable where you can, so they can run in parallel and be checked.
Exam traps
- Reaching for a dynamic agent when the steps are fixed.
- A single mega-prompt for a multi-file task.
- Per-file passes only, which miss cross-file problems.
- Decomposing without a plan for merging results.
References
- Subagents in the SDK — checked Oct 16, 2026
Check your understanding
Invoice processing with fixed stages: workflow or agent?Show answerHide answer
Answer
Workflow.A 30-file pull request needs review. Structure?Show answerHide answer
Answer
Per-file passes, then a cross-file integration pass.Why not always use an agent?Show answerHide answer
Answer
More cost, latency and unpredictability for no benefit when steps are known.