-
-
A listing hides text only AI agents can read. A third-party agent obeys it and orders the $129 bundle against an $80 mandate.
-
A false "never arrived" claim: every rule passed and PayPal tracking says delivered, so the merchant keeps the payment.
-
Case log (AG Grid): every case with its PayPal order and outcome; sortable and filterable.
-
Trust ledger (AG Grid): agents, buyers and shops with a track record, and what each flag changes.
-
Flight recorder: every agent step and every PayPal call, from signed mandate to refund.
-
Pre-payment gate: a flagged agent's order is refused before any money moves.
-
The buyer complains. Fixed rules find the price cap broken, so the agent is at fault and PayPal refunds the buyer automatically.
Inspiration
AI agents are starting to buy things for people, and PayPal is building the rails for it. But refund and dispute systems assume a human clicked "buy". If an agent overspends or is tricked by a product page, nobody can say who is at fault: the buyer, the shop or the agent. Buyer and seller protection is what PayPal is known for with human shoppers, so I built it for agent shoppers.
What it does
Recourse is a referee for purchases made by AI agents.
- Signed mandate. The buyer says what they want in plain words. Claude drafts the limits (item, price cap, quantity, allowed shops, expiry) and the buyer signs them.
- Flight recorder. Everything the agent does is logged: what it searched, which listings it opened, what it asked PayPal for.
- Resolver. When the buyer complains, Recourse compares the PayPal order with the signed mandate and PayPal's shipment tracking, then acts:
- The agent broke the mandate: PayPal refunds the buyer automatically.
- The agent stayed inside it and the item was delivered: the shop keeps the money and gets an evidence packet.
- Unclear: a person decides.
- Pre-payment gate. Optionally checks the order against the mandate before PayPal creates it, so a bad order never moves money.
- Trust ledger. Keeps a track record. Agents that keep breaking mandates, buyers whose complaints keep being rejected, and shops whose listings carry hidden instructions for agents are flagged, and each flag changes what Recourse does next.
The demo store includes a listing with hidden text aimed at AI agents (a prompt injection). A simulated third-party agent obeys it and overspends; Claude's agent reads the same text and ignores it.
How I built it
- PayPal Agent Toolkit (
@paypal/agent-toolkit) against the sandbox for every PayPal call: creating the order, capturing after wallet approval, reading the order back, refunding, and registering and reading shipment tracking. The shopping agent and the resolver use the same toolkit tools. - Claude through the Anthropic API for three jobs: drafting the mandate from plain words, running the shopping agent with tool use, and reading a complaint to say what is being claimed and whether the item matches the request.
- Rules, not a model, decide the money. The refund decision and the trust-ledger marks are plain TypeScript with unit tests. A low-confidence AI answer escalates to a person instead of moving money.
- Next.js and TypeScript for the app and dashboard.
Challenges
- Claude would not be tricked. I planted hidden instructions in a listing and Claude's agent ignored them, so I added a scripted "compromised" agent to show what a less careful agent does. Everything after its choice (order, capture, refund) is a real sandbox call.
- Sandbox regions. A US test buyer paying my default India sandbox merchant was declined for regulatory reasons. Creating a US sandbox merchant and an app tied to it fixed it.
- Response shapes. The capture response did not include the capture details I needed for refunds and tracking, so the app reads them back from the order.
Accomplishments
- Both sides of a dispute work end to end on real sandbox calls: an automatic refund when the agent is at fault, and merchant protection when the buyer's claim is false.
- The decision is explainable: six rule checks, two AI answers with a confidence score, and a recorded timeline.
- A flagged agent is blocked before payment on its next attempt.
What I learned
Agent identity is being worked on across the industry, but a record of how agents, buyers and shops actually behaved needs a party that resolves the disputes. That record falls out of the dispute process almost for free.
What's next
- Buyer-held keys (passkeys) for signing mandates, so the server cannot forge consent.
- A vaulted PayPal payment method, so the buyer approves once when signing the mandate.
- Handling disputes opened in PayPal's Resolution Center: the code path exists but I have not exercised it end to end.
- Binding ledger identities to an agent-identity standard and the PayPal payer id.
Sponsor tools
- AG Grid powers the Trust ledger tab: one grid for agents, buyers and shops, and a case log with each case's PayPal order and refund. Both sort and filter on any column and share a search box, and clicking a case opens it.
- Render hosts the live demo from a
render.yamlblueprint: https://recourse-c0os.onrender.com (free tier, so the first load can take up to a minute).
Built With
- ag-grid
- anthropic
- claude
- next.js
- node.js
- paypal
- react
- render
- tailwindcss
- typescript