A good agent isn't one that just keeps going. It's one that knows when to stop, and when it's worth retrying just once.
Let's think about this for a second
Set three stop conditions. Success — the output matches the expected shape. Safe failure — a missing file, something not allowed, or genuine uncertainty. Limit — max steps or timeout reached. Only retry when the error is transient. Calling a missing-file lookup five more times gets you nowhere. When you retry, change the argument — retrying with the exact same call just turns into a loop.
Let's connect this to everyday life
Study Helper's rules — stop once it's found the file and pulled out 3 facts. If a file's missing, call list_notes one more time; if it still can't find it, stop. On a tool timeout, retry once. Once 5 steps are used up, say "not done yet — a human needs to take over." Show the user progress along the way — a spinner that just sits there frozen kills trust.
Let's try it out together
const MAX_STEPS = 5;
function shouldStop({ steps, done, missing, unsure }) {
if (done) return "success";
if (missing || unsure) return "safe-failure";
if (steps >= MAX_STEPS) return "limit";
return "continue";
}You'll be able to explain three stop rules for an agent.5-minute try
Write a stop table for your own agent. For each of success / missing file / unsure / timeout / max steps, note exactly what it should say.
A quick word of caution
Never connect an agent with no limits to the internet. It can rack up costs and fire off requests you never expected.