Governance

Budget

Enforce spend as policy. Antraft meters token usage and dollar cost per run and can deny or pause when a cap is crossed — something no other agent framework does.

Hard vs soft caps

budget.py
runtime = (
Antraft.agent(model, tools, task="...")
.allow(["search_web"])
.budget(max_tokens=200_000, max_cost_usd=5.0) # hard -> deny
.build()
)
 
# soft cap -> pause for human approval instead of denying
.budget(max_cost_usd=2.0, hard=False)
Note
A hard cap denies (and stops) the run when exceeded. A soft cap pauses for approval via the human-in-the-loop flow.

How spend is tracked

  • Token usage is read from each provider response and accumulated on the run context.
  • Cost is computed from a pricing table keyed by model id.
  • The runtime syncs tokens_used and cost_usd into the policy context before every evaluation, so budget checks see the latest totals.
inspect.py
ctx = await runtime.run()
print(ctx.tokens_used) # e.g. 4200
print(ctx.cost_usd) # e.g. 0.0631

Pricing & unknown models

Models not in the pricing table report $0.0 for cost — token budgets still apply. Add entries (or use a known model id) to enable cost-based budgets.

Equivalent policy YAML

policy.yaml
limits:
hard:
max_tokens: 200000
max_cost_usd: 5.0
soft:
max_cost_usd: 2.0 # pause when crossed