What you need to know
Decomposition is how a large task becomes a set of smaller ones. The exam asks you to choose between two families.
| Fixed sequential pipeline (prompt chaining) | Dynamic, adaptive decomposition | |
|---|---|---|
| Shape | The same steps in the same order every time | The next subtask is chosen from what the last one found |
| Fits | Predictable, multi-aspect work: a review that always checks the same five things | Open-ended investigation: an incident, an unknown codebase |
| Strength | Cheap, testable, easy to debug | Handles what nobody anticipated |
| Weakness | Cannot react to surprises | Harder to predict cost and time |
Prompt chaining
A chain passes each step's output into the next. A code review chain might be: analyse each file on its own, then run one cross-file pass that checks how the files fit together. Each prompt is small and focused, and you can add a gate between steps: for example, if linting finds severe problems, skip type checks and go straight to the summary.
Splitting large reviews
A single prompt asked to review 20 files at once suffers attention dilution: some files get careful attention, others a skim, and findings can contradict each other. The fix is two kinds of pass:
- Per-file local passes, one file at a time, for local issues.
- A separate integration pass for cross-file concerns: data flow, interface mismatches, duplicated logic.
Adaptive investigation plans
Some tasks cannot be planned up front. "Add comprehensive tests to a legacy codebase" with no further detail is an example. A good decomposition does not start writing tests; it:
- Maps the structure: modules, entry points, dependencies, existing coverage.
- Identifies high-impact areas: code that changes often, handles money, or has no tests.
- Creates a prioritised plan, then adapts it as dependencies and surprises are discovered.
In the exam
Most stems describe a task and ask which decomposition fits, or describe a large review with inconsistent findings. Match predictable work to chaining, open-ended work to adaptive plans, and many-file reviews to per-file plus integration passes.
Check your understanding
A team must review security, naming, error handling, tests and docs on every pull request. Which decomposition fits?
Show answer
Answer: B. The checks are the same every time, so a fixed sequential chain is cheaper, predictable and easy to test.
Reviews of 25-file pull requests miss issues in some files and contradict themselves. What should change?
Show answer
Answer: A. Per-file passes give every file full attention; the integration pass handles cross-file concerns. That removes dilution and the contradictions it causes.
An agent is told to "add comprehensive tests" to a legacy codebase with no further detail. What should it do first?
Show answer
Answer: D. Open-ended work needs mapping first: structure, dependencies, coverage and risk. The prioritised plan then adapts as the agent learns more.
Apply it: Plan Lakeshore's pricing tests
An engineer asks Lakeshore's agent to "add tests to the pricing module". Coverage is about 9% and nobody knows the dependencies. Write the agent's decomposition.
- Choose the decomposition family and justify it in two sentences.
- Write the mapping phase. List what the agent must find out before writing any test.
- Write the prioritisation rule that turns the map into an ordered plan.
- Say how the plan adapts when the agent discovers that pricing depends on a currency service nobody mentioned.
Show model answer
1. Family. Dynamic, adaptive decomposition. The work is open-ended and the right first test depends on what the map reveals, so a fixed chain would guess.
2. Mapping phase
- Entry points of the pricing module and who calls them (Grep for the public classes).
- Its dependencies: other modules, services, the database.
- Existing tests and what they cover.
- Change frequency from version history, and any open bugs tagged pricing.
3. Prioritisation. Score each unit by impact (money calculated, number of callers) times risk (no tests, frequent changes, open bugs). Plan tests from the highest score down, starting with pure calculation code that needs no external services.
4. Adapting. When the currency service appears, the agent adds a subtask: find how pricing calls it and whether a test double already exists. Units that depend on it move behind the creation of that double; units that do not keep their place. The plan is updated and shown to the engineer before continuing.