The reservation broker is a thin hop between the agent platform and every downstream service that has no spend reservation of its own. Downstream might be a model API with only requests-per-minute and tokens-per-minute caps, a search provider billed per call, or an internal microservice. Hosted providers set those limits at organization or project scope and expect you to handle finer grain yourself agentgateway's analysis of provider limits. The broker adds the missing layer: it sees call history, session identity, and cumulative consumption before dispatch the token budget controls guide.
The broker keeps four things:
- The pool. A single tracked balance for the parent run, plus whatever the platform has granted the tenant above it.
- Allocations. A fixed number of capacity units held per sub-agent, created at spawn and closed at termination.
- The ledger. Append-only entries for every grant, hold, settle and release, keyed by sub-agent ID.
- The decision log. One structured record per admission decision, including refusals.
Two properties matter more than the data model. First, admission must be prospective: price the next request at its worst case, check it against the remaining balance, and refuse before the money leaves the per-run budget reservation pattern. Second, the check and the deduction must be one atomic operation, because two concurrent workers that both read "remaining: 10" will both proceed and spend 20 Cycles' write-up on hard limits.
A minimal schema for the allocations table:
CREATE TABLE reservation (
reservation_id TEXT PRIMARY KEY,
parent_run_id TEXT NOT NULL,
subagent_id TEXT NOT NULL,
currency TEXT NOT NULL, -- ledger unit, e.g. "usd_micro" or "tokens"
granted BIGINT NOT NULL, -- lifetime ceiling for this sub-agent
held BIGINT NOT NULL DEFAULT 0,
spent BIGINT NOT NULL DEFAULT 0,
state TEXT NOT NULL, -- open | draining | closed
version BIGINT NOT NULL, -- optimistic concurrency
spawned_at TIMESTAMP NOT NULL,
closed_at TIMESTAMP
);
granted - held - spent is the sub-agent's headroom. Every decrement of headroom goes through one UPDATE ... WHERE version = ? statement so the read and write cannot interleave.



