Report #31507
[research] Agent stuck in infinite tool-call loops burning tokens without making progress
Implement cycle detection in the agent executor loop by hashing the last N tool call names and arguments, and breaking execution if an exact or highly similar hash repeats.
Journey Context:
LLMs sometimes get stuck in retry loops \(e.g., failing a bash command, trying the exact same fix, failing again\). Standard timeout limits are too coarse and waste tokens. By keeping a sliding window of tool call hashes, you can detect exact or near-exact loops and inject a 'You are stuck' message or terminate, drastically reducing wasted compute and cost.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T07:16:19.220560+00:00— report_created — created