6.2.4 · D3AI Agents & Tool Use

Worked examples — Planning and task decomposition

2,278 words10 min readBack to topic

This page is the "throw everything at it" companion to Planning and task decomposition. Before we work examples, let's list every kind of situation a planning problem can throw at you, so that no scenario surprises you later.

Two ideas from the parent note power everything below. Let us re-earn them in plain words:

The one formula we lean on (parent note, re-stated):


The scenario matrix

Every planning problem this chapter can pose falls into one of these cells. The examples afterward each announce which cell they cover.

# Case class What makes it special Covered by
A Independent split ( clean pieces) subgoals share no data → full speedup Ex 1
B Degenerate "decomposition" that splits nothing Ex 2
C Extreme one subgoal per step → over-splitting Ex 3
D Dependent chain (backward chaining) step B needs step A's output Ex 4
E Mixed DAG (parallel + serial) some independent, some dependent Ex 5
F Failure + replanning a branch dies, retry only that branch Ex 6
G Real-world word problem pick strategy + count savings Ex 7
H Exam twist: is splitting worth it? overhead per step beats raw path count Ex 8

The examples below hit every cell A–H.


Example 1 — Cell A: the clean independent split

Forecast: guess now — will the improvement be a small factor like , or something dramatic?

  1. Naive cost. With no split, count all routes of depth 6: . Why this step? This is the baseline — every complete path explored.
  2. Depth per subgoal. Each of the 3 subgoals is only steps deep. Why this step? Independence means we never need one subgoal's later steps while solving another; each is a shorter, self-contained search.
  3. Cost per subgoal. routes. Why this step? Same rule, but now with the smaller depth 2.
  4. Total decomposed cost. Pay that 3 times: . Why this step? We solve 3 separate small searches, not one big one.
  5. Speedup. .
Figure — Planning and task decomposition

Verify: the general formula . Matches . ✓ The savings are dramatic, not linear — the exponent collapsed from 6 to 4.


Example 2 — Cell B: the degenerate

Forecast: should the decomposed cost equal the naive cost exactly, or differ?

  1. Plug . . Why this step? A single "piece" of full depth 6 is just the original problem.
  2. Speedup. . Why this step? kills the exponent, so speedup : no gain.

Verify: decomposed cost equals naive ; speedup exactly . ✓ The formula degrades gracefully — is a no-op, exactly as intuition demands.


Example 3 — Cell C: the extreme (over-splitting the math)

Forecast: does making every step its own subgoal give the biggest possible speedup?

  1. Depth per subgoal. . Each subgoal is a single action. Why this step? Maximal splitting means each piece is one step deep.
  2. Cost. . Why this step? Six one-step searches of 10 options each.
  3. Speedup vs naive. .

Verify: . Matches . ✓


Example 4 — Cell D: a dependent chain (backward chaining)

Forecast: will a 2-hop dependent chain of options behave like independent split (cost ) or like a chain (cost but forced serial)?

  1. Backward chain from the goal. Goal "Grammy AotY winner in year ". This needs first. Why this step? Reasoning must respect what depends on what — you cannot search step 2 before step 1 resolves.
  2. Resolve . search("1989 Taylor Swift release year"). Why this step? This is the precondition of the final query.
  3. Resolve winner. search("Grammy Album of the Year 2015")Morning Phase by Beck (2015 ceremony honours 2014 albums). Why this step? Now that is known, the second hop is well-posed.
  4. Cost structure. Two hops, each ~ candidate queries: tries, but they are serial — the second cannot start early. Why this step? Dependency forbids parallelism; you still avoid because you never combinatorially pair every hop-1 with every hop-2.
Figure — Planning and task decomposition

Verify: naive joint search ; chained search ; ratio . A real speedup, but only , far below Example 1's — because dependency forbids independent multiplication. ✓ Answer to the trivia: Beck.


Example 5 — Cell E: mixed DAG (parallel + serial)

Forecast: with 5 tasks, does the agent need 5 serial rounds, or fewer?

  1. Build the dependency graph (DAG). Edges: , , , . Why this step? A multi-agent/parallel scheduler needs to know which arrows point where before it can run anything.
  2. Topological sort into layers.
    • Layer 1: (no incoming edges).
    • Layer 2: (their inputs are ready).
    • Layer 3: . Why this step? Tasks in the same layer share no dependency, so they run at once.
  3. Critical path. Longest chain is (length 3). That's the minimum number of serial rounds. Why this step? You can never finish faster than the longest dependency chain.
Figure — Planning and task decomposition

Verify: 5 tasks, but only serial rounds. Serial-everything would take rounds → parallelism saves rounds. ✓ Layer sizes = total task count (no task lost or duplicated). ✓


Example 6 — Cell F: failure and localized replanning

Forecast: how much work does backtracking save here — a little, or most of it?

  1. Restart-from-scratch cost. Redo everything: (already done!) plus = units. Why this step? Naive agents with no memory re-execute succeeded steps. Wasteful.
  2. Replan-from-failure cost. Keep outputs (this is where agent memory earns its keep), regenerate only from onward with an alternative method: = units. Why this step? Failure isolation means only the broken branch is redone.
  3. Saved work. units, i.e. the two already-completed steps are not repeated.

Verify: restart , replan , saving ; saving fraction = 40% less work. ✓


Example 7 — Cell G: real-world word problem (pick the strategy + count)

Forecast: independent fetches → do we get the multiplicative blow-up, or the additive savings?

  1. Identify independence. The 3 fetch sources don't depend on each other → this is Cell A structure with . Why this step? Correctly labelling independence is what unlocks the additive (not multiplicative) cost.
  2. Naive joint search. Treating all three fetches as one depth- search with : . Why this step? This is the "explore every combination of every source's every endpoint" trap.
  3. Decomposed search. . Why this step? Each independent fetch is its own depth-2 search; solve, then move on.
  4. Then serial tail. Parse and plot are one dependent chain after the fetches — cheap, unaffected by the split.

Verify: speedup ; and formula . ✓ Decomposition helps enormously → use it.


Example 8 — Cell H: exam twist ("but is it actually worth it?")

Forecast: the exponent math from Ex 3 loved — will overhead overturn that?

  1. Cost model. , with . Why this step? Real agents pay per step, so we add once per subgoal — the piece the pure path-count formula ignored.
  2. : paths , overhead → total .
  3. : paths , overhead → total .
  4. : paths , overhead → total . Why this step? Beyond the shrinking path count can't outrun the growing overhead.
  5. Winner. () beats both () and ().
Figure — Planning and task decomposition

Verify: min over is at . ✓ This is the quantitative face of the parent's "over-decomposing" mistake: the sweet spot is interior, not .


Recall Quick self-test

Cloze the pattern, then reveal:

Decomposed path cost for independent subgoals ::: Speedup vs naive ::: Why gives speedup ::: the exponent becomes , so — no split, no gain What Example 8 adds that the pure formula omits ::: per-subgoal overhead , which makes very large expensive Why a dependent chain (Ex 4) beats naive by only a small factor ::: dependency forbids independent multiplication, so cost is additive not divided-exponent

See also: 6.2.01-Tool-augmented-LMs · 5.3.02-Chain-of-thought-prompting · back to Planning and task decomposition.