Skip to main content

Budgets

Goal: cap what a flow or an agent may spend, and extend the cap when a person is asked.

Prerequisites​

  • A Flow or an Agent manifest to add the budget to.

Steps​

  1. Add a budget to the flow's spec (a ticket ceiling) or to an agent's spec (a per-agent ceiling). Every dimension is optional. An absent dimension is no limit:

    kind: Flow
    spec:
    budget:
    tokens: 200000
    toolCalls: 200
    costUsd: 5
    wallTime: 30m
    maxTurns: 40
  2. 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]
  3. Run the flow. For basic and deep, the engine checks the budget against the ticket's ledger before each model call and each tool call. For acp, it checks the model budget before the prompt, and the tool budget on notifications that may already be in_progress or completed. When the ledger refuses a call, the engine cancels the turn. For a model call, it counts the tokens the next call would add.

  4. When an alert or a limit fires, the ticket pauses (paused_budget) and a person answers:

    afe resume T-0001 continue
    afe resume T-0001 extend
    afe resume T-0001 stop

    extend widens the dimension by half its limit. stop fails 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. extend raises 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.

See also​