Task decomposition and plan repair
medium 7 minPlanning separates a goal into work with preconditions and dependencies.
Video lesson · Chapter 1 of 4
A hold fails halfway through
Theory
Read or listen first. About 2 min.
What it is
Planning separates a goal into work with preconditions and dependencies. Execution changes the environment, which can invalidate the remainder of a previously sensible plan. A typed outcome lets the planner distinguish success, conflict, delay and denial.
Why it exists
When one step fails, identify its dependents and preserve valid completed work. A stale availability check should invalidate a reservation attempt, while an unrelated confirmed preference can remain in state.
Repair only the part of a booking plan that failed
Inside this chapter
Chapter sources- Why Planning Is Hard
- A plan is made with incomplete information, and the environment can change between planning and execution. An itinerary may stop being feasible when a connection closes. Represent dependencies explicitly and recheck critical preconditions at execution time before committing an irreversible action.
A plan is a bet made with what you knew at planning time, and the world keeps moving. The fix is not a smarter planner but explicit dependencies plus rechecks: any step that commits something hard to undo should re-verify its preconditions just before acting. Then a stale plan fails cheaply at the check rather than expensively at the effect.
Example. Room A is available when the plan is drafted and unavailable at commit time. The executor must recheck the precondition.
A precondition that changed before commit
The executor rechecks the critical precondition at commit time instead of trusting the planning-time answer. - Task Decomposition
- Decompose a goal into subtasks with concrete inputs, outputs and completion checks. Distinguish work that can proceed independently from work that requires an earlier result. “Find an available room” must produce a room ID and time window before “reserve the room” can run.
Good subtasks have concrete inputs, outputs and a completion check, which makes dependencies obvious: if step B needs a field that only step A produces, B waits. Everything without such a link can run in parallel. Vague subtasks such as "handle the room" hide these dependencies and lead to steps running on missing data.
Example. A hold step returns a token and expiry timestamp. A confirmation step requires both, so it cannot run before the hold succeeds.
Outputs that later steps depend on
Drafting the invite can run in parallel. Confirming cannot start until the hold returns a token and expiry. - Planning Strategies
- A fixed plan is cheap to inspect; incremental planning adapts to discoveries; branching plans reserve alternatives at extra cost. Choose based on uncertainty and cost of reversal. If availability changes rapidly, planning every downstream detail before the first lookup can waste work.
Fixed plans suit stable environments and reviewers who want to approve everything up front. Incremental planning suits fast-changing data, because detail planned before the first lookup may be thrown away. Working backwards from the goal, as with a noon arrival, can cut the search dramatically by only considering connections that could possibly make it.
Example. Work backward from a noon arrival, then inspect which connecting trains could reach it. Compare with expanding every possible outbound departure.
Three ways to plan the same trip
Strategy How it works Strength Cost Fixed plan all steps decided up front cheap to inspect and approve breaks when facts change Incremental plan next step after each result adapts to discoveries harder to preview Branching keep backup options ready fast recovery from failure extra lookups and holds Backward from goal start at noon arrival, work back prunes early needs a clear goal state Choose by uncertainty and how costly a reversal is. - Planner vs Executor Agents
- The planner proposes a dependency structure while the executor checks preconditions and performs authorized steps. Use typed outcomes such as completed, blocked or expired. Returning a free-form success message makes it hard for the planner to tell which part of the plan needs repair.
Splitting planning from execution gives each side a clear job: the planner reasons about structure, the executor enforces preconditions and permissions. The interface between them is the typed outcome. A small fixed set such as completed, blocked, conflict, expired and denied lets the planner pick a repair mechanically, whereas "something went wrong with the booking" forces it to guess.
Example. Make the executor return expired_hold instead of a paragraph. The planner now knows to reacquire a hold instead of confirming the old one.
JSON{ "step": "confirm_booking", "status": "expired_hold", "hold_id": "H-7", "expired_at": "2026-03-02T14:05:00Z", "retryable": false, "needs": "reacquire_hold"}A typed executor outcome. The planner can repair exactly one step instead of parsing a paragraph. - Failure Handling in Plans
- Classify a failure as transient, infeasible or permission-related. A transient read may be retried with a budget. An unavailable resource requires replanning, and missing authorization requires a different decision. Preserve completed work only when its assumptions and external effects still hold.
Retrying is only correct for failures that might go away on their own. A sold-out room will still be sold out on the tenth retry, and a permission denial will not lift because you asked again. Keep completed work only if the assumptions it relied on still hold; a hold made for 14:00 is useless if the replan moves the meeting to 16:00.
Example. Contrast a timeout with a sold-out room. Retry the first within budget and change the resource choice for the second.
Another example. A CI agent sees a network error fetching a package (retry), a version that does not exist (change the pin) and a registry 403 (ask a human for credentials).
Classify the failure before reacting
- Compensation after partial completion
- A plan spanning independent services can stop with some effects already committed. Track which actions have an approved compensation, what can be retried and what needs human intervention.
Across independent services there is no rollback, only compensating actions that each service allows, sometimes with fees or deadlines. Track for every committed effect whether a compensation exists, whether it needs fresh consent and whether it can fail. Tell the user what actually remains in place rather than promising the itinerary was fully undone.
Example. A trip planner reserves a room and then the train sells out. Check the room’s cancellation terms before offering a refund or promising that the whole itinerary was undone.
Unwinding a half-finished trip - 1Room reservedbooking R-55 committed
- 2Train sold outitinerary infeasible
- 3Check room termsfree cancel until 18:00?
- 4Offer optionscancel room, or keep it
- 5Record final statewhat was undone and what was not
A compensating action is a new operation with its own rules and costs, not an undo button.
How it works
Step through the idea, or press Play.
Dependencies. Find room → hold → confirm
Understand it
Worked example
Repair only the part of a booking plan that failed
- 1
Find room → hold → confirm
The hold depends on a specific room and time. Preparing a confirmation in parallel must not commit it before the hold succeeds.
- 2
Room A no longer available
The executor returns a typed conflict. This is an infeasible choice, not merely a slow network response.
- 3
Select room B · retain time window
Keep the validated time constraint while replacing the failed dependent step. Revalidate availability before a new confirmation.
Follow the handoffs
Which steps the conflict invalidates
Plan state before and after repair
| Field | Before failure | After repair |
|---|---|---|
| time_window | 14:00 to 15:00 | 14:00 to 15:00 (kept) |
| room | A | B |
| hold | attempted, conflict | pending recheck |
| confirm | queued for A | queued for B |
Summary
The whole topic in one minute.
A confirmed conflict changes feasibility. Retries are for failures that might change under the same operation.
When one step fails, identify its dependents and preserve valid completed work. A stale availability check should invalidate a reservation attempt, while an unrelated confirmed preference can remain in state.