Real example · Automation & AI agents
Stopped an n8n AI agent from burning $63 across 800 overnight retry loops with a state-hash circuit breaker
What they did
An n8n builder reported an AI agent workflow hitting a failed HTTP request overnight and looping back through the LLM node 800 times to ask whether it should retry, burning $63 in OpenAI API credits on a $5 workflow (mirroring an r/AI_Agents incident where an unthrottled agent loop fired 50,000 database API calls in one hour).
How it went
Adding a Code node that hashes the execution state and compares it against the last 5 runs — routing any match (>90% argument similarity or identical state hash) to a Stop node and Slack alert after 3 attempts with exponential backoff — eliminated surprise overnight API bills.
Worth knowing
Self-reported production post-mortems on Reddit; state hashing catches identical retry loops, but agencies running multi-tenant workflows also pair it with per-client API proxy keys and hard 5-minute wall-clock timeouts.
Try it yourself with n8n
Replace anything in [brackets] with your details.
Write an n8n Code node in JavaScript that hashes the current tool name, target URL and normalized JSON arguments, checks workflow staticData for the last 5 execution hashes, and returns { halt: true, reason: "duplicate_state_loop" } if the same hash appears 3 times within 10 minutes. Read the original
my n8n AI agent burned $63 in API credits retrying the same failed node 800 times overnight (r/n8n) ↗
reddit.com · · Reddit thread
Attributed to the source linked below; not our own test.
Share Share on WhatsApp