OpenRouter releases tutorial on preventing infinite loops in Agents
Understand this story
OpenRouter has released a tutorial on how to use four layers of protection to stop AI Agents from repeatedly calling failing tools in an infinite loop. Three of these layers take effect inside the Agent through the OpenRouter Agent SDK (@openrouter/agent 0.11.0): doom-loop detection, rules defining which calls count as duplicates, and step and cost limits; the fourth layer is the quota limit on the API key. OpenRouter said it ran 18 live tests across six models. With doomLoop detection enabled, all six models were blocked on the third identical tool call, and total tool calls dropped from 314 to 64, while cost fell from $0.29 to $0.05. The tutorial notes that if the key uses BYOK, include_byok_in_limit must be set to true, otherwise BYOK spending is not counted toward the quota; daily limits reset at UTC midnight, and weekly limits reset every Monday.
AI overview based on source reports · Updated 3 days ago
Coverage timeline
Follow the coverage to explore different perspectives.
- OpenRouter AnnouncementsHow to Stop an AI Agent Stuck in an Infinite Loop
OpenRouter describes four guards against runaway agent loops, tested on six models with its Agent SDK (@openrouter/agent 0.11.0): doom-loop detection, a loopKey that normalizes tool arguments, stopWhen caps on steps and cost, and a credit limit on the API key. With doomLoop: true, all six models were blocked on their third identical tool call, and across 18 runs detection cut tool calls from 314 to 64 and spend from $0.29 to $0.05. The article notes that loops vary between runs and that only the key-level limit caps total spend when agent code is buggy or caps are missing.
Activity for this story
- Current comparable activity
- 3
- Peak comparable activity
- 10Nov 12 09:00
- Change in the past 24 hours
- -49%
Trends compare the same fully observed participants, which may cover fewer participants than current activity. Move the pointer or tap the chart to inspect hourly activity; use the left and right arrow keys with a keyboard.