LEARN · 4 MIN

How loops end

Stop conditions, step limits, and why stopping is the hard part.

The whole trick is the stop. A useful loop has both a natural stop and a safety stop.

A natural stop is the point where the agent decides the goal is met, or it cannot find any more useful work. A safety stop is the limit the harness enforces: max steps, time, budget, or no progress after a few passes.

Without a stop, an agent can keep calling tools because another action is always possible. It might re-read the same page, rewrite the same file, or spend time proving something that was already known. Good loops make that failure boring: they count passes, detect repeated states, and stop before motion becomes waste.

Checks make stopping real. A pass is not done because the agent says so. It is done when a check passes: tests are green, a link resolves, a file exists, a report has required sources, or a human approves the next move.

Human gates are also stop conditions. Anything public, destructive, expensive, or credential-related should stop and ask. The loop can prepare the plan and evidence, but it should not cross that line by itself.

Sources: Simon Willison, Designing agentic loops; Anthropic, Building Effective Agents.