Teaching Script — Module 7: Error Handling & Recovery

Module: 7 · Duration: ~45 min

[SLIDE 1] Module Seven: Error Handling and Recovery. Forty-five minutes. The error-compounding math, the four-category taxonomy, stuck-loop detection, and graceful degradation.

[SLIDE 2] The compounding math. A ten-step process at ninety-nine percent per-step reliability gives about ninety percent end-to-end success. Fifty steps gives sixty percent. A hundred steps gives thirty-seven percent. Error handling is not a feature — it is the difference between a demo that works and a production system that ships.

[SLIDE 3] The four-category taxonomy. Transient — network timeout, five-oh-three, rate limit — retry with exponential backoff and jitter, capped at two per Stripe. LLM-recoverable — wrong argument, bad type — return the error as a tool result and let the model self-correct next turn. User-fixable — missing credential, ambiguous task — interrupt to the human, Module Six. Fatal — sandbox crash, budget exhausted — halt immediately, do not retry. Misclassify and you get the wrong response. Retrying a fatal error burns the budget. Swallowing a recoverable one makes the model hallucinate success.

[SLIDE 4] Four anti-patterns. Retrying everything — a fatal error retried forever consumes the entire budget. Swallowing everything — silent failures where the model hallucinates success because it got no feedback. Surfacing everything to the user — alert fatigue from Module Six. And no taxonomy at all — all errors treated identically, which usually means retry everything by default.

[SLIDE 5] Stuck-loop detection. The model calls a tool, it fails, the model calls it again with the same input, it fails again. Same tool, same input, same error — that is a stuck loop. The detection signal comes from Module One's observability payload: input hash and output hash. If both match across N consecutive turns, typically three, the loop is stuck.

[SLIDE 6] The circuit breaker. When stuck-detection fires, the circuit breaker trips: disable the failing tool for the rest of the session. The model cannot call it again. It must route around the failure or report that it cannot proceed. This is the tool-level realization of the error-threshold stop condition from Module One. It prevents one misbehaving tool from trapping the agent.

[SLIDE 7] Graceful degradation. Partial completion — do as much as possible, report clearly what was skipped. Budget exhaustion — save state via checkpoint, exit cleanly, write the handoff file. Budget exhaustion is a planned stop, not a failure. And human-readable failure reports — task, what's done, what failed, why, what the human should do next. Specific, not vague.

[SLIDE 8] Four takeaways. Four categories — transient retries, LLM-recoverable self-corrects, user-fixable interrupts, fatal halts. Error compounding — ninety-nine percent over fifty steps is sixty percent; the taxonomy is the cure. Stuck loop — same input and output hash across N turns; circuit breaker disables the tool. Graceful degradation — partial completion, clear report, budget-exhaustion handling. Next: Module Eight — State, Checkpointing, and Multi-Session Design.

# Teaching Script — Module 7: Error Handling & Recovery

**Module**: 7 · **Duration**: ~45 min

[SLIDE 1] Module Seven: Error Handling and Recovery. Forty-five minutes. The error-compounding math, the four-category taxonomy, stuck-loop detection, and graceful degradation.

[SLIDE 2] The compounding math. A ten-step process at ninety-nine percent per-step reliability gives about ninety percent end-to-end success. Fifty steps gives sixty percent. A hundred steps gives thirty-seven percent. Error handling is not a feature — it is the difference between a demo that works and a production system that ships.

[SLIDE 3] The four-category taxonomy. Transient — network timeout, five-oh-three, rate limit — retry with exponential backoff and jitter, capped at two per Stripe. LLM-recoverable — wrong argument, bad type — return the error as a tool result and let the model self-correct next turn. User-fixable — missing credential, ambiguous task — interrupt to the human, Module Six. Fatal — sandbox crash, budget exhausted — halt immediately, do not retry. Misclassify and you get the wrong response. Retrying a fatal error burns the budget. Swallowing a recoverable one makes the model hallucinate success.

[SLIDE 4] Four anti-patterns. Retrying everything — a fatal error retried forever consumes the entire budget. Swallowing everything — silent failures where the model hallucinates success because it got no feedback. Surfacing everything to the user — alert fatigue from Module Six. And no taxonomy at all — all errors treated identically, which usually means retry everything by default.

[SLIDE 5] Stuck-loop detection. The model calls a tool, it fails, the model calls it again with the same input, it fails again. Same tool, same input, same error — that is a stuck loop. The detection signal comes from Module One's observability payload: input hash and output hash. If both match across N consecutive turns, typically three, the loop is stuck.

[SLIDE 6] The circuit breaker. When stuck-detection fires, the circuit breaker trips: disable the failing tool for the rest of the session. The model cannot call it again. It must route around the failure or report that it cannot proceed. This is the tool-level realization of the error-threshold stop condition from Module One. It prevents one misbehaving tool from trapping the agent.

[SLIDE 7] Graceful degradation. Partial completion — do as much as possible, report clearly what was skipped. Budget exhaustion — save state via checkpoint, exit cleanly, write the handoff file. Budget exhaustion is a planned stop, not a failure. And human-readable failure reports — task, what's done, what failed, why, what the human should do next. Specific, not vague.

[SLIDE 8] Four takeaways. Four categories — transient retries, LLM-recoverable self-corrects, user-fixable interrupts, fatal halts. Error compounding — ninety-nine percent over fifty steps is sixty percent; the taxonomy is the cure. Stuck loop — same input and output hash across N turns; circuit breaker disables the tool. Graceful degradation — partial completion, clear report, budget-exhaustion handling. Next: Module Eight — State, Checkpointing, and Multi-Session Design.