npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@monetisebg/circuit-breaker

v0.2.0

Published

Circuit breaker for AI agents — pick budget-guard, loop-killer or worth-it mode and stop runaway token spend, stuck agents or budget overruns in one wrapper. Adapters for LangChain, OpenAI Agents SDK, Claude Agent SDK, Vercel AI SDK and LangGraph Platform

Readme

@monetisebg/circuit-breaker

CI npm version

One wrapper between you and runaway execution.

An agent that loops forever, or quietly burns through your token budget on a single bad run, is a production incident waiting to happen. You usually find out from the bill, or from a thread that never returns.

Circuit Breaker is the one wrapper that stops it. Wrap any supported agent, pick a mode, and the breaker cuts the run short the moment it crosses a limit — before the loop spirals, before the budget is gone.

import { withCircuitBreaker } from "@monetisebg/circuit-breaker/openai-agents";

const safeAgent = withCircuitBreaker(agent); // that's it — 10k/10k token caps by default

await safeAgent.run("Analyze this dataset");

No config to get started. No tokenizer to wire up. No lock-in to one framework.

📖 Full documentation: circuitbreaker.dev/docs

Watch the 1-minute overview — see Circuit Breaker stop a runaway agent in real time.

Circuit Breaker — 1-min explainer

Install

Requires Node ≥ 22.

npm install @monetisebg/circuit-breaker
# + the framework you already use (peer deps are optional — install only one):
npm install @langchain/core@^1.1.47              # LangChain.js
npm install @openai/agents@^0.11.0               # OpenAI Agents SDK
npm install @anthropic-ai/claude-agent-sdk@^0.2  # Claude Agent SDK
npm install ai@^5                                 # Vercel AI SDK
npm install @langchain/langgraph-sdk@^1           # LangGraph Platform SDK

Pick a mode

One wrapper, three behaviours. Set mode and you're done.

| Mode | Stops a run when… | Reach for it when… | | --- | --- | --- | | budget-guard (default) | aggregate input/output tokens cross a cap | you want a hard ceiling on token spend | | loop-killer | the same state recurs more than maxRetries times | agents get stuck re-trying the same step | | worth-it | the projected total cost of the run would blow a budget | you think in money, and want to intervene before it's spent |

// budget-guard — token caps (the default)
withCircuitBreaker(agent, { maxInputToken: 50_000, maxOutputToken: 20_000 });

// loop-killer — kill stuck agents
withCircuitBreaker(agent, { mode: "loop-killer", maxRetries: 3 });

// worth-it — predictive, cost-aware budget gates
withCircuitBreaker(agent, {
  mode: "worth-it",
  budgetLimit: 500,                       // $5.00 in cents
  milestones: ["plan", "fetch", "write"],
  defaultPricing: { inputPerMToken: 300, outputPerMToken: 1500 },
});

worth-it is the advanced one: it costs each step, smooths the trend, and projects the total spend of the run so it can warn, optimize, and finally trip before the budget is gone — not after. Read the deep dive →

Works with your stack

Shipped adapters, each a drop-in wrapper around the framework you already use:

Why developers reach for it

  • Zero-config defaults — sensible caps work out of the box.
  • Visible — emits CircuitBreakerEvents as the run progresses; pipe them to your UI or observability stack.
  • Typed — throws a typed CircuitBreakerError, or routes through your onTrip handler for a graceful fallback.
  • Lean — optional peer deps, no bundled tokenizer. You install only what you use.

Full options, the projection math, responsible-usage guidance, and per-framework guides live at circuitbreaker.dev/docs.

Contributing

We built Circuit Breaker to solve the visceral pain of runaway agent costs and infinite loops — but every execution environment is unique, and we don't have all the answers. The API is intentionally minimal today; our roadmap is driven by how you use (or fight) the tool in the wild.

We especially want to hear from you when:

  • It almost fits — the defaults are 80% right but you need one tweak.
  • You're building workarounds — wrapping our API to force a behaviour.
  • Your use case diverges — strict trading apps vs. loose research agents.

Open an issue, share a gist, or reach out. Your edge cases are our roadmap.

See AGENTS.md for project layout, build/test commands, and the recipe for adding a new framework adapter.

License

Apache-2.0 — © 2026 MonetiseBG