# How do you detect a looping agent in production?

Watch for the shape a stuck loop always leaves in a trace: the same tool call or model call repeating with near-identical arguments while turn count, duration, or cost keeps climbing well past what that call site normally takes. A looping agent doesn't throw an error or hang in any way monitoring would flag on its own, since the model keeps generating fluent, plausible steps the whole time; the giveaway is the pattern across the session, not any single step in it.

Static analysis, scanning an agent's own code for a cycle with no real limit on it, catches this before a change ships, but it's a one-time check on code you have, not something watching live traffic after the fact. Production detection is the layer that catches what a code review can't: an agent that loops because of a runtime condition the code review never exercised. [Tessary's duration_drift and cost_drift classifiers](/answers/tessary-duration-drift/what-is-tessarys-duration-drift-classifier) watch exactly that per call site, comparing each session's cost and duration against its own history rather than a fixed threshold, since what's slow or expensive for one agent is routine for another.

---

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

Source: https://tessary.ai/answers/agent-loops-research/how-do-you-detect-a-looping-agent-in-production
More on Agent loops research: https://tessary.ai/answers/agent-loops-research
From Tessary, agent reliability for AI agents in production: https://tessary.ai
