Inspiration
AI agents are starting to buy things for people, and PayPal can already move the money. But when the agent buys the wrong thing, or the order never shows up, somebody has to pay, and today that means messages, a dispute and a guess about whose mistake it was.
What it does
Every agent purchase keeps a receipt bundle: what the buyer asked for, what the shop listed, what the agent bought and what arrived. When the buyer complains (or a PayPal dispute arrives), six steps run, and the incident page shows each one:
- AI proposes who is at fault (the shop, the agent's operator, the buyer, or unclear) and quotes the record lines it relied on.
- An independent AI judge (a second pass with a different prompt and, by default, a different Gemini model) rules on each quote and lists records that point the other way. It never names an amount or a remedy.
- A fixed rule decides in plain code: every quote must appear word for word in the record it cites, from the right kind of record for the fault named; the judge must agree; confidence must be at least 70%. The rule sets the amount from a capped policy (the AI never sets money), picks who must approve, and stops when evidence is weak, the judge can't be reached, or record text tries to steer the process.
- When it stops, it says what is missing ("Needs more records", e.g. a carrier scan or the agent's mandate). The owner can attach a record and re-run; it is logged as owner-supplied.
- The owner approves, then money moves through PayPal, three ways:
- shop at fault: a refund offer inside PayPal's dispute flow (or a direct refund when no dispute is open);
- operator at fault: the shop keeps its sale and the operator reimburses the buyer by PayPal Payout (the payout ids are saved before sending, so a retry looks up the same batch instead of paying twice);
- buyer's claim contradicted by the records: evidence is prepared and the owner decides what to send.
- A liability ledger records who paid what, next to an append-only audit log.
How it differs from our other entry (Exception Desk)
Exception Desk and Make Good answer different questions. Exception Desk is a guardrail on whether an AI agent may execute a refund or dispute action: one money path (refund), a fixed amount rule ($25 agent limit), and the owner approves. Make Good starts after an agent-made purchase goes wrong and decides who is liable and which way money should move: it reasons over a multi-party receipt bundle (buyer request, shop listing, agent order, delivery), adds an independent AI judge and a verbatim-quote check, routes money three different ways (dispute refund offer, PayPal Payouts from the operator, or defend with evidence), keeps a liability ledger across shop, operator and buyer, and asks for specific missing records instead of guessing. Different PayPal APIs are central (Disputes make-offer and Payouts here, versus Refunds with request-id idempotency and the Agent Toolkit there), with a different data model, different AI design and a different user. Make Good reuses some plumbing from Exception Desk (PayPal HTTP client and sandbox host guard, approval binding, append-only audit pattern, AI provider adapters, the voice-over mixer), and its README says so.
How we built it
- TypeScript on Node 22 with built-in SQLite, plain HTTP API, React + Vite console, Zod schemas for proposer and judge output, Vitest (172 tests, offline).
- PayPal (sandbox host only, enforced in code): OAuth2; Orders v2 create/capture (scripts); Disputes: list/detail,
make-offer(REFUND),provide-evidence,send-message; Refunds on captures; Payouts (POST /v1/payments/payoutswith a pre-savedsender_batch_id, then batch and item GETs); webhook intake (not run against a real delivery). A scripted sandbox buyer (Playwright) approves orders and files disputes in PayPal's own pages to prepare demo cases. - AI: Gemini as proposer (
gemini-3.8-flash) and judge (gemini-3.1-pro-preview) by default; adapters for other providers. Record text is treated as untrusted; the judge's output can only stop a case, never set a remedy or amount. - Eval: 36 synthetic labelled cases, three passes, live models (
docs/EVAL_REPORT.md). A smoke test, not a benchmark: one person wrote the labels. - An AI coding agent did most of the typing on Paul's delegation.
Challenges we ran into
- PayPal's sandbox needs a buyer to approve orders and file disputes in its web pages, so we scripted a sandbox buyer; it is fragile because those pages change (one run hit an Indonesian-language button).
- About 4 minutes pass after a buyer files before the seller can act, and about 2 more after the offer before PayPal resolves; the demo prepares disputes ahead and the app polls PayPal state.
- A partial refund offer needed the buyer to accept it in PayPal's page (accepting via API with merchant keys returned 403); a full-amount offer was settled by PayPal with no buyer step.
- Re-sending a payout with the same
sender_batch_idreturns 400 "already exists" even with the same request id, so the app treats that as "look up the existing batch", never "send again with a new id". - A payout item can be SUCCESS while its batch still reads PROCESSING; the app follows the item.
- In both live dispute runs a FAILED $19.02 refund appeared that we did not issue. We did not find out why, and the README says so.
- Our own eval scoring had a record-id matching bug that first made the judge look much worse; the first scoring is kept in the repo.
Accomplishments that we're proud of
- End-to-end on the real PayPal sandbox through the app, with a live AI proposal: buyer files "item not received", the app proposes shop at fault, the owner approves, the app sends the refund offer, and PayPal resolves the dispute with $20.00 refunded (e.g. dispute
PP-R-PRG-10193448, refund15L83320PH726421K; re-checked read-only Nov 12). - Real PayPal Payouts as the operator's reimbursement: a $15.00 payout in the demo (batch
6L88CLZG2BTJC, item SUCCESS) and three $1.00 runs, one showing the duplicate-batch lookup. - The rule, not the AI, sets every amount, and a quote that is not word for word in its record stops the case.
- On the 36 synthetic cases (108 saved proposals), the rule never paid the wrong party and no steering attempt got the attacker's outcome; the judge was a small extra filter, not a large one. Full numbers and failures in
docs/EVAL_REPORT.md.
What we learned
Liability is a records problem before it is a payments problem: the AI is useful for reading messy records and naming a side, but only if the amount, the caps and the stop conditions are plain code, and the AI's quotes are checked against the records. An independent judge helps less than we expected on our cases, and the honest result is to say so. And PayPal's sandbox behaviour (timing, offer types, buyer steps, batch ids) has to be observed, not assumed.
What's next for Make Good
Run evidence and message sending and webhook verification live, test more dispute types and stages, a separate operator PayPal account instead of a labelled ledger line, a bigger independently labelled eval, a connect-your-shop flow and a hosted demo, then a pilot with a real shop.
AI tools used and how
| Tool | Where | How |
|---|---|---|
Google Gemini gemini-3.8-flash |
Runtime (proposer) | Reads the receipt bundle, names who is at fault with a confidence, quotes the record lines it relied on; JSON checked against a schema. Live in the sandbox runs (Oct 19) and re-run Nov 12 with mock PayPal. |
Google Gemini gemini-3.1-pro-preview |
Runtime (independent judge) | Rules on each quote (supports / background / does not support) and lists unaddressed contradictions; can only stop a case. Live in the eval and on Nov 12. |
| Other provider adapters | Runtime, optional | Same interface, not run live. |
| AI coding agents | Development | Wrote most of the code, tests and docs on Paul's delegation. |
Deepgram Aura 2 text to speech (aura-2-neptune-en) |
Demo video | Voice-over of the demo script. |
Try it out / links
- Repo: https://github.com/spalaai/make-good (public, MIT, main
29077d1) - Demo: no hosted demo; runs locally with zero keys (mock PayPal, recorded AI answers).
- Video: https://youtu.be/RIcfQAMLYi4
Testing instructions for judges
Node 22.13+.
git clone https://github.com/spalaai/make-good && cd make-good
npm install
npm run seed # four example purchases that went wrong
npm run dev # API on http://localhost:8787
npm run dev:web # console on http://localhost:5173 (second terminal)
npm test
Logins owner / owner-demo and agent / agent-demo (only the owner can approve). Open each incident: the shop-at-fault case offers a refund, the operator case sends a payout, the arrived case defends with evidence, the unclear case stops and lists the records it needs. Approving as the agent is refused; approving twice is refused. For the real sandbox, copy .env.example to .env, set PAYPAL_MODE=sandbox, PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET (free sandbox app at developer.paypal.com) and optionally GEMINI_API_KEY with AI_PROVIDER=gemini.