GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - devsoniclk/tripwire: Agent cost circuit breaker — prevents runaway loops and token budget burn before cloud bill shock

BranchesTags
Open more actions menu

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
data
data
 
 
docs
docs
 
 
examples
examples
 
 
src/tripwire
src/tripwire
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pyproject.toml
pyproject.toml
 
 

Repository files navigation

tripwire

Follow on GitHub Star on GitHub License: MIT

An agent stuck in a loop can spend your monthly budget in an afternoon. I know because it happened to me. tripwire is the thing I wish I'd had.

It's a budget guard that watches token spend and tool calls in real time. When the agent hits your cap — or starts looping the same call 40 times — it raises BudgetExceeded and stops.

pip install tripwire
from tripwire import Budget, BudgetExceeded

with Budget(max_usd=2.00, max_calls=50, warn_at=0.8):
    run_my_agent()

That's the whole thing for most use cases.


The failure modes it catches

Infinite loops. Agent calls the same tool with the same args over and over. The LoopDetector spots the repeat pattern and trips the breaker before it becomes expensive.

Runaway fan-out. An orchestrator spawns sub-agents that each spin up their own LLM calls. The flat call counter hits max_calls regardless of nesting depth.

Slow leaks. A long-running agent making small calls that look fine individually but add up. The max_usd ceiling catches cumulative spend.


Other integration modes

# decorator
@Budget(max_tokens=200_000)
def nightly_agent(): ...

# callback — feed usage directly from your LLM response
budget.check(model="gpt-4o", input_tokens=1500, output_tokens=300)

# langchain
from tripwire.adapters.langchain import TripwireCallbackHandler
llm = ChatOpenAI(callbacks=[TripwireCallbackHandler(budget)])

Proxy mode

If you'd rather not touch application code:

tripwire proxy --max-usd 5 --upstream https://api.openai.com

Point your SDK at http://localhost:8787 instead. Every request gets metered through the proxy.

Pricing

Bundles a pricing table covering GPT-4o, Claude, Gemini, and others in data/pricing.json. You can override any model:

from tripwire.pricing import override_pricing
override_pricing("my-finetuned-model", input_per_1k=0.002, output_per_1k=0.01)

License

MIT


🌟 Part of the Sovereign Agent Fleet

Engineered by Lakshitha Dananjaya (@devsoniclk) | X / Twitter | dlxconsult.com

⭐ Star this repository to bookmark it and follow @devsoniclk for production-grade agent security and quant trading tools.

About

Agent cost circuit breaker — prevents runaway loops and token budget burn before cloud bill shock

Topics

agent-safetyai-agentscircuit-breakerllm-cost-controlpythonrate-limiting

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.