AgentBudgetManager
Per-agent spending caps for autonomous AI wallets.
Overview
AgentBudgetManager enforces spending limits on agent wallets. Before an agent can charge against a plan, the budget manager checks that the agent has not exceeded its authorized spend for the current period.
This is set by a controller — your backend wallet — not the agent itself. The agent cannot raise its own spending cap.
Key functions
| Function | Caller | Description |
|---|---|---|
setBudget(agent, limit, windowSeconds) | Controller | Set or update a spending cap for an agent address |
revokeBudget(agent) | Controller | Remove an agent's budget entirely |
getBudget(agent) | Anyone | Returns limit, spent, remaining, and resetsAt timestamp |
checkBudget(agent, amount) | CronRegistry (internal) | Reverts if agent would exceed their budget |
How it integrates
When an agent wallet calls subscribe() on a plan markedagentCompatible: true, CronRegistry callsAgentBudgetManager.checkBudget() before proceeding. If no budget is set for the agent, the call reverts.
Charges also run through the budget check — the agent's spent total increments each billing cycle. When the window resets, the spent counter resets to zero.
Example
// Controller sets a $100/month budget for the agent
budgetManager.setBudget(
agentAddress,
100 * 1e6, // $100 in USDC (6 decimals)
30 days
);
// Agent can now subscribe to plans totaling up to $100/month
// After $100 in charges, further subscriptions revert until the window resets