# Why does an agent get stuck in a loop instead of finishing the task?

An agent loops because whatever's meant to end the cycle, a stop condition, a check that the goal was actually met, doesn't bound the path back into another model call, tool call, or handoff. [Researchers scanning 6,549 open-source agent repositories](https://arxiv.org/abs/2607.01641) for this pattern, which they call an infinite agentic loop, confirmed 68 real instances across 47 projects: a plan with zero valid steps that resets a success flag and retries the same call with no cap, or an empty, malformed reply that triggers a corrective reprompt that loops with no bound. None of this looks like a hang. The model keeps generating fluent, plausible steps the whole time, so nothing crashes and no error fires; the run just never converges. The fix isn't a smarter prompt, it's a bound outside the model's own judgment: a hard step limit, a check that state actually changed since the last attempt, or deduplication on repeated identical calls.

---

Sources:
- "When Agents Do Not Stop: Uncovering Infinite Agentic Loops in LLM Agents" (arXiv:2607.01641): https://arxiv.org/abs/2607.01641 (fetched 2026-08-29)

Source: https://tessary.ai/answers/failure-modes/why-does-an-agent-get-stuck-in-a-loop
More on Failure modes: https://tessary.ai/answers/failure-modes
From Tessary, agent reliability for AI agents in production: https://tessary.ai
