HomeUse cases › How to set spend limits for AI agents
Use case

How to set spend limits for AI agents

Cap what an AI agent can spend with a cumulative limit enforced across every call it makes — not a per-call check that a loop can bypass.

The problem with per-call checks

A per-call limit ("no charge over $100") does nothing against a loop that makes a thousand $99 charges. What you actually want is a cumulative cap: this agent may spend at most $50 total, ever, across all calls under this warrant. That requires state — a running total the enforcement point tracks.

A stateful spend cap

Liceat's spend_limit caveat is cumulative and stateful. The gateway sums allowed spend per warrant and denies the call that would cross the cap — atomically, so concurrent calls can't race past it.

import { issue, attenuate } from 'liceat';

// Issue a scoped root warrant for an agent…
const { warrant, attenuationKey } = issue(issuerSecret, 'kid-1', {
  principal: 'org:acme', agent: 'agent:assistant',
  caveats: [
    { type: 'resource', patterns: ['mcp:github/*'] },
    { type: 'action', actions: ['read'] },
    { type: 'spend_limit', currency: 'USD', max: 5000 },
    { type: 'expires', at: Math.floor(Date.now()/1e3) + 3600 },
  ],
});
// …then hand a NARROWER one to a sub-agent — authority can only shrink:
const sub = attenuate(warrant, attenuationKey, [{ type: 'action', actions: [] }]);

Amounts are integer minor units (cents). The cap is on the sum of all allowed spends, in the given currency.

Delegation keeps caps honest

If the agent hands work to a sub-agent, it can only pass a narrower warrant — it cannot grant a higher cap than it holds. A $50 agent can delegate at most $50, usually less.

Frequently asked

Is the cap per call or total?

Total (cumulative) across every allowed call under the warrant, enforced by the gateway. You can combine it with a rate limit and an expiry.

Does verification need a network call?

No. A warrant is a signed, self-describing token; the SDK verifies it fully offline against the issuer's public key. Use the gateway when you also want centralized audit, stateful spend/rate limits, and instant revocation.

Give your agents permission, not your keys.

Free to self-host. 10,000 free decisions on the hosted gateway — no card.

Get an API key Read the docs