How are you handling token budgets across multiple AI agents in production?
Curious how people here deal with this: when you’ve got several agents working together (a researcher, a writer, a critic, whatever the setup), how do you manage their shared token spend? In my experience most setups just give each agent a flat cap, which means an important agent can run dry mid-task while a less important one right next to it has budget sitting unused.
I ended up building a small open-source library to deal with this on my own projects — Token Budget Contracts (TBC). Each agent gets a priority and a budget; when one runs low, spare tokens automatically flow in from lower-priority or idle agents, never the reverse, and never below a protected reserve. It also stops an agent from spending further once it’s already confident in its result.
from tbcontracts import BudgetManager
manager = BudgetManager()
manager.register_agent("researcher", priority=3, max_tokens=4000)
manager.register_agent("critic", priority=1, max_tokens=2000)
@manager.govern("researcher")
def call_researcher(prompt):
return my_llm_call(prompt)
pip install token-budget-contracts — MIT licensed, 23 tests, no dependencies. Works with any Python-based agent setup (LangGraph, CrewAI, AutoGen, or raw API calls).
Mostly want to know: is this a real pain point for others, or is everyone already solving it some other way (rate limits, observability tools, just eating the cost)? Genuinely curious what people are doing here.