A priority system for token budgets across multiple AI agents
systems can waste tokens when every agent gets a fixed spending cap. A high-value agent may run out in the middle of a task while a less important or idle agent still has unused budget. Contracts is an Python library built to manage this more flexibly.
Each agent gets a priority level and a maximum . When a higher-priority agent is running low, unused tokens can move automatically from lower-priority or idle agents to that agent. Tokens do not move in the opposite direction, and each agent keeps a protected reserve so it is not drained completely.
An agent can also be stopped from spending more tokens once it is already confident enough in its result. The library is , has no , includes 23 tests, and is presented as usable with Python-based setups such as LangGraph, CrewAI, AutoGen, or direct API calls.
Key points
- Fixed token caps can leave important agents short while less important agents keep unused budget.
- Contracts assigns each agent a priority and maximum .
- Unused tokens can flow from lower-priority or idle agents to higher-priority agents, but not the other way around.
- Protected reserves prevent an agent from being drained completely.
- The library is , -free, and aimed at Python agent setups such as LangGraph, CrewAI, AutoGen, or direct API calls.