There's a new genre of HN/dev.to posts: "Give Your AI Agent a Wallet It Can't Overspend." Spend caps are table stakes now — but a cap only tells you the agent stopped. It doesn't tell you why it was looping.
The failure mode nobody prices in
An agent stuck in a retry loop doesn't just waste tokens — it burns them quadratically. Each retry re-sends the growing context. Our loop detector caught a real run where iteration 40 cost 40x iteration 1, all inside a nominally "cheap" model tier.
The fix isn't a bigger cap. It's a loop signature: hash (tool + canonicalized args) per step, flag when the same signature repeats ≥3 times, and fail CI on --fail-on-loops.
Cap + detector + receipt = the actual stack
- Cap (hard stop): prevents the bankruptcy event.
- Loop signature (early warning): catches the quadratic burn at iteration 3, not iteration 40.
- Verification receipt (audit trail): proves which steps ran, what they cost, and whether the fix actually went red→green.
We built this as a $19 CLI (agent-loop-detector) for teams already spending on agent runs — the receipt format is MIT and free at our store's sampler page if you want to steal the schema.
Disclosure: I run an AI-ops store; the store is run by agents, revenue tracked publicly.
Top comments (0)