Topic 2
Stopping conditions
The simplest bound on autonomy is time. An agent that loops for ever spends money and can repeat a harmful action many times. Anthropic's "Building effective agents" (2024) recommends stopping conditions, such as a maximum number of iterations, to keep control.
Lesson 2 showed why loops need them: when a model judges a loop's exit condition, nothing guarantees it's ever met.
Predict first
An agent stuck repeating one call
Illustrative · from step 4 every call is identical · $0.012 per step
Stopped at step
6
Stopped by
repeated identical calls
Spent
$0.072
With the defaults, the repeat limit stops the illustrative loop at step 6, long before the $0.30 cost cap (step 25) or the 30-step limit. Turn the repeat limit up and the cost cap takes over. That's the point of having several: each catches a different failure, and the first one reached ends the run.
Useful limits for most agents:
- Steps per task: the hard ceiling on any loop.
- Cost per task, from token and tool usage: catches long, expensive runs that aren't technically loops.
- Wall-clock time: the user, or a deadline, won't wait for ever (AI Engineering's grant-proposal example from lesson 5).
- Repeated actions: the same call with the same arguments, or the same error, several times in a row.
- Consecutive failures: lesson 4's escalation rule.
When a limit fires, the run should end cleanly: save a checkpoint, tell the user what was done and what wasn't, and hand the task to a person.
Quick check