- Every model call inside the run goes through a wrapped client, so it is checked and metered like any other call.
- Between steps, you check whether the agent still has budget for the next step, and decide what to do if it does not. Running out then becomes a normal path in the run, such as offering the customer more credits or asking an admin to raise a budget, instead of an error halfway through.
Wrap the model client the framework uses
Create the model client withstigg.wrap(), and pass the wrapped client to the framework wherever it accepts one. Every model call the framework makes is then checked and metered, with no other changes. See LLM and gateway wrappers.
Check the budget between steps
Add a step that checks the budget before an expensive part of the run, and route on the result. In LangGraph, put the check in a node and route with a conditional edge:Related
- Agent governance: give each agent its own budget.
- Gating actions that are not model calls: check and report tool calls.