Key ideas
- The one idea — The same loop that gives an agent its power can trap it — repeating a failing action, oscillating between states, or wandering — because it picks each step from an unchanging context, burning tokens and money; real agents need guardrails.
- How it is shown — An agent running the identical failing search over and over (context unchanged → same choice), a step counter and token meter climbing with zero progress, until a cap stops it.
- The trap to avoid — Letting an agent run unbounded, trusting it to always converge — it can spin forever; always cap iterations and detect repetition.
- What it sets up — You've seen the loop, planning, self-checks, and failure — time to build one.
Production agents ship with a kill switch: an iteration cap and repetition detectors. Because left alone, a looping agent will happily burn your budget making zero progress.
The one idea
The same loop that gives an agent its power can trap it — repeating a failing action, oscillating between states, or wandering — because it picks each step from an unchanging context, burning tokens and money; real agents need guardrails.
The loop is what gives an agent its power — and it's also a trap. Because the agent decides each step from its context, it can repeat itself: doing the same failing thing over and over, burning time and money, making no progress. Agents get stuck in loops. The most common form: the agent tries an action, it fails, and it tries the exact same action again, expecting a different result. The search returns nothing, so it runs the identical search. The code errors, so it resubmits it. Same input, same failure, repeat. Another form is oscillation: it flips between two states — picks A, doubts it, switches to B, doubts that, swings back to A, never settling. Or it wanders, chasing sub-goals that sprout more sub-goals until the real task slips away. Same dead end.
How it works — the demo
An agent running the identical failing search over and over (context unchanged → same choice), a step counter and token meter climbing with zero progress, until a cap stops it.
Why does this happen? The model chooses each step by conditioning on the context. If the context barely changes after a failure, it keeps making about the same choice. Nothing shifted enough to push it onto a new path. Same picture in, same move out. And every spin of that loop is a full model call — tokens in, tokens out, real money. A stuck agent isn't just unproductive; it's expensive, running up a bill while going nowhere. Left unbounded, it spins until someone pulls the plug. So real agents need guardrails. Cap the number of steps.
The trap to avoid
Letting an agent run unbounded, trusting it to always converge — it can spin forever; always cap iterations and detect repetition.
Why it matters — and what’s next
You've seen the loop, planning, self-checks, and failure — time to build one.
Detect repetition and force a different approach. Give the agent memory of what it tried, so it won't retry it. Set a budget. These don't add intelligence; they stop the runaway. The trap: letting an agent run unbounded, trusting it to always converge. It won't. Always cap iterations and watch for repetition. The loop is both power and trap. You've seen the loop, planning, checks, and failure — time to build one. Next: build an agent in thirty lines.
This is one short episode in AI: Zero → Frontier, a step-by-step climb through how AI actually works. Each episode builds only on the ones before it.
Full transcript 2:30 of narration
The loop is what gives an agent its power — and it's also a trap. Because the agent decides each step from its context, it can repeat itself: doing the same failing thing over and over, burning time and money, making no progress. Agents get stuck in loops.
The most common form: the agent tries an action, it fails, and it tries the exact same action again, expecting a different result. The search returns nothing, so it runs the identical search. The code errors, so it resubmits it. Same input, same failure, repeat.
Another form is oscillation: it flips between two states — picks A, doubts it, switches to B, doubts that, swings back to A, never settling. Or it wanders, chasing sub-goals that sprout more sub-goals until the real task slips away. Same dead end.
Why does this happen? The model chooses each step by conditioning on the context. If the context barely changes after a failure, it keeps making about the same choice. Nothing shifted enough to push it onto a new path. Same picture in, same move out.
And every spin of that loop is a full model call — tokens in, tokens out, real money. A stuck agent isn't just unproductive; it's expensive, running up a bill while going nowhere. Left unbounded, it spins until someone pulls the plug.
So real agents need guardrails. Cap the number of steps. Detect repetition and force a different approach. Give the agent memory of what it tried, so it won't retry it. Set a budget. These don't add intelligence; they stop the runaway.
The trap: letting an agent run unbounded, trusting it to always converge. It won't. Always cap iterations and watch for repetition. The loop is both power and trap. You've seen the loop, planning, checks, and failure — time to build one. Next: build an agent in thirty lines.