2 minute readNewAgent-ready
One spend budget for a run of small paid calls
A buyer agent that pays for many small calls, such as x402 calls at a cent each, can open one session under your spend policy instead of checking every call. Each call draws its price from the session. When the run ends, whatever was not drawn goes back to your daily cap, and only what was drawn counts as spent.
An agent paying a cent per call had two choices: check every call, which costs a round trip per cent, or reserve the whole run's maximum as one purchase, which held all of it until the agent reported back.
- Open a session: the agent checks once with a maximum (
open_spend_session, orkind: sessionon the check). Your policy judges it like a purchase of that maximum, so a person approves a large budget first if your rules say so. - Draw per call: right before paying each call, the agent draws its price (
draw_session_spend). Draws never pass the maximum, even when they race, and each call still has to be within your most per purchase. - Give the rest back: closing the session (
close_spend_session) returns what was not drawn to the daily cap at once. A session left open returns it when it expires. - Calls that fail or time out: a failed call's draw comes back to the session. One whose outcome is unknown keeps counting until it is reconciled, as for a single purchase.
- Your changes apply mid-run: if you tighten the policy, the next draw judges the session again. A lower cap shrinks what it may still draw, and a blocked seller closes it.
