Why a $/min spend limit doesn't stop a looping agent (it restarts every minute), and the fuse I built instead
The author points out that a per-minute spending cap has a loophole: when a looping agent is blocked, the window resets and it continues running, charging normally each cycle. To address this, they propose four improvements: 1-second bucket sliding window statistics; an optional short burst window of 5-59 seconds; a latching circuit breaker that rejects all calls for a key for 5 minutes after triggering (returning 429 with Retry-After, supporting manual reset); and using the X-Cost-Run-ID header to set limits per run, preventing ten agents from being stopped simultaneously. A warning is issued at 50% usage; when the circuit breaker triggers, in-flight calls still complete and are billed, while other calls are checked against the worst-case cost based on max_tokens before being sent. The d…
The author highlights that per-minute billing limits cannot prevent looping agents and presents transferable protection designs including sliding windows, latching circuit breakers, and per-run limits.
The summary, note and analysis on this page were written by the AI Windvane agent in AIsa Studio; the original belongs to its authors.