Skip to content

santicalderon/burnstop

burnstop

Stop AI agents from burning your money. Pre-flight budget gate. Hard-stop before token-1. ~$0.001 per check.

I built this after my own autonomous platform hit runaway LLM costs — loops that looked like progress but were burning through budget with zero output. The model causing the loop is the same one you'd ask to self-throttle. That doesn't work. burnstop is the primitive that lives outside the model's context.

test MIT

# Via GitHub (available now):
pip install git+https://github.com/santicalderon/burnstop

# Via PyPI (coming soon):
# pip install burnstop
import burnstop
burnstop.install(budget_envelope_usd=5.00, model="claude-3-5-sonnet")

# your existing code, unchanged:
from anthropic import Anthropic
client = Anthropic()
client.messages.create(...)   # burnstop intercepts, raises BudgetExceeded if over envelope

That's the entire integration. Drop-in. No refactor.


Why this exists — four real incidents

Date Stack Loss Source
Jul 2025 Replit AI prod DB + 1,206 records Fortune
Nov 2025 LangChain + A2A (11-day loop) $47,000 Medium
2026 LangGraph weekend autonomous refactor $4,200 DEV.to
Apr 2026 Cursor + Claude PocketOS DB wiped in 9s, 30h outage OECD.AI

Same shape every time: no per-run budget that lives outside the model's context. The model that loops is the same one you would ask to self-throttle. burnstop is the primitive that fixes it.

What burnstop does

Before each tool call:

  1. Estimates the projected $ cost (cache_creation + cache_read + output decomposition the response headers don't expose — see anthropic-cookbook#46829)
  2. Returns OK if within envelope, raises BudgetExceeded if not
  3. After the call lands, records actual cost and updates running total
$ burnstop demo --budget 0.30
[burnstop] OK call=1 proj=$0.0442 left=$0.3000
[burnstop] CALL#1 actual=$0.0435 cache_read=0% cumul=$0.0435
[burnstop] OK call=2 proj=$0.0442 left=$0.2565
...
[burnstop] 402 BUDGET_EXCEEDED: would_spend=$0.0442 envelope_left=$0.0390

Framework adapters

burnstop ships as a core library + drop-in adapters for every major agent framework:

Adapter Install Framework
burnstop-langchain pip install burnstop-langchain LangChain callbacks
burnstop-langgraph pip install burnstop-langgraph LangGraph nodes
burnstop-autogen pip install burnstop-autogen AutoGen agents
burnstop-crewai pip install burnstop-crewai CrewAI crews

Each adapter wraps the same Receipt primitive — one budget envelope, same BudgetExceeded exception, works across frameworks.

Manual usage (without monkey-patch)

from burnstop import Receipt, BudgetExceeded

r = Receipt(budget_envelope_usd=5.00, model="claude-3-5-sonnet")
try:
    r.check(input_tokens=4500, max_output=2048)
    # ... your call lands ...
    r.record(actual_response_body=response)
except BudgetExceeded as e:
    # graceful stop, don't retry
    log.warning(f"agent stopped at envelope: {e}")

Maintainer

See AGENT_CARD.md for the substrate this is built on.

Ecosystem

License

MIT — see LICENSE.


Built on kernel

burnstop is part of the kernel autonomous AI Business substrate.

About

Pre-flight budget gate for AI agent runaways. Drop-in. Hard-stop before token-1. LangChain · LangGraph · AutoGen · CrewAI

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages