Exercises

Agentic AI · L-Decomp

Task decomposition by hand, in the order of the lecture: boundaries and checks, the plan as an object, and scheduling and recovery.

The programming exercises are in the lab notebook lecture-Decomp-lab.ipynb.

Part I — Boundaries and Checks

These exercises compute what a check at a step boundary is worth. They use the success probability $p$ of a step, and the detection rate $d$ and the false-positive rate $\phi$ of a check, as the lecture defines them under Step Reliability with Verification.

Exercise 1 — Reliability: Monolithic vs. Decomposed (calculation + concept)

A task needs n = 10 dependent steps; each step succeeds independently with p = 0.9.

  1. A single monolithic attempt is correct only if all steps are right. Compute $P(\text{all correct})$.
  2. The task is decomposed, and a per-step check with detection rate $d = 1$ triggers one retry of a rejected step. Compute the probability of a step (with at most one correction) and the success probability of the chain.
  3. The retry is now repeated until the check accepts. Compute the success probability of one step and the expected number of attempts, and state what the higher reliability costs in model calls.
  4. A real monolithic prompt usually does worse than the answer to part 1. Which assumption of $p^n$ breaks, and why?

Exercise 2 — False Positives at the Boundary (calculation)

The lecture's first formula for a step with a check assumed that the check fires only on a faulty step. Real critics also flag correct work. Keep the same setup — a step succeeds on its own with probability $p$, the check is run once on the first attempt, and a flagged step is redone once as a fresh draw with the same $p$ — but add the false-positive rate $\phi$: the probability that the check flags a step that was actually correct. As before, $d$ is the detection rate: the probability that it flags a step that was actually faulty.

  1. The formula. Which formula of the lecture gives $p'$ for a check with the false-positive rate $\phi$? Show that it reduces to the lecture's formula for a check without false positives when $\phi = 0$.

  2. When is the loop worth running? State the condition on $d$ and $\phi$. Then take $p = 0.9$, $n = 10$ and compute $p'$ and $p'^{\,n}$ for three checks:

    | Check | $d$ | $\phi$ | |---|---|---| | a unit test on the artifact | 0.9 | 0.01 | | an LLM asked "does this reasoning look right?" | 0.2 | 0.25 | | no check at all | 0 | 0 |

    Compare all three against the unchecked $p^{\,n}$.

  3. The worst check. For a fixed $p$, which $(d, \phi)$ minimises $p'$? Give $p'$ and $p'^{\,10}$ in closed form and for $p = 0.9$. How does a reflection loop end up in that corner?

  4. Estimating $\phi$. Estimate the false-positive rate $\phi$, and roughly the detection rate $d$, of each check, and justify each estimate from what the check reads: (a) unit tests of a generated function, written independently of it, for example by a developer; (b) unit tests written by the same model from the same specification as the function; (c) a JSON-Schema validator on a generated object; (d) a model asked whether the reasoning text of the step looks right; (e) a model that reads the artifact together with the report of a test run; (f) a human reviewer. Relate the estimates to the lecture's artifact vs. narration rule.

  5. Formal or semantic. A generated function passes its unit tests. Which property of the function has been verified, and which has not? What does the answer imply for $d$?

Part II — The Plan as an Object

These exercises place planning architectures in the design space of the lecture and compute what a check per step and a plan written before execution are worth. The seven design dimensions are the ones the lecture lists under Design Dimensions of a Planning Architecture.

Exercise 3 — Decomposition-First vs. Interleaved Decomposition (conceptual)

For each task, decide whether a plan written before the first action (decomposition-first) or a decision on the next step at every turn (interleaved, as in ReAct) fits better. Justify the choice with a property of the task, and name the mechanism that the chosen mode needs to compensate for its cost.

  • (a) summarise each of 20 given files, then combine the summaries;
  • (b) find out why the test suite of an unfamiliar project fails;
  • (c) convert 50 configuration files to a new format, then run the full test suite once;
  • (d) answer a research question whose next sub-question depends on what the previous source says;
  • (e) book a flight and a hotel, then a restaurant within walking distance of the hotel.

Exercise 4 — Design Dimensions of an Architecture (conceptual)

A team describes its coding agent:

