Agent repeatedly calls tools and burns money; OpenRouter’s four gates stop the loop
OpenRouter uses four gates to deal with an Agent repeatedly calling the same tool: identifying repeated calls, preventing tiny parameter changes from bypassing detection, limiting steps and cost per run, and using API key quota to cover total spending.

- Failed retries resend the full conversation, pushing up per-round cost
- Repetition detection can block identical calls based on consecutive count
- loopKey can normalize parameter differences to identify variants
- Beyond per-run limits, server-side key quota is also needed as a backstop
Official tutorial and product demo; testing was performed by OpenRouter; the figures in this article are internal experiment results and have not been independently retested by third parties.
The invoice endpoint keeps timing out, yet the Agent keeps retrying with the same invoice over and over; you see the call count rising, but it does not stop on its own. OpenRouter’s tests show that this kind of loop not only repeatedly consumes tool calls, but each round also carries a longer conversation history, making each call more expensive. It adds four gates to the Agent SDK: identify and block repeated calls, normalize parameters, limit steps and cost per run, and then use API key quota to guard total spending, with the goal of stopping the loop before the bill spirals out of control.