Skip to main content

⚡ AgentBreaker

A real-time circuit breaker for AI agent loops.

AgentBreaker monitors token spend, iteration count, and cost velocity across multi-step LLM orchestration — and hard-stops runaway agents before they burn through budget or get stuck in infinite loops.

Most teams only set max_tokens on a single LLM call. AgentBreaker works at the orchestration layer — across multiple LLM calls, tool invocations, and sub-agent spawns. Observability tools tell you an agent went wrong after the fact. AgentBreaker stops it while it's happening.


The Problem

AI agents that loop, retry, or spawn sub-tasks can silently burn through API budgets in minutes. A max_tokens cap on one call doesn't catch an agent that makes 50 calls in a row. Teams find out when the bill arrives.

What AgentBreaker Does

  • Tracks cost, token usage, iteration count, and elapsed time live, per agent run
  • Evaluates every LLM call against a configurable rule engine
  • Hard-stops the agent the instant a rule fires — not after the fact
  • Surfaces exactly which rule fired and why, with full run history and cost trajectory

Features

  • Composable rule engine — not hardcoded thresholds. Pick which rules apply per run:
    • Total Cost Limit
    • Max Iterations
    • Max Run Time
    • Spend Velocity (catches fast burns)
    • Stuck Loop Detector (same tool called repeatedly)
    • Cost Anomaly Spike (single call costs way more than average)
    • Long Run Warning (soft warning, doesn't stop execution)
  • Live dashboard — real-time cost trajectory chart, run history, trip alerts with estimated savings
  • REST API — start runs, poll status, fetch aggregate metrics
  • Fully containerized — docker compose up and you have a working demo

Tech Stack

Layer Tech
LLM Provider Groq (Llama 3.3 70B)
Agent Framework LangChain
Backend FastAPI + SQLAlchemy + SQLite
Frontend React + Recharts
Infra Docker + Docker Compose
CI GitHub Actions

Architecture

agentbreaker/

backend/ agent.py # Demo "runaway" research agent circuit_breaker.py # Core breaker — tracks state, evaluates rules rules.py # Rule engine + built-in rule library database.py # SQLAlchemy models, SQLite setup main.py # FastAPI app — endpoints + background run execution frontend/ src/App.js # Dashboard — run form, history, live detail view docker-compose.yml


Quick Start (Docker — recommended)

  1. Clone the repo:
   git clone https://github.com/YOUR_USERNAME/agentbreaker.git
   cd agentbreaker
  1. Get a free Groq API key at groq.com (no credit card required).

  2. Create a .env file in the project root:

   echo "GROQ_API_KEY=your_key_here" > .env
  1. Run it:
   docker compose up --build
  1. Open http://localhost:3000

Local Development (without Docker)

Backend:

cd backend
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reload --port 8000

Frontend (separate terminal):

cd frontend
npm install
npm start

API Reference

Method Endpoint Description
POST /runs Start a new agent run
GET /runs List all runs
GET /runs/{run_id} Get a single run's live status
GET /rules List all available rules
GET /metrics Aggregate stats across all runs
DELETE /runs Clear all run history

Roadmap

  • Phase 1 — Core breaker logic, demo agent, FastAPI backend, React dashboard
  • Phase 2 — Composable rule engine, per-run rule configuration
  • Phase 3 — Semantic loop detection, goal drift detection, anomaly baselines
  • Phase 4 — LangChain callback handler for zero-friction integration, PyPI package

License

MIT

Metadata

Release files for agentbreaker-sdk 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentbreaker-sdk 2.1.0
File Size Uploaded Provenance Actions
agentbreaker_sdk-2.1.0.tar.gz 15.2 kB Without provenance Details for agentbreaker_sdk-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agentbreaker-sdk 2.1.0
File Interpreter ABI Platform Actions
agentbreaker_sdk-2.1.0-py3-none-any.whl Python 3 none any Details for agentbreaker_sdk-2.1.0-py3-none-any.whl

Total release size: 30.4 kB

Release files / agentbreaker_sdk-2.1.0.tar.gz

Download URL agentbreaker_sdk-2.1.0.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3e9695453ad6af6c0ebde5b059bbe5594a9ba96fd94531907d36635084f50d88
BLAKE2b-256 checksum
How to use checksums
8120e259c3a3bde9d4413de80de6ecb5c36b17ca434d4673814e64492b788a8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / agentbreaker_sdk-2.1.0-py3-none-any.whl

Download URL agentbreaker_sdk-2.1.0-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22195511cb4b93bb78bd30208bfdfbd3b112aa4ef1a4b4994cf2297483e15cc6
BLAKE2b-256 checksum
How to use checksums
1d7c26e6b8ea85643eb04e3df36711a951d8f6dba86475cbf9566a684302d5a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for agentbreaker-sdk 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page