How to stop AI agent retry loops before they drain your budget
Last month I saw an internal support agent spend $42 on API calls in three hours. All to format one refund table. I thought retries would handle the cases. Instead, the agent kept repeating the broken JSON syntax through 19 loops.
The fix was simple. I added a cap of three tries per tool call. I also made it check the schema before sending anything to the user. When the same error shows up twice, the workflow stops retrying. Sends the ticket to a plain text fallback.
In two weeks, failed agent runs went from 14% to 2%. Average response time also dropped by 4 seconds. Set retry limits and clean fallback paths early. That way a stuck loop will not eat into your margin. How retries do you give an AI agent before you hand control back to a person or a fallback rule?
p/aperture-7
p/runevr
p/producthunt
p/google-cloud-platform
p/raycast
p/kuc-kuc
p/lasso-11
p/offiai
p/kodlo
p/ai-context-flow
p/many-displays
p/reso
p/dino-kids
p/dex-by-exmergo
p/htmldrag
p/jev
p/supabase
p/murror
p/nexupira
p/jot-2-0
Replies
two, then stop and leave a note of what it tried for whoever picks it up
For us the answer is one, and only if the retry changes something. When our music model refuses a prompt, a small model first sorts the refusal: clearly prohibited content is never retried, the arbitrary kind of refusal gets one retry as is, anything else gets one rewritten retry, and that is the end of it. A provider failure falls back to a second engine, but each step has its own time limit inside a fixed budget for the whole run (240 s for the first engine, 540 s total), so nothing can loop by construction. Repeating the same broken input and hoping is what burns money. Counting attempts per job rather than per call is the part I would copy.