token-budget-contracts v0.3.0 — LangGraph/CrewAI adapters + OpenTelemetry for multi-agent token governance

Reddit r/AI_Agents Tools

Summary

token-budget-contracts is a library for governing token spend across multi-agent systems. Version 0.3.0 adds native adapters for LangGraph and CrewAI, plus OpenTelemetry integration for monitoring budget activity.

Posted here a while back about token-budget-contracts, my library for governing token spend across multi-agent systems. Core idea: each agent gets a priority and a budget, and when one runs dry mid-task, spare tokens reallocate from idle or lower-priority agents instead of the whole thing failing. Plus confidence-gated spending, so an agent stops burning tokens once it's already confident in its answer. The most common question last time was "does this actually plug into my framework?" So v0.3.0 is mostly about that: Native LangGraph adapter — nodes are just callables taking state and returning an update, so you wrap them directly: python: from tbcontracts.adapters import TBCGraphGovernor gov = TBCGraphGovernor() gov.register("researcher", priority=3, max_tokens=4000) gov.register("critic", priority=1, max_tokens=2000) graph.add_node("researcher", gov.wrap("researcher", researcher_node, usage_key="tokens_used")) graph.add_node("critic", gov.wrap("critic", critic_node, usage_key="tokens_used")) Native CrewAI adapter — governs at the stable boundary (the callable that runs an agent's task), reads exact usage via a usage_fn you pass in. OpenTelemetry integration — every governance decision emits a tbc.* span (reallocation, gate-block, usage recording) with attributes for agents involved and tokens moved. Watch budget activity in Grafana/Datadog/Honeycomb next to your existing agent traces. Opt-in, no hard dependency. Exact accounting — feed real token counts from your provider's API response instead of estimates. pip install token-budget-contracts Still early and actively developed. The adapters are unit-tested against the framework call contracts but I'd especially value feedback from anyone running them inside a real LangGraph or CrewAI graph — curious whether the usage_key/usage_fn approach fits how you actually track tokens, or whether it feels awkward. Issues and PRs welcome.
Original Article

Similar Articles