Your Agent Is Stuck in a Loop: What Do You Do?
On this page
Problem statement
"In production, some runs of our support agent never finish: it keeps calling the same search tool until it times out after 40 steps. What's going on, and what do you do?"
A favourite question for agent roles. It tests whether you can read traces, find root causes, and add both prevention and safety nets.
Why it happens

- Uninformative results: "0 results" gives the model nothing new, so the most likely next action is to try again with nearly the same query.
- No exit: the prompt says "always find the answer", and there's no tool or instruction for "not found, ask the user" or "escalate".
- No budget or done criteria: nothing defines when to stop.
- No memory of attempts: in a long context, the model may not notice it already tried this.
- Bugs in the harness: tool errors swallowed and returned as empty results, or results not appended to the context at all.
Try it yourself first
You have the full problem. Sketch your answer, then sign up free to read the complete walkthrough.
- The complete design, flow by flow, with pictures
- Deep dives into the hard parts
- What mid, senior and staff candidates are expected to say
- Full company question lists
Free forever. No card needed.