Why loops get stuck
The three classic failure modes — and why longer loops are riskier.
A loop is powerful precisely because it repeats — but repetition is also how it goes wrong. Before you can make loops reliable, you need to recognize the three ways they fail. These are common, well-known, and largely predictable.
1. Repeating a failed action. The agent tries something, it does not work, and it tries the same thing again — and again. Without a sense of "I already tried that," a loop can bang on the same locked door indefinitely. You have probably seen a version of this: an AI that keeps offering the same broken fix even after you say it did not work.
2. Wandering off the goal. Each turn, the agent decides what to do next — and small drifts add up. It starts fixing the test, notices something else, refactors that, gets curious about a third thing, and twenty steps later it is far from the original goal. Flexibility is the loop strength; unchecked, it becomes aimlessness.
3. Runaway cost. Every turn of the loop is more model calls and more tokens, which means more time and more money. A loop with no limit can quietly rack up cost, especially if it is stuck repeating or wandering. An agent that "worked" but cost far too much is still a failure.
Why longer loops are structurally riskier. Each step has some chance of going wrong, and those chances compound. If an agent is 95 percent reliable per step, then over 20 steps its odds of getting the whole chain right are about 36 percent (0.95 multiplied by itself 20 times). So even a fairly reliable per-step agent becomes unreliable across a long chain — and it gets worse, because a model that sees its own earlier mistakes tends to make more after them. This is not a bug that a better model quickly erases; it is a structural property of chaining steps. The practical lesson: the shorter and better-scoped the loop, the more reliable it is.
Recap. Loops fail in three classic ways: repeating a failed action (no memory of what was already tried), wandering off the goal (small drifts compounding into aimlessness), and runaway cost (every turn spends time and tokens). And longer loops are structurally riskier because per-step errors compound — 95 percent per step over 20 steps is only about 36 percent overall — and models make more mistakes after seeing their own. The durable takeaway: keep loops short and well-scoped, and add the guardrails in the next lesson.
Imagine an agent looping on a task and getting stuck. Which of the three failure modes is most likely for YOUR task — repeating, wandering, or cost — and why? Naming the most likely failure up front tells you which guardrail in the next lesson matters most for you.
Enjoying the free lessons? Get an email when we publish new courses and updates — no spam, unsubscribe anytime.
Discussion (0)
Ask a question or share what worked for you. Comments are reviewed before they appear.
No comments yet. Be the first to start the discussion!