Skip to main content
An agent framework runs an agent as a series of steps: plan, call a model, call a tool, and so on. Stigg fits into a run in two places:
  • 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 with stigg.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:
The check asks for the credits the next step is expected to cost, so a run does not start a step it cannot finish. See Requested usage.