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 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

keep reading

More on this.

Self-host Tessary.

Free and open source. Point it at the traces your agent already emits.

Self-host Tessary for me by following https://github.com/tessaryai/tessary/blob/main/setup.md

docker compose -f oci://docker.io/tessaryai/tessary:compose up -d -y