Budgets
Goal: cap what a flow or an agent may spend, and extend the cap when a person is asked.
Prerequisites
- A
Flowor anAgentmanifest to add the budget to.
Steps
-
Add a
budgetto the flow'sspec(a ticket ceiling) or to an agent'sspec(a per-agent ceiling). Every dimension is optional. An absent dimension is no limit:kind: Flowspec:budget:tokens: 200000toolCalls: 200costUsd: 5wallTime: 30mmaxTurns: 40 -
Set the alert fractions at which a person is asked, when the defaults (
0.75,0.9) do not fit:spec:alerts: [0.5, 0.9] -
Run the flow. The engine checks the budget against the ticket's ledger before each model call. It counts the tokens the next call would add.
-
When an alert or a limit fires, the ticket pauses (
paused_budget) and a person answers:afe resume T-0001 continueafe resume T-0001 extendafe resume T-0001 stopextendwidens the dimension by half its limit.stopfails the ticket at that point.
See Budgets and loop guards for why the ledger is the source of truth, and Answer approvals for the other pauses.
Troubleshooting
'agent' does not report its cost (reportsCost is not true) (a validation warning)
An acp agent has a costUsd budget, but its AcpAgent manifest does not set
reportsCost: true. The engine cannot check a cost ceiling it never receives. Set
reportsCost: true if the agent reports cost, or drop costUsd from its budget.
The ticket pauses more often than expected
A lowered alerts fraction fires earlier. Check the flow's alerts before assuming the ledger is
wrong: afe inspect T-0001 shows the totals it paused on.