Agents, Tool Use & MCP·Question 43 of 90Advanced

Walk me through the compounding-error math for agents, and what it implies for design.

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

If each step succeeds independently with probability p, an n-step task succeeds end-to-end with probability p^n. The numbers are brutal: 0.95²⁰ ≈ 36%, 0.99⁵⁰ ≈ 61%, and 0.9¹⁰ ≈ 35%. A per-step reliability that sounds excellent (95%!) produces a coin-flip-or-worse product at realistic trajectory lengths. This single equation explains the demo-to-production gap: demos are short trajectories cherry-picked from the pass@k distribution; products live at pass^1 over long trajectories.

Full worked answer with diagram

If each step succeeds independently with probability p, an n-step task succeeds end-to-end with probability p^n. The numbers are brutal: 0.95²⁰ ≈ 36%, 0.99⁵⁰ ≈ 61%, and 0.9¹⁰ ≈ 35%. A per-step reliability that sounds excellent (95%!) produces a coin-flip-or-worse product at realistic trajectory lengths. This single equation explains the demo-to-production gap: demos are short trajectories cherry-picked from the pass@k distribution; products live at pass^1 over long trajectories.

The model gives you exactly three levers, plus one that breaks the model itself:

  1. Reduce n. Consolidated tools (one schedule_meeting instead of a three-call chain), better plans that avoid wandering, caching known results, and doing deterministic glue in code rather than via model steps. Halving steps helps more than most prompt work: 0.95¹⁰ ≈ 60% vs 0.95²⁰ ≈ 36%.
  2. Raise p. Better tool descriptions, constrained schemas (enums over free text), stronger models on hard steps, lower-variance decoding on mechanical steps, high-signal context hygiene.
  3. Change the exponent's meaning - add recovery. The p^n model assumes failures are terminal. If a failed step is detected and correctable - actionable error messages, verification sub-steps, checkpoints to retry from - then failures become retries rather than run-killers, and effective reliability decouples from raw n. This is the most important lever and the least glamorous: it's why error-message quality and verifiability of intermediate state dominate mature agent engineering.
  4. The caveat: steps aren't independent. Errors correlate - one bad assumption poisons every subsequent step (worse than the model), while good context and self-correction create positive correlation (better than the model). Context pollution makes p decline with n, which is why compaction and fresh-restart strategies exist.

Design summary: shorten, strengthen, and above all make failures observable and recoverable.

Worth sketching. The recovery branch is what breaks the exponent, so draw that loop rather than a row of multiplying probabilities.

flowchart LR
    A["Step k"] --> B{"Result checkable?"}
    B -->|"no signal"| C["Bad state rides forward,<br/>p declines with n"]
    B -->|"actionable error"| D["Retry or reroute"]
    D --> A
    B -->|"verified"| E["Step k+1"]
    E -->|"20 steps at p = 0.95"| F["36% end to end"]

What a good answer covers

  • If each step succeeds independently with probability p, an n-step task succeeds end-to-end with…
  • The numbers are brutal: 0.95²⁰ ≈ 36%, 0.99⁵⁰ ≈ 61%, and 0.9¹⁰ ≈ 35%
  • A per-step reliability that sounds excellent (95%!) produces a coin-flip-or-worse product at realistic…
  • This single equation explains the demo-to-production gap
  • Reduce n

Key terms: Reduce n · Raise p · The caveat

Interviewer follow-ups to expect

  1. How does verification-before-done interact with this math?

  2. Given a fixed budget, when do you spend it on a better model vs recovery machinery?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep