A Paying Client That Cannot Overspend: Mandatory Caps for x402 Buyer Agents
An x402 buyer SDK that refuses to construct without PaymentCaps: per-call cap, session budget, strict accepts[] validation (never guess decimals), anti-loop guard, payer-binding headers, and an agentbadge pay CLI with --print-only.
@agentbadge/circle-payments ships a buyer-side x402 client that cannot be created without PaymentCaps {maxPaymentUsd, sessionBudgetUsd} — no uncapped mode. Every 402 response is validated before signing (x402Version=2, scheme/network/asset allowlists, extra.decimals===6 — mis-scale is refused, never inferred); spend is recorded at sign/broadcast, a second 402 after payment-signature throws PaymentNotAcceptedError, and paginateAll counts every page against the session budget. The agentbadge pay CLI enforces the same caps and --print-only shows amount/network/payTo before any signature.

On October 10, 2026, we pointed our own agentbadge pay CLI at our own production API, and it refused to pay us. Three times, three different ways: once for the per-call cap, once for the network allowlist, once for the session budget. Every refusal named the exact field and the exact value. Every refusal happened before a signature existed. The wallet balance did not move by a cent. That is not a bug report; that is the feature working, and this article is about how it works.
An agent shopping a paid API in a loop is a small program holding a credit card. If the API starts returning 402s on every retry, or the agent mis-reads a price that shifted, the loop keeps signing payments until the wallet is empty. The failure is rarely the payment rail. It is the absence of a ceiling. So we built the buyer side of @agentbadge/circle-payments on one premise: a paying client without limits is a bug, not a default. There is no uncapped mode. createPayingClient throws a TypeError the moment you omit PaymentCaps, before a single request leaves the process.
Why are spending caps mandatory instead of optional?
Because a cap you can forget is a cap you will forget. The paying client requires {maxPaymentUsd, sessionBudgetUsd} at construction, for example {maxPaymentUsd: "0.50", sessionBudgetUsd: "5"}. Omit them and construction fails with TypeError: PaymentCaps required — refusing to create an uncapped paying client. Passing "0.25" as a number, an empty string, or a non-positive value fails the same way: caps are USD decimal strings validated by regex, and all money math is BigInt on 6-decimal atomic units, never floats.
An optional allowedNetworks array pins which chains the signer may touch. The default is Arc mainnet (eip155:5042) and Arc testnet (eip155:5042002), and the validator enforces it before anything else happens.

What does strict accepts validation reject?
Everything that is not on the contract, and it names what it rejected. Each entry of the accepts[] array in a 402 body must pass five checks: x402Version is 2; scheme is one of exact, eip3009-client-broadcast, or gateway-batch; network is in your allowlist; asset equals the USDC address for that chain; and the amount fits under the per-call cap. Every refusal returns {ok: false, reason, field, value} so an agent can log which field killed the payment and with what value.
The sharpest rule is extra.decimals. If a requirement declares decimals other than 6, the client refuses rather than guessing, because a mis-scaled amount (6 vs 18 decimals) is a classic footgun in token payments. The safe answer is rejection, not inference.
These are not toy tests. The October 10 run against production produced three live refusals, each before any signing:
refused field=amount value="300000": amount 300000 exceeds per-call cap 10000 (atomic units)
refused field=network value="eip155:84532": network "eip155:84532" not in allowedNetworks
refused: Session budget exhausted: spent 0 + requested 300000 > budget 10000 (atomic units)

