179 questions
No questions match those filters.
← All questions
AgentsMedium· Agents & Orchestration
How do you stop an agent looping forever?
This is one of the questions in the full AI/ML interview bank. Pro unlocks all 1789 questions; Premium includes the same bank plus the highest daily Practice limit.
See plansAn iteration cap is necessary and not sufficient on its own — it just turns an infinite loop into a truncated failure with no useful output, which is better than a runaway process but still a failure.
What I actually want:
- A bounded iteration budget, paired with a defined terminal state — what does the agent return when it exhausts its budget, and does the caller know the result is truncated rather than complete?
- A spend ceiling alongside the iteration cap, since iterations and cost are effectively the same axis for anything calling a paid model.
- Progress detection — if the agent is repeating the same failing action, stop after one or two repeats rather than letting it retry the same dead end nine more times.
The goal isn’t just “it eventually stops” — it’s that when it stops early, the system and the caller both know exactly why.