"The model writes the plan as a JSON list; each item has an id, a tool and a depends_on list. A scheduler starts every item whose dependencies have finished, several at once. The output of each item is checked by the unit tests of that item, and a rejected item is retried at most twice, with the test report in its prompt. If an item still fails, a second model call rewrites the items that have not yet run. No programmer writes the graph of steps."

  1. Classify the agent along the seven design dimensions of the lecture.
  2. Which architecture of the lecture is it closest to, and in which dimension does it differ most?
  3. The unit tests of an item are written by the same model that writes the item's code. Which property of the step check does that weaken, and which architecture of the lecture shares the weakness?
  4. Which two repairs does the agent combine, and in which order does it try them?

Exercise 5 — Check per Graph (calculation + concept)

Take the plan of Reliability: Monolithic vs. Decomposed with $d = 1$, but with one check after the whole graph instead of one after every step; a run detected as faulty derives all $n$ steps again.

  1. Compute the success probability (the formula is in the lecture, Step Verification) and the expected number of step executions, and compare both with the per-step design.
  2. Why does the check per graph do worse, in terms of what happens to a faulty result before it is checked?
  3. LLMCompiler's Joiner reads all results once per graph. Why is it not such a check?

Part III — Scheduling and Recovery

These exercises compute with the plan as a DAG: its matrix, its topological orders, the check of a given order and its reachability relation.

🔁 Prior knowledge (your Algorithms course): Grundlagen der Graphen · Graphensuche (BFS/DFS). We reuse adjacency matrices and adjacency lists, degrees, traversal, matrix powers, and running-time analysis here.

Exercise 6 — Plan → DAG → Order (calculation)

A plan has the tasks A–F with the dependencies $$A\to B,\quad A\to C,\quad B\to D,\quad C\to D,\quad C\to E,\quad D\to F,\quad E\to F.$$

  1. Write the adjacency matrix $A$ (rows = from, columns = to) and the in-degree and out-degree of each task; name the sources and sinks.
  2. Give one topological order. Is it unique?
  3. Group the tasks into parallel levels: tasks that can run at the same time.
  4. What is the critical path length (count steps, $d_i = 1$)? Why does it bound the makespan?
  5. Checking an order. For each proposed order, decide whether it is a valid topological order. If it is not, name one violated edge $\tau_i \to \tau_j$ and the positions that violate it: (i) A C E B D F, (ii) A B D C E F, (iii) A B C E D F.

Exercise 7 — A Cyclic Dependency Graph (calculation)

Dependencies: $P\to Q,\ Q\to R,\ R\to S,\ S\to Q$. Run Kahn's algorithm by hand (repeatedly remove an in-degree-0 node). What happens, and what does the result say about the plan?

Exercise 8 — A Trace of the Scheduler (trace)

Run the scheduler of the lecture by hand on the DAG of exercise Plan → DAG → Order. The scheduler repeats the four steps of The Scheduler Loop (ready set, dispatch, wait, block); the procedure $\textbf{Schedule}$ below Notation for the Scheduler writes them out. Two workers are available, and ready tasks are dispatched in alphabetical order. Task A takes 1 time unit, B takes 3, every attempt of C takes 1, and D, E and F take 1 each. C runs inside $\textbf{Checked-Step}_C$ with the retry cap $\kappa = 2$.

  1. Without a failure. The check accepts C's first attempt. Draw the run as a timeline with one row per worker, and give the makespan. Which path determines it?
  2. With a failure, policy drain. The check rejects both attempts of C. For each time at which a task finishes, give the finished task, its result (artifact or failure report), the running tasks, the blocked tasks and the tasks dispatched next. When does the round end, and what does it return?
  3. Policy stop. Repeat part 2 with stop. When does the round end, what does it return, and what happens to B?
  4. The repair. The replanner adds a retry node $C'$ (1 time unit, accepted at its first attempt) and re-points D and E onto it. For each policy, give the tasks of the second round, its duration, and the total time of both rounds. Which policy is cheaper here, and why? Which results are not recomputed?

References

Peer-reviewed papers

  • Kim, Sehoon, et al. "An LLM Compiler for Parallel Function Calling." International Conference on Machine Learning. Vol. 235. 2024. arXiv:2312.04511.
  • Shinn, Noah, et al. "Reflexion: Language Agents with Verbal Reinforcement Learning." Advances in Neural Information Processing Systems. Vol. 36. 2023. arXiv:2303.11366.

Preprints & other non-peer-reviewed papers

  • Huang, Xu, et al. "Understanding the planning of LLM agents: A survey." arXiv preprint arXiv:2402.02716 (2024).