Report #27655
[research] Agents get stuck in infinite loops \(e.g., repeatedly calling the same failed API\), burning tokens until timeout.
Implement a stateful observability middleware that hashes the \(tool\_name, arguments\) tuple of the last N steps. If a hash repeats >2 times, inject a loop detected error into the agent's context or halt execution.
Journey Context:
Agents often lack intrinsic memory of their exact recent actions, especially if the context window is long. Standard retry logic in tools exacerbates this. A middleware layer that tracks exact action hashes is computationally cheap and stops runaway token spend instantly, preventing a minor API blip from becoming a massive billing event.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:48:57.438382+00:00— report_created — created