1.6 Task Decomposition Strategies
What You Need to Know
Section titled “What You Need to Know”Task decomposition is how you break complex work into pieces an agentic system can actually handle. The exam tests two patterns and expects you to pick the right one for the task in front of you. Pick wrong and the work suffers in predictable ways. It also tests one specific failure mode — attention dilution — that shows up when decomposition is too shallow.
Pattern 1: Fixed Sequential Pipelines (Prompt Chaining)
Section titled “Pattern 1: Fixed Sequential Pipelines (Prompt Chaining)”Fixed sequential pipelines break work into predetermined steps that execute in order. Each step takes the output of the previous step as input.
How it works: The workflow is defined in advance. Step 1 runs, its output feeds into Step 2, Step 2’s output feeds into Step 3, and so on. The sequence does not change based on intermediate results.
Example — Code review pipeline:
- For each file, run a local analysis pass (style, bugs, complexity).
- After all local passes, run a cross-file integration pass (data flow, API consistency, import chains).
- Compile results into a unified review report.
Best for: Predictable, structured tasks where the steps are known in advance. Code reviews, document processing, data extraction pipelines, and compliance checks all fit this pattern.
Advantages: Consistent and reliable. The same input always follows the same path. Easy to debug — you know exactly which step produced which output. Easy to monitor — you can log the output of each step.
Limitations: Cannot adapt to unexpected findings. If Step 2 discovers something that should change the approach for Step 3, the pipeline can’t adjust. The steps are fixed regardless of what turns up along the way.
Pattern 2: Dynamic Adaptive Decomposition
Section titled “Pattern 2: Dynamic Adaptive Decomposition”Dynamic adaptive decomposition generates subtasks based on what is discovered at each step. The plan evolves as the agent learns more about the problem.
How it works: The agent starts with a high-level goal, performs initial investigation, and generates a plan based on what it finds. As it executes the plan, it discovers new information that may change the remaining steps. The agent adapts the plan accordingly.
Example — Adding tests to a legacy codebase:
- Map the codebase structure (directories, modules, dependencies).
- Identify high-impact areas (most-used modules, modules with the most bugs, untested critical paths).
- Create a prioritised test plan based on the mapping.
- Start writing tests. Discover that Module A depends on Module B, which has no tests.
- Reprioritise: test Module B first so Module A’s tests can rely on it.
- Continue adapting as new dependencies and issues emerge.
Best for: Open-ended investigation tasks where the full scope is not known at the start. Legacy system exploration, security audits, research projects, and debugging unfamiliar codebases all benefit from this pattern.
Advantages: Adapts to the problem. Can discover and respond to unexpected complexity. Produces more thorough results for open-ended tasks because it does not force-fit a predetermined plan.
Limitations: Less predictable. Execution time varies depending on what is discovered. Harder to estimate completion time or resource usage. More difficult to debug when things go wrong.
Selecting the Right Pattern
Section titled “Selecting the Right Pattern”The exam tests your ability to match the pattern to the task:
| Task Characteristics | Pattern | Reasoning |
|---|---|---|
| Steps known in advance, structured input | Fixed pipeline | Consistency and reliability outweigh adaptability |
| Open-ended, unknown scope | Dynamic decomposition | Adaptability is essential when the problem is not fully defined |
| Multi-file code review | Fixed pipeline | Per-file analysis + cross-file integration is predictable |
| Legacy codebase exploration | Dynamic decomposition | Dependencies and issues emerge during investigation |
| Document extraction | Fixed pipeline | Fields and format are predetermined |
| Debugging an unfamiliar system | Dynamic decomposition | Root cause is unknown; investigation must adapt |
The Attention Dilution Problem
Section titled “The Attention Dilution Problem”Attention dilution is a specific failure mode that occurs when an agent processes too many items in a single pass. The result is inconsistent depth — the agent produces thorough analysis for some items and misses obvious issues in others.
The telltale symptoms:
- Detailed feedback for the first few files, increasingly shallow analysis for later files.
- A pattern flagged as problematic in one file while identical code is approved in another file.
- Obvious bugs missed in some files while minor style issues are caught in others.
Why it happens: The model allocates attention across all items in the context. When there are too many items, attention per item decreases. Early items get disproportionate attention; later items get skimmed.
The fix: Multi-pass architecture. Split the work into two layers:
- Per-item local analysis passes: analyse each file (or document, or module) individually in its own pass. Each pass has the full attention budget focused on a single item.
- Cross-item integration pass: after all local passes complete, run a separate pass that looks across all items for cross-cutting concerns (data flow issues, inconsistent pattern usage, cross-file dependencies).
The per-item passes catch local issues consistently because each item gets dedicated attention. The integration pass catches cross-item issues because it focuses specifically on relationships between items rather than trying to do everything at once.
Practical Example: The 14-File Code Review
Section titled “Practical Example: The 14-File Code Review”A code review agent processes 14 files in a single pass. The results:
- Files 1-5: detailed feedback with specific line references, bug identification, and improvement suggestions.
- Files 6-9: moderate feedback with some issues identified but less thorough analysis.
- Files 10-14: superficial feedback that misses obvious null pointer bugs and SQL injection vulnerabilities.
- A
forEachloop flagged as inefficient in File 3, while identical code in File 11 receives no comment.
This is attention dilution. The fix is not a better model, a larger context window, or a more detailed prompt. The fix is structural: split into 14 per-file analysis passes (each focused on one file) plus a cross-file integration pass (checking for data flow issues and pattern consistency across all files).
The multi-pass approach catches the null pointer bugs in Files 10-14 (because each file gets its own dedicated pass) and identifies the inconsistent forEach evaluation (because the integration pass specifically checks for cross-file pattern consistency).
Exam Traps
Section titled “Exam Traps”Practice Scenario
Section titled “Practice Scenario”A code review agent processes 14 files and produces detailed feedback for the first 5 files but misses obvious bugs in files 10-14. It also flags a forEach loop as inefficient in one file while approving identical code in another. What is the root cause and the most appropriate solution?
- A. The model context window is too small to hold all 14 files — upgrade to a model with a larger context window
- B. Split the review into per-file local analysis passes plus a separate cross-file integration pass to avoid attention dilution
- C. Add a stronger system prompt emphasising the importance of reviewing all files with equal thoroughness
- D. Reduce the number of files per review to 5 and process in sequential batches of 5 files each
Answer & explanation
Correct: B
- A — Context window size is not the issue. Attention dilution occurs because processing too many items in a single pass produces inconsistent depth, regardless of how much context the model can hold. A larger window does not fix uneven attention allocation.
- B — Multi-pass architecture solves attention dilution. Per-file passes ensure each file receives dedicated, consistent analysis. The cross-file integration pass catches data flow issues and pattern inconsistencies. This addresses both symptoms: missed bugs in later files and contradictory pattern evaluation.
- C — Prompt improvements do not solve attention dilution. The fundamental issue is processing too many items in a single pass, which is an architectural problem requiring a structural solution, not a prompting solution.
- D — Batching is closer to the right idea and solves within-batch attention dilution, but it misses cross-batch issues. Without a separate cross-file integration pass, data flow issues between batches and pattern consistency across all 14 files are not addressed.
Sources
Section titled “Sources”- Claude Agent SDK Overview — Anthropic
- Claude Code in Action (Skilljar) — Anthropic
- Anthropic Prompt Engineering Guide — Anthropic
Exam Simulator
Section titled “Exam Simulator”Five exam-style multiple-choice questions on Task Decomposition Strategies. Pick an answer, then open the explanation.
Question 1
Section titled “Question 1”A code review agent processes 14 files and produces detailed feedback for the first 5 files but misses obvious bugs in files 10-14. It also flags a forEach loop as inefficient in one file while approving identical code in another. What is the root cause and the most appropriate solution?
- A. The model’s context window is too small to hold all 14 files — upgrade to a model with a larger context window
- B. Split the review into per-file local analysis passes plus a separate cross-file integration pass to avoid attention dilution
- C. Add a stronger system prompt emphasising the importance of reviewing all files with equal thoroughness
- D. Reduce the number of files per review to 5 and process in sequential batches of 5 files each
Answer & explanation
Correct: B
- B is correct because multi-pass architecture solves attention dilution. Per-file passes ensure each file receives dedicated, consistent analysis. The cross-file integration pass catches data flow issues and pattern inconsistencies. This addresses both symptoms: missed bugs in later files and contradictory pattern evaluation.
- A is wrong because context window size is not the issue. Attention dilution occurs because processing too many items in a single pass produces inconsistent depth, regardless of how much context the model can hold.
- C is wrong because prompt improvements do not solve attention dilution. The fundamental issue is processing too many items in a single pass, which is an architectural problem requiring a structural solution.
- D is wrong because batching solves within-batch attention dilution but misses cross-batch issues. Without a separate cross-file integration pass, data flow issues between batches and pattern consistency across all 14 files are not addressed.
Question 2
Section titled “Question 2”A team needs to add tests to a legacy codebase with undocumented dependencies. Which task decomposition pattern is most appropriate?
- A. Dynamic adaptive decomposition: map the structure, discover dependencies, reprioritise as new complexity emerges
- B. Fixed sequential pipeline: analyse each module, write tests, run tests, report results
- C. Fixed sequential pipeline with a larger context window to handle the complexity
- D. Process each module independently without any decomposition strategy
Answer & explanation
Correct: A
- A is correct because adding tests to a legacy codebase with undocumented dependencies is an open-ended investigation task. The full scope is not known at the start — dependencies emerge during investigation. Dynamic decomposition adapts the plan as new information is discovered.
- B is wrong because a fixed pipeline assumes the steps are known in advance. With undocumented dependencies, the agent cannot predetermine which modules to test first. It may discover Module A depends on Module B, requiring a plan change.
- C is wrong because context window size does not address the need for adaptability. The issue is that the plan must evolve based on discoveries, not that the model cannot hold enough data.
- D is wrong because independent module processing ignores dependencies. Tests for Module A may fail if Module B (a dependency) has no tests. Some coordination strategy is required.
Question 3
Section titled “Question 3”Which of the following tasks is best suited for a fixed sequential pipeline (prompt chaining)?
- A. Investigating the root cause of an intermittent production bug
- B. Exploring a competitor’s product features for a market analysis
- C. Conducting a security audit of an unfamiliar system
- D. Extracting structured data from invoices with a known format
Answer & explanation
Correct: D
- D is correct because invoice data extraction has a known structure: the fields and format are predetermined. The steps are predictable: read invoice, extract fields, validate format, output structured data. Fixed pipelines are ideal for structured, predictable tasks.
- A is wrong because root cause investigation is open-ended. The cause is unknown, and the investigation must adapt as clues emerge. Dynamic decomposition is more appropriate.
- B is wrong because market analysis involves discovering unknown information. The scope of competitor features is not fully known in advance, making dynamic decomposition more suitable.
- C is wrong because security audits of unfamiliar systems require exploration and adaptation. Vulnerabilities may reveal additional attack surfaces that change the investigation plan.
Question 4
Section titled “Question 4”What distinguishes attention dilution from a model capability limitation?
- A. Attention dilution occurs only with small models; large models do not experience it
- B. Attention dilution is caused by insufficient context window size
- C. Dilution varies depth, while capability limits are uniformly bad
- D. Attention dilution only affects code review tasks, not other types of analysis
Answer & explanation
Correct: C
- C is correct because attention dilution is characterised by inconsistency: thorough analysis for some items, superficial for others, and contradictory evaluation of identical patterns. A capability limitation would produce consistently poor results across all items. The inconsistency is the telltale sign.
- A is wrong because attention dilution affects models regardless of size. It is a structural issue of processing too many items in a single pass, not a model power issue.
- B is wrong because attention dilution is about attention allocation, not context window size. A larger context window does not fix uneven attention distribution.
- D is wrong because attention dilution can occur in any task where too many items are processed in a single pass: code reviews, document analysis, data validation, and more.
Question 5
Section titled “Question 5”A developer batches 14 files into groups of 5 for review but does not include a cross-file integration pass. Which issues will this approach miss?
- A. Cross-file data flow issues and pattern inconsistencies between files in different batches
- B. Bugs within individual files — batching does not help with local analysis
- C. Performance bottlenecks introduced by processing the files in batches rather than in a single pass
- D. Formatting inconsistencies inside individual files that the batch boundaries happen to split apart
Answer & explanation
Correct: A
- A is correct because batching solves attention dilution within each batch but does not address cross-batch issues. Without a dedicated cross-file integration pass, data flow issues between modules in different batches and contradictory pattern evaluation across batches go undetected.
- B is wrong because batching actually improves local analysis by giving each batch a more focused attention budget. Per-file or per-batch analysis catches local issues better than a single pass.
- C is wrong because the question asks about review quality, not performance. Batching may actually improve throughput by reducing per-pass load.
- D is wrong because formatting inconsistencies within files are local issues that batching handles adequately. The missed issues are specifically cross-file concerns.