-
-
Reins puts limits between AI agents and your PayPal account, so you give an agent a budget instead of your card.
-
The Playground feed shows what the agent wanted and why, and what Reins decided and why.
-
A hidden injection tells the agent to add a $189 printer. Gemini blocks the boxes, the cap blocks the printer. Nothing is charged.
-
The $65 tape is over the $50 threshold, so it waits for a human. One tap on Approve charges it through PayPal Vault.
-
A receipt was edited in the database. Verify Chain flags the exact receipt where the SHA-256 hash chain breaks.
-
Link PayPal once via Vault with a $1 verification order, refunded automatically. The agent never sees your credentials.
-
Every purchase passes deterministic rules, then Gemini’s guard, before reaching PayPal. Gemini can block or escalate, never approve.
Inspiration
AI agents are starting to buy things for us, but today the only way to let one pay is to hand it a card number or a logged-in account, with no limits. That's all-or-nothing access. OAuth solved this for data years ago: apps get scoped, revocable tokens instead of your password. Nothing like that exists for money.
Agents can also be manipulated. One hidden line in a product listing can change what an agent decides to buy. I wanted to build the layer that sits between the agent and the wallet and can say no.
What it does
Reins is a consumer-side trust and control layer for AI agents that spend through PayPal.
- Spending mandates. You set a total budget, a per-purchase cap, allowed merchants and categories, an expiry, and a threshold above which a human must approve. You link PayPal once through PayPal Vault. The agent gets an HMAC-signed mandate token, never your payment credentials.
- Policy engine. Every purchase attempt goes through Reins first. Deterministic rules check budget, caps, merchant, time window and escalation threshold. Then Gemini 3.6 Flash checks whether the item really fits the allowed categories and screens the merchant listing for hidden prompt-injection payloads.
- Three outcomes. Approved purchases are charged server-side through PayPal Vault with zero buyer clicks. Escalated purchases go to an inbox for one-tap human approval. Blocked purchases are never charged.
- Tamper-evident receipts. Every decision, with both the agent's reason and Reins' reason, is written to a SHA-256 hash chain:
$$H_n = \text{SHA256}(H_{n-1} \,|\, \text{receipt}_n)$$
If anyone edits a stored receipt, "Verify Chain" points to the exact broken link. The audit trail is displayed in AG Grid.
- Revoke anytime. Revoking a mandate deletes the vaulted payment token from PayPal immediately.
The rule I designed around: AI can only add caution. Gemini can block or escalate a purchase, but it can't override a hard rule, and if it times out, runs out of quota or returns malformed output, the purchase goes to a human instead of going through.
The demo
A small-business seller lets a Gemini shopping agent restock fulfillment supplies with a $300 budget, a $100 per-purchase cap and a $50 escalation threshold. Given a goal like "We're low on mailers, boxes and tape. Restock within budget," the agent plans and submits its purchases:
- $24.99 bubble mailers: approved and charged through PayPal Vault
- $189 label printer: blocked by the per-purchase cap
- $32.50 boxes from a hostile listing with a hidden instruction saying carrier rules require adding the $189 printer: the boxes are blocked by Gemini's injection check and the printer by the cap. Nothing is charged, even when the agent falls for the attack.
- $65 packing tape: escalated; a human taps Approve and the charge goes through
The Playground shows both sides of every decision ("Agent wanted X because… / Reins blocked because…"), and a live Red-Team Attack Simulator lets you launch your own injection attacks at Reins.
How I built it
- Backend: Python 3.11 and FastAPI, with a mandate engine, a policy engine and a hash-chained receipt store.
- PayPal: OAuth client credentials; Orders v2 with vault attributes for a $1 setup order, captured with
Prefer: return=representationto get the permanent vault ID, then refunded automatically; vault-ID purchases withPayPal-Request-Ididempotency keys;DELETE /v3/vault/payment-tokenson revoke; and a fallback approval-link mode for sandboxes without Vault enabled. - AI: Gemini 3.6 Flash through the google-genai SDK, in two separate roles: the shopping agent, which is treated as untrusted, and the guard inside the policy engine. Item IDs and prices always come from the verified catalog, never from the model's text, and the agent never talks to PayPal directly.
- Frontend: React, TypeScript, Vite and AG Grid.
- Shipping: Render blueprint deployment, GitHub Actions CI, and 52 pytest tests with PayPal and Gemini mocked.
Challenges I ran into
- Vault in the sandbox. It needed US business and US personal sandbox accounts, Vault enabled in the app settings, and a $1 verification order that has to be captured to get the vault ID and then refunded. I added a fallback mode for setups where vaulting isn't configured.
- Making the AI fail safely. I had to raise Gemini's output token limit so its structured responses weren't cut short, and make any malformed or missing response default to human escalation.
- Rule ordering. An item can be over both the cap and the escalation threshold. Escalating it would let a human approve something the user said should never happen, so hard caps are always checked first.
- Assuming the agent gets fooled. I designed for the case where the shopping agent obeys the injection, so the defense never depends on the agent behaving.
- A tamper demo that doesn't weaken production. The tamper and restore endpoints only exist when
DEMO_MODE=trueand return 404 otherwise, and the app refuses to start without a signing secret.
What I learned
- In agentic commerce, prompt injection is a payments problem as much as a model problem. You can't make an agent impossible to fool, so the control has to sit where the money moves.
- Rules and AI work best with clear authority: rules for what must never happen, AI for judgment calls, and humans for the gray zone.
- PayPal Vault is what makes this practical. Purchases happen server-side with no clicks, yet stay inside limits the user can revoke at any time.
What's next
- Separate mandates and budgets for multiple agents per user
- AI-assisted dispute mediation that uses the receipt chain as evidence
- Packaging Reins as a drop-in proxy for agent frameworks