DEV Community

Igor Ganapolsky
Igor Ganapolsky

Posted on

Your AI Agent Burned $47K Last Night. Here's How to Stop the Next One.

The $47,000 retry loop

In June 2026, a developer on dev.to documented how their Claude Code agent got stuck in an 11-day retry loop. The bill: $47,000 in API tokens.

The agent kept retrying a failing operation. No watchdog. No circuit breaker. No human approval gate. Just a loop that ran unchecked until someone noticed.

This isn't a one-off.

The pattern is everywhere

I've been cataloging AI agent incidents for months. The same failure modes repeat:

  • $47K token burn — agent stuck in retry loop (dev.to, June 2026)
  • $6,531 AWS bill — autonomous agent made unchecked infrastructure changes overnight (HN, 2026)
  • Production database deleted — agent executed a DROP TABLE thinking it was cleaning up test data
  • 28.6 million secrets exposed — agents committed credentials to public repos (GitGuardian 2025 State of Secrets Sprawl)

Every single one was preventable. None of them were prevented.

Why observability isn't enough

Current tools — LangSmith, Langfuse, Helicone — are excellent at showing you what happened. Dashboards, traces, token counts, latency.

But they all share one fundamental limitation: they show you the damage after it's done.

You open the dashboard. You see the $47K bill. You see the database deletion. You see the leaked secret.

Post-hoc. Reactive. Too late.

The missing layer: pre-action gating

What if you could intercept every tool call before it executes?

Not logging. Not tracing. Blocking.

Agent: "I want to run `rm -rf /var/lib/postgresql`"
Gate:  DENY — destructive operation requires approval
Agent: "I want to make 500 API calls to retry this operation"
Gate:  WARN — rate limit exceeded, human review required
Agent: "I want to write credentials to a file"
Gate:  DENY — credential exfiltration pattern detected
Enter fullscreen mode Exit fullscreen mode

This is what I built ThumbGate to do. A pre-action gate that sits between your AI agent and every tool call:

  • ALLOW — normal operations pass through instantly
  • WARN — risky operations are flagged for human review
  • DENY — destructive operations are blocked before execution

It works with Claude Code, Cursor, and any agent that uses tool calls.

The five failure modes a gate prevents

1. Unbounded retry loops

Without a gate: Agent hits an error, retries, hits the error again, retries forever. Each retry costs tokens.

With a gate: After N retries on the same operation, the gate escalates to WARN. After M, it DENYs. The loop breaks before it becomes a $47K problem.

2. Destructive operations

Without a gate: Agent decides to "clean up" and runs DROP TABLE, rm -rf, or DELETE FROM users.

With a gate: Destructive SQL, file deletion, and infrastructure teardown operations are DENYed by default. The agent must get explicit human approval.

3. Credential exfiltration

Without a gate: Agent writes API keys, passwords, or tokens to files that end up in git.

With a gate: Patterns matching secrets, keys, and tokens are detected before write operations. The write is blocked.

4. Infrastructure drift

Without a gate: Agent provisions 47 EC2 instances overnight because it thought it needed more capacity.

With a gate: Cloud resource creation above a threshold triggers WARN. The human gets a notification before the bill arrives.

5. Data exfiltration

Without a gate: Agent reads your entire customer database and sends it to an external API "for processing."

With a gate: Large data reads and outbound transfers to untrusted domains are flagged.

How to get started

Option 1: Self-host the gate (free)

npx thumbgate init
Enter fullscreen mode Exit fullscreen mode

This installs the gate as a local proxy. Your agent's tool calls pass through it. You configure ALLOW/WARN/DENY rules.

Option 2: Agent Reliability Diagnostic ($499)

I'll personally audit your agent setup, identify your specific risk surface, and configure custom gate rules for your stack. You get:

  • Full incident-risk assessment of your agent workflows
  • Custom gate rules for your tool inventory
  • Watchdog configuration for your retry patterns
  • A documented runbook for common agent failure scenarios

Book the diagnostic →

Option 3: Partner Pilot ($1,500/month)

For teams running agents in production. Full managed gate, SLA, custom integrations, and ongoing tuning.

Talk to me →

The honest state of the product

I want to be transparent about where things stand:

  • External revenue: $0 as of July 2026. The product is early.
  • Design partners: Looking for 3 teams to dogfood Continuity (cloud-based agent handoff when your Mac goes offline).
  • What works: The gate logic, watchdog timers, circuit breakers, and rate limiters are all battle-tested in my own agent setup.
  • What's deferred: Usage-based pricing and enterprise compliance packages — waiting for real demand.

Stop being a case study

If your team is using AI agents without guardrails, you're one bad prompt away from being the next incident report.

The tools exist. The patterns are known. The question is whether you install them before or after your incident.


ThumbGate is open source and free to self-host. Paid tiers add managed continuity, cloud handoff, and priority support. Get started →

Top comments (0)