Skip to slide
024 / 221

CH 02 · The Agent Loop Pattern · 12/15

Read as one page

Common failure modes to design against

  • Runaway iteration → the hard cap.
  • Stuck loops (same call repeated) → repetition detection.
  • Missing tool results → guarantee one result per call.
  • Malformed tool arguments → parse defensively, default to empty, return a useful error the model can recover from.
  • Tool exceptions → catch them and feed the error back as a tool result, so the model can adapt rather than the whole turn crashing.

The theme: the loop is where the model's unreliability meets your code, so the loop is where you must be most defensive.

Finished this idea?

Your learning progress stays in this browser.