Every security conversation about AI agents eventually lands on the same question: if this agent goes wrong, what is the worst thing it can do? For agents that can pay for things, the honest answer is usually "spend everything it has access to". A prompt injection, a buggy retry loop, a vendor that overcharges, or a leaked credential all end the same way: money leaves faster than a human notices.
You cannot make an agent impossible to compromise. You can decide, in advance, how many dollars a compromise is worth. This post covers how to design agent spending limits so the blast radius is a number you picked, not whatever happened to be on the card.
Why "the agent has a card" is the wrong model
The simplest way to let an agent pay is to give it something that pays: a card number, an API key on a billing account, a hot wallet key. Each of these has the same problem. The limit is whatever the underlying account allows, and that limit was set for a human who checks statements, not for a process that can make hundreds of calls a minute.
Agents also make the failure modes worse:
- Loops. An agent that retries a failed paid call can pay for the same thing many times if nothing on the payment side recognizes a repeat.
- Injected instructions. Content the agent reads can tell it to pay someone. If the payment tool accepts any recipient, the agent is one convincing paragraph away from a transfer. We covered the credential side of this in prompt injection and credential theft.
- Shared authority. One payment method used for every vendor means one compromise reaches every vendor. That is the confused deputy problem with a balance attached.
A useful spending limit has to hold even when the agent itself is the adversary. That rules out limits the agent enforces on itself, like a system prompt that says "never spend more than ten dollars".
Two ceilings, enforced by different things
The design Notlogin uses stacks two independent limits, each enforced by something the agent cannot talk its way past.
Level 1: a budget on the credential
When a human authorizes a vendor, the per-vendor credential they issue carries a budget in USDC alongside its scope and expiry. The budget is inside the signed payload, so the agent cannot raise it, and it is tracked by the broker against the credential's unique nonce.
When the agent asks the broker to pay, the broker verifies the credential's signature, expiry and revocation, then computes what has already been spent against it. Anything beyond budget - spent is refused with HTTP 402 before a transaction is ever built. This is the limit that protects you from a vendor that overcharges or an agent that loops: the ceiling is per vendor, and it is a software ledger the human sets.
Level 2: the balance in the wallet
The second ceiling is the managed wallet that actually holds the funds. Notlogin custodies one wallet per user, and the human funds it with USDC. Whatever the ledger says, the agent cannot move more stablecoin than the wallet holds on-chain. If the software ledger had a bug, the balance is still the hard stop.
The budget answers "how much may this agent spend at this vendor?" The balance answers "how much could anything spend, in the worst case?" Fund the wallet only with what you are willing to lose and the second answer becomes a number you chose.
Count reservations, not just settlements
A budget that only counts completed payments has a race in it. If an agent fires ten payment requests at once and each one checks "spent so far" before any of them settles, all ten can pass the check.
The fix is to count money that is committed, not just money that has moved. In Notlogin's ledger, a payment that has been authorized but not yet presented, one waiting for human confirmation, and one currently settling all count as spent. Only declined, expired or failed payments free their share of the budget. Concurrent requests therefore cannot add up to more than the budget, because each one reserves before the next one checks.
The cost: an authorization the agent never uses stays reserved until reconciled. That is the right default — when in doubt, money stays unspendable rather than spendable twice.
Make retries safe with idempotency keys
Loops are the most common way a well-meaning agent overspends. The defense is an idempotency key: the agent sends a key it chooses with each payment, the broker records the payment row before calling the chain, and a replay with the same key returns the first outcome instead of paying again.
For agents, treat this as mandatory even where an API makes it optional. Derive the key from the thing being paid for (an order ID, a request hash) rather than generating a fresh random value on each retry, or the protection disappears exactly when you need it.
Pin where the money can go
Capping how much an agent spends limits how fast a compromise drains a wallet. It does not limit who receives the money. A budget of fifty dollars that the agent can send to any address is still fifty dollars to an attacker.
So the recipient should be fixed by the vendor, not supplied by the agent. When a vendor registers a payout address with Notlogin, payments made under that vendor's credential are pinned to it: the agent cannot substitute another recipient, and vendors can additionally prove they control the address by signing a challenge. Withdrawals to an arbitrary address are a separate, session-only action for the human, not something an agent credential can trigger.
If you are building agent payments yourself, this is the single highest-value rule: the code path an agent can reach should never accept a free-form recipient.
When the vendor pulls instead of the agent pushing
Some vendors want to charge a user directly, the way a card on file works. Notlogin supports this as a separate grant the human gives at consent time, with its own budget cap and expiry, and only for vendors with a pinned payout address. On top of the cap:
- Charges at or below a threshold the user picks settle automatically, with a notice email.
- Charges above it go to pending and wait for the human to approve or decline, reserving budget in the meantime.
- A rolling daily limit counts every attempt, so a vendor hammering the endpoint gets rate-limited rather than retried into success.
- A settled charge can be disputed, which also revokes the grant.
The pattern generalizes: small amounts flow without friction, large ones need a human, and the total is still bounded by the cap.
Budgets, revocation and expiry are separate controls
A budget is not a kill switch. It limits the total; it does not stop an agent that is spending within limits but doing the wrong thing. For that you need revocation, which takes effect on the next verification, as described in how to revoke AI agent access. And expiry bounds how long a forgotten grant stays live.
You want all three, and you want them per vendor, so tightening one vendor does not break the rest.
A checklist for limiting agent spending
- Put the spending limit somewhere the agent cannot edit: a signed credential and a server-side ledger, not the prompt.
- Scope budgets per vendor so one compromise does not reach every account.
- Count reservations and pending payments as spent.
- Require idempotency keys on every payment an agent can trigger.
- Pin recipients on the server; never let the agent choose who gets paid.
- Fund the agent's wallet with what you are willing to lose, and treat the on-chain balance as the last ceiling.
- Keep revocation and expiry as separate, faster controls.
For the payment flow itself, see how AI agents pay with x402. If you run agents and want per-vendor budgets with a funded wallet as the hard stop, create a Notlogin account. If you run a service that agents pay, register as a vendor and pin your payout address.