Anti-Patterns

Unbounded Loop

Anti-pattern: run the agent loop without a step budget and let model self-termination decide.

Problem

In practice the model rarely declares itself done on hard tasks: it wanders into related questions, retries failed actions, or loops on errors without recognising that it is looping. With no external bound on iterations, total cost, or wall-clock time, the loop can run for hours and burn through significant budget before anyone notices. The user is left waiting while the agent grinds. Picking an exact cap is empirical and feels arbitrary, but no cap at all is worse: the agent will eventually be put in a state where it never terminates on its own, and unbounded cost is the result.

Solution

Don't. Set max_steps. Add a stop hook. See step-budget, the-stop-hook.

When to use

  • Cite this entry when loop termination depends solely on the model deciding it is done.
  • You are already here if runs occasionally wander for hundreds of steps with unbounded cost.
  • Set max_steps, add a stop hook (see step-budget, the-stop-hook), and pair with cost-gating.

Open the full interactive page

Diagram, neighbourhood map, code examples, related patterns and full provenance.

Related