Step Limit (Agent)
An agent that is making progress stops because it finished. An agent that is confused does not stop at all — it will try the same broken call again, and again, with perfect patience. A step limit is the blunt instrument that ends the run anyway: a hard count of loop iterations, after which the agent is cut off whatever it believes it is doing.
What counts as a step
One step is normally one pass through the loop — a model call plus the tool invocation it requested. Frameworks name it differently (max_iterations, max_steps, recursion_limit in LangGraph) but the mechanic is identical: the runtime increments a counter it owns and the model cannot touch. That ownership is the whole point. A termination condition asks the model to decide it is done; a step limit does not ask.
Choosing the number
Set it too low and legitimate work is truncated — a research agent cut off after six steps returns a half-read answer that still sounds confident. Set it too high and a stuck loop burns real money before anyone looks. Useful limits come from measurement: read the traces of successful runs, take the worst case, add headroom. Then handle the overrun properly — hitting the ceiling should surface the partial result and a clear step limit reached signal, never a silent empty answer.
Why it matters
It is the floor under every other runtime control. Token budgets, loop detection and cost caps can all be misconfigured or evaded; the step limit is simple enough to be correct, which is what makes it the guarantee that a run terminates.
A step limit caps the number of iterations an agent may run through its plan–act–observe loop before the runtime halts it, whether or not the task is complete. Enforced by the framework rather than decided by the model, it guarantees termination when a termination condition is never reached — a tool that keeps failing, or a plan that keeps restarting. Without it, a confused agent retries indefinitely, spending tokens and money for no result.
Think of sending someone off to sort out a problem with the instruction: give it ten tries, then come back and tell me what happened. That is a step limit.
An AI agent works in small steps — try something, look at the result, try the next thing. If it gets confused, it will happily repeat a useless step forever, because nothing makes it feel frustrated. So the software counts the steps and pulls the plug at an agreed number.
It is a crude rule, and that is exactly why it is trusted: there is no cleverness in it to go wrong. You get a partial answer and an honest note that it ran out of tries, instead of a bill that quietly grew all night.