Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Describe two distinct conditions that cause an agent loop to run indefinitely. Then name three runtime safeguards, explaining why each one alone is insufficient as the only protection.
Loops come from same-tool repetition and no-progress oscillation. Step caps, call dedup, and progress checks each miss a case, so production stacks all three plus a cost and time budget.
Imagine someone lost in a hedge maze. One way they get stuck is walking into the same dead end over and over, never learning it is a dead end. Another way is pacing back and forth between two spots, looking busy but going nowhere. A simple fix is a kitchen timer: when it rings, leave the maze. But the timer is dumb, it might ring while you are about to find the exit, or let you wander for an hour first. So you add more checks. One watches for the same wrong turn twice. One watches whether you are actually getting closer to the exit. No single check catches everything, because each one is blind to a different kind of stuck. Only stacking them all makes the maze safe to enter.
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.
Open by separating the two loop conditions, same-tool repetition and multi-state oscillation. Then take each safeguard in turn, state what it catches and the exact case it misses, and converge on layered defense with cost and wall-clock budgets plus tracing as the production answer.
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.
Naming only a step cap and stopping there. A step cap bounds the worst case but cannot tell a productive long run from a stuck short one, so it either fires too early or wastes a full budget on a hung agent.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.