How does the session budget stop a runaway loop?
The client keeps a cumulative SpendTracker for the session, and the reserve happens before signing. A 402 response goes through validateAccepts → tracker.tryReserve(amount) → only then does the signer see a typed-data payload. A price above the per-call cap throws CapExceededError carrying {cap, requested}; a price that would push cumulative spend over the budget throws BudgetExhaustedError carrying {spent, budget, requested}. In both cases the signer's signTypedData is never invoked. In our test suite the cap-refusal test asserts exactly that: the wallet mock receives zero signing calls when the price exceeds the cap.
Spend is recorded when money commits, not when a 402 arrives: at settle for facilitator rails, at broadcast for self-settle. An onSpend(entry) hook persists each event to whatever store the operator owns; the SDK keeps memory only for the session.
Two compounding protections sit on the same path. First, an anti-loop guard: if the retried request carrying payment-signature comes back with another 402, the client throws PaymentNotAcceptedError instead of paying twice for the same request. Second, paginateAll treats every paginated page as a payment: cursor-based endpoints iterate until exhaustion, each page debit counts against the session budget, and the budget exception propagates mid-iteration instead of silently retrying.
What does the agent actually sign — and when does money move?
Signing is scheme-specific, and signing is not spending. For exact, the signer produces an EIP-3009 transferWithAuthorization typed-data signature; the facilitator settles it later, so a signature alone moves no funds. For eip3009-client-broadcast (Arc self-settle), the client broadcasts the USDC transfer itself and spend is fixed at broadcast; when the requirement declares extra.payerBinding, the retry additionally carries X-Wallet, X-Sig, and X-Timestamp headers proving the payer bound the payment to this request (EIP-191, agentbadge-pay:v1 challenge). For gateway-batch the client signs the BatchEvmScheme payload, and an opt-in gateway.autoDepositUsd option tops up the Gateway wallet before the request instead of failing at settle.
The October 10 run put numbers on the signing-vs-spending gap. Three paid attempts against production hit a server 500 after payment-signature was accepted; the facilitator never broadcast, and the payer balance went from 20.038 to 19.738 USDC only because of a separate successful local settle of 0.30 USDC (tx 0xcc789ccf305d7699cb5fffeee6f89726d06ea2350357e51e2c3d70f6079ef958, block 47933655, on Base Sepolia). Three signatures, zero on-chain settlement on the failed attempts: the ceiling held even when the server did not.

The whole seam in one picture: money can only move through the sign step at the bottom, and you cannot reach it without passing caps, strict accepts validation, and the budget reserve. Every refusal exits with zero spend and a named reason.
How do you run it — and verify before signing?
From code:
const client = createPayingClient({
caps: { maxPaymentUsd: "0.50", sessionBudgetUsd: "5" },
signer: viemSigner(walletClient),
});
const res = await client.get("https://agentbadge.xyz/api/total-scan");
// 402 → validateAccepts → cap-check → sign → retry → spend recorded
From the shell, the same caps discipline is enforced by the agentbadge pay CLI. Caps come from flags (--max-payment, --budget) or env (AGENTBADGE_MAX_PAYMENT, AGENTBADGE_BUDGET); the private key comes only from env (AGENTBADGE_PAYER_KEY), never a flag, because argv is visible in ps. Exit codes distinguish outcomes: 0 ok, 2 refusal/cap/budget, 3 transport.
--print-only is the buyer's smoke test. It decodes the 402, validates accepts, prints the payment details, and exits without ever touching a signer. This is the real output from the October 10 run against production:
agentbadge pay https://agentbadge.xyz/api/total-scan \
--max-payment 0.50 --budget 5 --network eip155:84532 --print-only
# {"scheme":"exact","network":"eip155:84532","asset":"0x036CbD53…",
# "amountAtomic":"300000","priceUsd":"0.3","payTo":"0x9a66…95A5"}
You can wire it into any agent loop as a pre-flight check for exactly the same validation the paid path enforces.

Can a client verify the server's contract before paying?
Yes, because the 402 body the client validates is part of the machine-readable API contract. The server's committed openapi.yaml artifact carries the x402 components (X402PaymentRequired, X402PaymentRequirement, X402HonestRefusal) with x402Version: 2, the scheme enum, extra.decimals: 6, and charged: false pinned as consts. A drift-check in CI (bun run check:openapi) fails if the spec drifts from the live routes. A buyer can diff its validateAccepts expectations against the same artifact the CI enforces; the contract is verified on both sides of the wire, not documented in prose.
Dogfooding caught us too. On the same October 10 run, our catalog declared eip155:5042002 (Arc testnet) while the live 402 offered only Base Sepolia (eip155:84532). The default Arc-only allowlist refused the offer until we passed --network explicitly. Our own validator flagged our own catalog drift, which is the kind of failure you want a validator to cause.
This is C18 in the Arc Campaign series. Previously: Never Charged for a No: a machine-checkable refusal contract. Next: agent skills — capability-scoped discovery for paid surfaces.