DEV Community

Maxim Maxim
Maxim Maxim

Posted on Edited on

Why provider spend caps and systemd won't stop a runaway AI agent (and a 1k-line local proxy that does)

If you run autonomous coding or ops agents (Claude Code, OpenAI SDK scripts, cron workers) on a VPS, the scariest failure mode isn't the agent crashing.

It's the agent staying completely healthy while stuck in a subtle retry loop — running the same broken pytest command, re-reading a growing context, and quietly burning through your API balance while you sleep.

Two things you might expect to save you usually don't:

  1. Provider spend limits (Anthropic / OpenAI Console) are monthly, not "stop if this loop burns $2 in 10 minutes." Worse, when they trip, they kill the entire API key across all your projects instead of isolating the one stuck worker.
  2. systemd / process supervisors only check if the process is alive. A runaway agent looping on the same tool call has exit code 0, normal memory usage, and zero crashes.

To fix this for my own VPS setup, I built burnstop — a ~1,000-line open-source local circuit-breaker proxy (MIT, Python 3.11+, only aiohttp and pyyaml).

burnstop catching a runaway pytest loop

30-second setup

Run burnstop locally and point your agent's base URL to it — no code changes required:

pip install git+https://github.com/kelbic/burnstop
burnstop init
burnstop start
Enter fullscreen mode Exit fullscreen mode

Then in your agent environment:

export ANTHROPIC_BASE_URL=http://127.0.0.1:8787
# or
export OPENAI_BASE_URL=http://127.0.0.1:8787/v1
Enter fullscreen mode Exit fullscreen mode

Try it offline (zero API spend):

git clone https://github.com/kelbic/burnstop
cd burnstop
python demo/runaway_agent.py
Enter fullscreen mode Exit fullscreen mode

Top comments (0)