agentbelt-budget
A lightweight, in-process circuit breaker for LLM token and cost spend. Part of the agentbelt suite.
pip install agentbelt-budget
Quickstart
from agentbelt_budget import Budget, CircuitBreaker, BudgetExceeded
breaker = CircuitBreaker(Budget(max_tokens=100_000, max_cost_usd=5.0, window="24h"))
try:
breaker.check("session-123")
response = call_llm(prompt)
breaker.record_response("session-123", response, model="gpt-4o")
except BudgetExceeded as e:
print(f"blocked: {e}")
What did this actually catch?
print(breaker.impact_report())
# 5 call(s) blocked across 1 session(s) before exceeding budget (1 distinct trip event(s))
Countable events (calls blocked, distinct sessions, trip count) — not a
dollar estimate, since there's no way to know what a blocked call would
have actually cost. .metrics on the returned ImpactReport gives the
same numbers as a plain dict if you want to log or export them.
See the suite README for the
full concept and how this fits with agentbelt-loop and
agentbelt-sampler.
License
MIT
Metadata
Release files for agentbelt-budget 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| agentbelt_budget-0.1.1.tar.gz | 10.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agentbelt_budget-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.7 kB
Release files / agentbelt_budget-0.1.1.tar.gz
| Download URL | agentbelt_budget-0.1.1.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd1d1a54d4fe1feff476a2237bf3f46398b3b68ef75e4efcef4ef2c6625a69e5
|
|
BLAKE2b-256 checksum How to use checksums |
9f438c83ea535224e309d8bbeafc3a9fc19fac016ea6f00d5b9f3e66d0827be1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.
Transparency logRelease files / agentbelt_budget-0.1.1-py3-none-any.whl
| Download URL | agentbelt_budget-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
15d354e58f1b59a5e661155522c3acbea50b83ae9a1605f672230af837cfdfc0
|
|
BLAKE2b-256 checksum How to use checksums |
9c68ec11cb5d86cca5024d1b5781d2b25d7272da31890e20e75e5d71a7e09c61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.
Transparency logSecurity for agentbelt-budget 0.1.1
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for agentbelt_budget-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.
Transparency logA 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.