Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
What are the three canonical stopping conditions for an agent loop? For each, briefly describe how it is detected. Then explain why cost cap is harder to implement correctly than the other two.
The three stopping conditions are final-answer signal, step budget, and cost cap. Cost cap is hardest because next-step cost is unknown until after the call and compounds as context grows.
Imagine you give a helper a task and a few rules for stopping. First, they stop when they say they are finished. Second, they stop after a fixed number of tries, no matter what. Third, they stop once they have spent a set amount of money. The first two rules are easy to check. "Did they say done?" is a yes or no question. "Have they tried ten times?" is just counting. But the money rule is sneaky. You only learn the price of a try after it happens, not before. And each new try costs more than the last, because the helper carries a growing pile of notes along every time. So it is easy to blow past your budget on the very step that pushes you over, since you could not see the bill until the work was already done.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Name the three stops and their detection mechanisms, frame steps and cost as hard backstops layered under the model's own done signal, then spend most of the answer on why cost is hardest: post hoc knowledge of token cost, monotonic compounding of context, overshoot risk, and what to return on a forced stop.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Trusting the model's final-answer signal as the only stop. A confused agent declares done prematurely or never, so hard backstops on steps and cost must run independently of what the model claims.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.