@tmigone Opening this as a suggestion / discussion, not a bug. Feel free to convert it to a Discussion.
Update (revised after production feedback): someone running x402 in production corrected the original premise of this issue, and they're right, so I've rescoped it.
What I got wrong
I originally framed this as "x402 makes you pay on the request, not on a successful result." That is not an x402 property, it's an implementation choice. The signed authorization and the settlement are separate steps, and the server decides when to settle. A handler can validate everything first and only settle when it returns success; on rejection it returns 4xx and the buyer's authorization simply expires unused, so nobody eats a failed call. The standard Next x402 wrapper does this out of the box. Settlement also doesn't have to block the response, you can count and settle after the response is already on the wire. So per-call "pay only for what succeeded" already exists today, and the latency cost isn't inherent either.
The actual open problem
The amortized case. When an agent makes many small queries in a short burst, you don't want a facilitator round trip per call in the hot path, and you don't want N separate settlements. Batched or session settlement — many queries reconciled into a single settlement — is the piece that doesn't have a clean answer yet in the x402 client.
Shapes worth exploring
- Prepaid balance. Caller tops up once, the server draws it down per query with no per-call settlement, and re-challenges when the balance is empty.
- Signed vouchers / escrow. Caller signs incrementing off-chain vouchers, the server redeems the latest one on chain in a single tx, unspent funds return on close. The Graph already has essentially this in TAP (receipts aggregated into RAVs, redeemed in batches), so the pattern is proven in-stack.
Open question: is any batched/session settlement already on the radar for the x402 client?
@tmigone Opening this as a suggestion / discussion, not a bug. Feel free to convert it to a Discussion.
Update (revised after production feedback): someone running x402 in production corrected the original premise of this issue, and they're right, so I've rescoped it.
What I got wrong
I originally framed this as "x402 makes you pay on the request, not on a successful result." That is not an x402 property, it's an implementation choice. The signed authorization and the settlement are separate steps, and the server decides when to settle. A handler can validate everything first and only settle when it returns success; on rejection it returns 4xx and the buyer's authorization simply expires unused, so nobody eats a failed call. The standard Next x402 wrapper does this out of the box. Settlement also doesn't have to block the response, you can count and settle after the response is already on the wire. So per-call "pay only for what succeeded" already exists today, and the latency cost isn't inherent either.
The actual open problem
The amortized case. When an agent makes many small queries in a short burst, you don't want a facilitator round trip per call in the hot path, and you don't want N separate settlements. Batched or session settlement — many queries reconciled into a single settlement — is the piece that doesn't have a clean answer yet in the x402 client.
Shapes worth exploring
Open question: is any batched/session settlement already on the radar for the x402 client?