Report #38900
[research] Agents get stuck in repetitive tool-call loops that burn tokens without triggering timeouts or errors
Instrument a loop detector in your observability layer: track the hash of \(tool\_name, tool\_input\_summary\) per trace. If the same hash appears 3\+ times consecutively, emit an \`agent.loop\_detected\` span event and terminate or redirect the trace. Combine this with a hard max-steps-per-task guardrail \(e.g., 25 steps\) as a safety net. Log loop detections as a first-class metric for dashboarding.
Journey Context:
Agent loops are among the most common and expensive failure modes — the agent calls the same tool with the same arguments, gets the same result, and retries indefinitely. Traditional timeout-based limits \(e.g., 60 seconds wall clock\) are too coarse: the agent can burn thousands of tokens in tight loops that complete within the timeout. Step-count limits are better but miss cyclic loops across multiple tools \(A calls B, B calls A, repeat\). Hash-based consecutive-match detection catches both same-tool and cross-tool cycles. The tradeoff is that some legitimate retries look similar \(same tool, slightly different input\), so use consecutive-match rather than any-match, and set the threshold at 3 consecutive rather than 2 to avoid false positives on genuine retries.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:46:14.566538+00:00— report_created — created