Most Agent Failures Are Loop Failures
The control loop is where you design termination, budgets, and recovery.

When an agent misbehaves, the loop is usually the culprit, not the model. Loop engineering is the deliberate design of when to keep going, when to stop, and what to do when a step fails.
A GPS that never announces you have arrived, or keeps rerouting you around the same block, is worse than no GPS at all, and the map data is fine in every case. The problem is the loop giving directions. An AI agent is a loop too, and most of the ways it fails are the loop misbehaving: never stopping, stopping too soon, or going in circles. Fixing agents is mostly fixing the loop.
When an agent misbehaves, we tend to blame the model. In my experience the loop is usually the culprit. The model chose a reasonable next step; the harness just never decided whether that step should happen, whether to keep going, or when to stop. That decision layer is the control loop, and designing it well is its own discipline.
The loop is the agent's control flow. It calls the model, runs a tool, observes the result, and then makes a decision: are we done, are we out of budget, are we stuck, or should we take another step. Everything interesting happens at those checkpoints.
None of those checkpoints come for free. A raw model call has no notion of "done," no budget, and no memory that it already tried this. If you do not build termination, budgets, and progress detection, you do not get them. This is why so many agents that demo beautifully fall apart in production: the demo runs on the happy path, and the loop was never taught to handle anything else.
The four failures below are the ones you actually hit. Click each to see the symptom and the guard that prevents it:
The loop keeps calling the model and running tools, never deciding the task is done. Burns budget forever.
A hard step budget (max iterations) plus a real completion check.
The failures are predictable, and each one has a guard the harness has to supply on purpose.
Walk the four:
- Never terminates. The loop keeps calling the model with no exit, burning tokens and time. The guard is a hard budget on steps, tokens, and wall-clock. The loop must not be able to outlive its budget.
- Gives up too early. The agent declares victory before the goal is met and returns half an answer. The guard is an explicit completion check. "Done" is a condition you can state, not a feeling the model reports.
- Thrashes and repeats. It retries the same failing step over and over, making no progress. The guard is progress detection: the same move twice is a signal that the plan is wrong, not that it needs another try.
- No recovery. A tool fails and either the whole run dies or the model pretends it succeeded. The guard is retry with backoff, then escalation. A failed tool should be handled, not hidden.
The deeper point is that a good loop is mostly the handling of everything that is not the happy path. The straight-line success case is easy. The reason production agents are hard is the branching mess around it: partial failures, ambiguous results, dead ends, and the temptation to keep going when you should stop.
This is also why the ordered sequence of steps is worth testing directly. In regulated or high-stakes workflows the path matters as much as the destination, and asserting the expected trajectory, that the agent asked for consent before it acted, that it looked something up before it changed it, is really a test of the loop. It is the part of AgentTrustCI I reach for most, because it catches the loop drifting long before a user does.
The model decides the next step. The loop decides whether that step happens, how long to keep trying, and when to stop and report what it has. Get the loop right and a mediocre model becomes dependable. Get it wrong and the best model in the world will still spin.