Inspiration
Nobody hands an AI agent a credit card, and for good reason. But agents that can't pay for anything stay stuck at "here's a link, you buy it". We wanted the middle ground: give the agent a budget with rules instead of a card, and keep a human in the loop only when it matters.
What it does
An LLM agent gets a goal (for example "Set up our launch site: domain, hosting and analytics"). It can search a product catalog and request purchases. Every request goes through a deterministic policy engine that returns one of three verdicts:
- ALLOW (small and in policy): the order is created and captured from a vaulted PayPal wallet, with no human present.
- ESCALATE (over the auto-approve limit, over the daily budget, or a possible duplicate): a PayPal order is created and a human approves it in PayPal checkout. Only then is it captured.
- DENY (blocked category or unknown vendor): nothing is created and the reason is logged.
Every request lands in an audit ledger (AG Grid) with the agent's justification, the rule that fired, the PayPal order and capture IDs, and a per-request timeline. Policy limits, allowed vendors and blocked categories are editable live.
How we built it
- The model never touches PayPal. It can only call four tools (
search_catalog,get_budget_status,request_purchase,check_purchase_status). Prices, vendors and categories come from the catalog, not from the model, so it can't talk its way into a different price. - Policy is plain code with no LLM inside it. It checks the vendor allowlist, blocked categories, duplicates in the last 10 minutes, the daily budget (including amounts still awaiting approval) and the auto-approve limit, and it has automated tests.
- PayPal integration: Orders v2 (create, capture, get, with idempotency keys), Vault v3 (setup tokens and payment tokens for unattended payments) and webhook signature verification. Only a COMPLETED capture is ever recorded as paid. Declines and failures appear in the ledger with the PayPal error and debug ID.
- Stack: Next.js (App Router), TypeScript, Tailwind, AG Grid, a JSON-file store, and an OpenAI-compatible LLM client (Groq's free tier running gpt-oss-120b). Deployed on Render.
- Red team: we attacked the agent with 13 scripted prompts (prompt injection, fake admin messages, price manipulation, splitting a purchase under the limit, buying blocked items). No money moved outside policy. The report is in
docs/RED_TEAM.mdin the repo.
Challenges
- Vault payments needed account-level setup (a US Business sandbox account with vaulting enabled) before PayPal would authorize them.
- Free LLM tiers rate-limit and sometimes emit malformed tool calls, so the agent loop retries and fails with readable messages.
- Free hosting has an ephemeral disk, so the linked wallet needs an environment-level default to survive restarts.
- Keeping the audit trail honest: an escalated purchase that a human approved stays ESCALATE in the verdict column (that is what the policy decided), while the outcome shows Paid.
Accomplishments we're proud of
A real end-to-end flow on the PayPal Sandbox: autonomous payment from a vaulted wallet, human-approved checkout, and hard denials, all visible in one ledger. The same agent and the same policy handle all three paths.
What we learned
Agent payments are a trust problem more than a payments problem. Moving the decision out of the model and into small, testable code made the system easier to reason about, easier to test, and much harder to attack.
What's next
Per-agent budgets and policies, merchant-level spending categories, burst limits and retry limits for denied items, refunds and disputes in the ledger, approvals over email or chat, and a production-grade store in place of the JSON file.
Try it
- Live app: https://allowance-g8sh.onrender.com/ (the first load can take up to a minute on free hosting)
- Code: https://gitlab.com/kananramazanov/allowance
Testing instructions (sandbox only, no real money): open the live app, click Link PayPal wallet and log in with the sandbox buyer [email protected] / I?<^m2Vo. Then send these prompts with the chips in the chat:
- "Buy a .com domain for our launch" gives ALLOW and is paid from the wallet.
- "We need the Analytics Growth plan" gives ESCALATE. Click Approve in PayPal in the ledger row and approve as the buyer.
- "Get a $40 gift card for the team raffle" gives DENY.
Reset demo clears the ledger. This is a single-user demo with no login.
Team: Kanan Ramazanov, Rizvan Mammadzada, Seyran Umudov, Habib Gurbanov
Built With
- aggrid
- groq
- next.js
- paypal
- react
- render
- tailwind
- typescript
- vitest