A single chat turn has a natural end: the model stops writing. A loop does not. If the stop condition never fires (a tool keeps returning an error, the agent keeps re-trying the same call, the task was never achievable), it goes round until something external stops it, and every lap costs more than the last. These five caps are the something external.
Five caps, in the order they save money
- 1
1. Max steps
Hard-stop the loop at N tool calls. Fifteen is generous for most tasks; a run that needs thirty is usually stuck. This is the cap that catches the most incidents.
- 2
2. max_tokens per call
The largest plausible tool call plus a short explanation, typically 1,000 to 4,000 tokens for an agent turn. It stops a runaway monologue. It does not stop context growth, which is why it is second, not first.
- 3
3. Stop conditions
End the run on a final-answer call, on the same tool call repeated with identical arguments (the signature of a loop), or on an empty tool result twice in a row.
- 4
4. A per-run dollar budget
After every call, add input tokens × input rate plus output tokens × output rate to a running total, and abort past your ceiling. On Sonnet 5, a $0.50 budget allows about 14 uncached steps of the reference trace, or roughly 35 cached.
- 5
5. A confirmation gate on side effects
Any tool that sends, pays, deletes or edits waits for a human yes. This does not save tokens; it saves the thing the tokens were spent on.
| Cap | Stops | Does not stop |
|---|---|---|
| Max steps | Endless loops | Fifteen expensive steps on a flagship |
| max_tokens | Runaway output | Input growth, which is 98% of the bill |
| Stop conditions | The stuck-repeating case early | A loop that varies its calls slightly each time |
| Dollar budget | Spend past a number you chose | Nothing else; it is the backstop |
| Confirmation gate | A wrong action with consequences | Any token spend at all |
Which would you trust?
Two agent designs for the same job: classifying 500 incoming support emails a day and drafting a reply for each. Which should you trust with your card on file?