Create

Sign in to ReadmeX

or

How we handle your data: Privacy Policy

ReadmeX

Your AI reading companion

What would you like to catch up on?

Pick a briefing, or ask your own question.

Your community and people briefings stay personal to you.

Story

OpenRouter Guide Offers Four Controls for AI Agent Loops

AI summary

OpenRouter published a guide for stopping AI agents from repeatedly calling a failing tool. It recommends doom-loop detection, a rule for identifying repeated calls, per-run step and cost caps, and an API-key credit limit. The first three controls are available through version 0.11.0 of the OpenRouter Agent SDK, while OpenRouter enforces the key limit. In OpenRouter’s tests across six models, all six were blocked on their third identical tool call when detection was enabled. Without detection, 4 of 18 runs retried until a 40-step cap; with it, 16 of 18 runs ended after two real tool calls. Exact-match detection can miss loops that slightly change arguments, which the guide addresses with normalized loop keys.

In-depth insight

The four controls address different failure modes: repeated-call detection, argument normalization, per-run limits, and provider-side spending limits. OpenRouter’s tests provide implementation examples for limiting runaway tool calls and costs.

How to Stop an AI Agent Stuck in an Infinite Loop

OpenRouter ·11/12/2026

How to Stop an AI Agent Stuck in an Infinite Loop
How to Stop an AI Agent Stuck in an Infinite Loop

An AI agent gets stuck in an infinite loop when a model keeps calling a tool that fails, usually with the same arguments, because nothing in the agent loop tells it to stop. Each retry resends the whole conversation, so every turn costs more than the last, and a loop left running overnight can cost thousands of dollars.

This guide stops the loop with four guards, which we tested on six current models. Three run inside your agent through the OpenRouter Agent SDK (@openrouter/agent 0.11.0): doom-loop detection, a rule for which calls count as repeats, and caps on steps and cost. The fourth is a credit limit on your API key. We enforce it on our side, so it holds even when your agent code has a bug.

#OpenRouter#OpenRouter Agent SDK

Original · 12 min readRead the original
Group chat

No comments yet. Start the conversation.