Your Agent Is Stuck in a Loop: What Do You Do?

Free with account Updated Nov 16, 2026 · 3 min read
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

    Example trace: the same call, the same empty result, and nothing that changes the agent's next move.
    Example trace: the same call, the same empty result, and nothing that changes the agent's next move.
    • 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.