Inspiration

PayPal gave AI agents the power to pay, and businesses want agents that do the boring buying for them: restock supplies, pay supplier invoices. But people don't trust agents with the last step. In Accenture's 2026 survey of 25,590 consumers, 32% would let an agent choose a purchase within limits, yet only 9% would let it complete purchases without a final approval. They're right to worry: agents read untrusted pages and emails, and the oldest scam in the book, "we changed banks, pay this new account", cost US businesses about $3.05 billion in 2025 (FBI IC3). Handing an agent a card or a PayPal login means one poisoned page can drain the account.

We wanted to give a small-business owner the confidence to let an agent pay, the way a leash lets a dog walk ahead of you without running into the road.

What it does

Dana owns Bean There Café. Her ops agent restocks coffee, oat milk and cups, and pays supplier invoices. With Leash:

  • She writes her rules in plain English. Claude compiles them into a policy she reviews as a Rule Card before anything is saved.
  • She approves a real PayPal authorization hold for the week ($500). The agent never gets PayPal credentials; it can only ask Leash to pay.
  • Every request passes a layered guard: deterministic rules, a prompt-injection scanner, and an AI intent judge that checks the payment traces back to Dana's task. AI can tighten a decision, never loosen it.
  • Allowed purchases are partial captures from the hold, and suppliers are paid with PayPal Payouts. Anything over her limit goes to her phone with the reasons and a market-price check.
  • Attacks are blocked and explained: hidden "buy 5 gift cards" instructions on a supplier page, a lookalike invoice with new bank details, payments split to dodge the limit, an invoice paid twice. A blocked attack shortens the leash (the agent's autonomy level drops); a clean track record earns a longer one, but only when Dana accepts.
  • When Claude itself spots the "we changed banks" email and skips it, "Replay with a fooled agent" shows what happens when an agent does fall for it: Leash blocks the payment on its own.
  • Every payment gets a signed, hash-chained intent receipt anyone can verify.
  • At week's end the unused budget is voided back to Dana in PayPal, and next week's hold is placed from her saved PayPal with no one present.
  • The Attack Lab lets anyone try to trick the agent, in a sandbox café with simulated money.
  • Bring your own agent: Leash is an MCP server (Claude Code, Claude Desktop, any MCP client), and withLeash() puts the same guard in front of the PayPal Agent Toolkit's refund and dispute tools.

How we built it

  • Next.js 16 (App Router, Server Actions, streaming), TypeScript and Tailwind; Drizzle on Postgres, with embedded PGlite for zero-setup runs.
  • PayPal: Orders v2 (AUTHORIZE), Payments v2 (partial capture, void, reauthorize, refund), Vault (merchant-initiated renewals), Payouts, Transaction Search and PayPal-Request-Id idempotency, through the APIMatic-generated PayPal Server SDK plus typed REST. One gateway interface, two implementations: the sandbox client and a database-backed simulator that follows PayPal's rules, both held to a shared contract test suite.
  • Claude: structured outputs for the policy compiler, the injection scanner and the intent judge; a tool-use loop for the ops agent; models resolved at runtime per tier; deterministic offline fallbacks; AI failures fail closed (the payment goes to the owner); a daily spend cap.
  • AG Grid Enterprise for the ledger (grouping, pivots, charts, Excel export) and the AG Grid AI Toolkit to answer plain-English questions by producing grid state.
  • Channel3 product search and unit-normalized market prices that feed both the agent and the guard (the hosted demo uses recorded Channel3 responses).
  • MCP SDK for the MCP server (Streamable HTTP + a stdio bridge); Ed25519 + SHA-256 for receipts.
  • Render Blueprint: web service + Postgres; on the free plan the allowance jobs run inside the web server.
  • Quality: ~270 Vitest tests and ~30 Playwright end-to-end tests on desktop and phone (including WCAG 2.1 AA accessibility checks) run in CI, and the same end-to-end suite runs against the live demo on the PayPal sandbox with Claude.
  • LeashBench: 60 attack and legitimate payment requests run through the guard three ways (rules only, AI only, layered).

Challenges we ran into

  • Keeping AI out of the trusted path. An injection that fools a model must not be able to unlock a payment. Deterministic rules are the floor (AI layers can only escalate), and every request is built from Leash's own records (prices, payees, categories), never from what the agent claims.
  • False alarms are a bug too. Our first live benchmark run found the scanner treating an honest "URGENT: invoice overdue" email as an attack. We fixed the prompt (urgency alone isn't manipulation), re-ran, and published the numbers from after the fix.
  • A PayPal hold that behaves like a budget. One authorization with several partial captures, a void for the rest, a reauthorization after the honor period, and merchant-initiated renewal from a vaulted wallet. We built a simulator that follows PayPal's documented rules, then verified every assumption against the sandbox.
  • Real sandbox money. Abandoned demo holds tied up the shared test buyer's balance, and an EUR merchant account converted USD captures so payouts failed. Leash now releases idle demo holds and keeps a payment paid (with the payout queued and retried) if PayPal hasn't cleared the funds.

Accomplishments that we're proud of

  • The full story runs end to end on real PayPal sandbox money, with Claude live.
  • LeashBench: rules alone catch 27/30 attacks and the AI layers alone 23/30; layered, Leash catches all 30 and blocks none of the 30 legitimate requests.
  • The guard holds even when the agent itself is fully hijacked, and the Attack Lab proves it in public.
  • Signed, verifiable receipts tie the owner's words to the PayPal transaction ids.
  • Any MCP agent, and the PayPal Agent Toolkit, can sit behind the same guard.

What we learned

  • Agent safety for payments is mostly about what the agent is not allowed to say: prices, payees and categories must come from the system, not the model.
  • PayPal's authorize-and-capture flow is a natural fit for agent budgets: the hold caps the blast radius by design.
  • Layers beat any single defense: rules see history and exact numbers, AI sees intent and hidden instructions.

What's next for Leash

  • A faster guard (p95 is 3.7 s today) and live PayPal webhooks.
  • Dispute evidence straight from the signed receipts.
  • More agent surfaces: invoicing agents, procurement for multi-location businesses, agent-to-agent payments.

Built With

  • ag-grid
  • anthropic
  • apimatic
  • channel3
  • claude
  • drizzle
  • mcp
  • next.js
  • paypal
  • paypal-agent-toolkit
  • playwright
  • postgresql
  • render
  • tailwind
  • typescript
  • vitest
Share this project:

Updates

Submission history