Teaching an agent when to stop

Search for a command to run...

The hardest part of building a tool-use agent is not teaching it what to do. It is teaching it when to stop.
An agent that can call tools has two failure modes, and they are mirrors of each other. Stop too early and you get a shallow answer — the agent asked one question, got a result, and wrote a response before it understood the problem. Stop too late and you get an expensive one — the agent kept searching long after it had enough, calling tools in circles, burning time and tokens to arrive at the same answer it could have written five steps ago. Both are bad. The first hurts quality. The second hurts cost and latency. And the obvious fixes for each one make the other worse.
Here is the stop rule we landed on, and why.
The first naive rule is to let the model decide. Give it the tools, tell it to answer when it is ready, and trust it. This fails on the early side. Models, left to themselves, tend to stop as soon as they have something plausible to say. The first tool returns a result that looks like an answer, and the agent writes the answer. It never finds the second source that would have contradicted the first, or the dosage caveat, or the safety note. Trusting the model to stop produces confident, shallow, fast answers.
The second naive rule is to force a fixed number of steps. Make it call tools six times, no matter what. This fails on the late side, and in a more expensive way. If the answer was obvious after two calls, the agent spends four more calls re-deriving it, or worse, inventing tangential sub-questions to justify the steps it is required to take. Forcing steps produces thorough, slow, sometimes-contrived answers.
Each rule fixes the other's failure by introducing its own. You cannot pick a side. You need both constraints at once.
Our stop condition is a floor and a signal, combined.
The floor is a minimum number of steps, scaled to how deep the question is. A basic question requires at least three tool-using steps before the agent is even eligible to stop. A standard question requires six. A deep comparison requires ten. Below the floor, the agent is not allowed to finish, no matter how ready it thinks it is. This is the guard against shallowness — the model cannot bail after one good-looking result, because the floor has not been met.
The signal is the model's own judgment, expressed in a specific way. After each step, the agent reflects on what it learned and what gaps remain, and it writes what it will do next. When it believes the investigation is complete, it says so explicitly, with a fixed marker — a literal "done" token in its reflection. That marker is the only way, beyond the floor, that the agent can request to stop.
Eligibility to stop requires both: the minimum step floor has been met, and the agent has signaled that it is done. Either alone is insufficient. Above the floor, if the agent keeps finding new things to investigate, it keeps going — there is no ceiling forcing it to wrap up, so genuine depth is allowed. But the moment it signals done, and the floor is behind it, it stops.
The floor prevents the failure of stopping too early. The signal prevents the failure of stopping too late. And because the signal comes from the agent's own reflection rather than a hard step cap, the agent that genuinely needs twelve steps to answer a hard question can take them, while the agent that nailed it in four is free to say so and move on.
There is something pleasing about the shape of it. We did not teach the agent when to stop by writing a smarter rule. We wrote two simple rules that disagree with each other and refused to let either one win. The floor says "not yet." The signal says "now." The agent stops only when both agree. That conjunction — not the floor alone, not the signal alone — is what produces answers that are deep enough without being wasteful.
Most of the hard problems in building agents are not about making the model smarter. They are about constraining it well. A model with good tools and bad constraints will fail in predictable, expensive ways. The same model with good constraints — a floor against shallowness, a signal against waste, both required — will behave remarkably well.
Teach the agent what to do, certainly. But spend at least as much care on when it is allowed to stop. That is where most of the quality, and most of the cost, lives.