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. For
basicanddeep, the engine checks the budget against the ticket's ledger before each model call and each tool call. Foracp, it checks the model budget before the prompt, and the tool budget on notifications that may already bein_progressorcompleted. When the ledger refuses a call, the engine cancels the turn. For a 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.
The ticket budget is shared
A flow budget is the ticket's ceiling, not a node's. Every node and every map branch counts its
calls and tokens against it. An Agent budget stays that agent's own ceiling.
- One threshold of the ticket raises one question, even when several branches cross it at the same time. The branches wait on that one question.
- The question says the ceiling is the ticket's.
extendraises it for every node and branch. The nodes that run later use the new ceiling too. - At 100% no branch starts a new tool call. The calls already running finish.
The ticket's decisions live in the store, so they survive a pause and a restart. Calls in flight do not.
The question you see
Each pause names the ceiling the answer changes. A branch alert says the ceiling is that branch's own:
tool calls at 75% of this branch's own budget (node investigate/researcher[2], branch 2)
A ticket alert says the ceiling is shared:
tool calls at 75% of the ticket budget, shared by every node and branch; extend raises it for all of them
The engine asks one question at a time. A branch alert and a ticket alert raised together become two
questions, and so do two branches that cross their own budgets. extend changes only the ceiling
the question names.
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.