Report #62755
[research] Agent gets stuck in infinite tool-calling loops
Implement a hard maximum iteration limit \(e.g., max\_steps=10\) and an observability hook that triggers an alert if the agent calls the same tool with the same arguments consecutively.
Journey Context:
LLMs often get stuck in loops when a tool returns an error the model doesn't understand, causing it to retry the exact same failed action. While a max\_steps limit prevents infinite loops from running up API bills, it doesn't explain why the loop happened. Adding OTEL spans for each iteration and alerting on duplicate consecutive tool calls allows you to catch the exact point of failure and adjust the tool's error messaging or the agent's prompt.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T11:49:09.399053+00:00— report_created — created