AgentGuard — Autonomous AI Agent Payment Proxy & Budget Controller
Inspiration
Giving an autonomous AI agent a credit card is terrifying. One runaway loop and an agent can drain an account in minutes buying compute, data feeds, and subscriptions through tool calls. Platform dashboards cap token spend, but nothing governs the money an agent spends in the outside world across multi-step tool executions. We built the missing layer: a payment proxy that treats every agent purchase like it needs a manager's approval — except the manager is a policy engine backed by PayPal.
What It Does
AgentGuard sits between an AI agent and PayPal. When an agent tries to buy something through a tool call, AgentGuard: (1) intercepts the purchase request (agent ID, merchant, amount, currency, description); (2) runs a policy check — total budget cap, per-transaction cap, merchant whitelist, and hourly frequency limit — plus an AI second opinion that flags urgency/scam patterns in the request description; (3) if approved, executes the payment with PayPal's Orders API v2 using a tokenized payment method from the PayPal Vault, so the agent never sees raw card or account credentials; (4) listens to PayPal webhooks (order approved, payment captured) and writes every decision to an append-only audit ledger shown on a live developer dashboard. It works with any agent framework that can make an HTTP call (LangChain, CrewAI, AutoGPT, or a hand-rolled loop).
How We Built It
PayPal Developer Sandbox for the full transaction lifecycle; PayPal Vault API (v3 payment-method tokens) so payment methods stay tokenized; PayPal Orders API v2 to create, authorize, and capture payments programmatically; PayPal Webhooks for real-time events that update spend state and the audit ledger; a Gemini Flash AI evaluator that reviews borderline requests in natural language while a deterministic rules engine remains the hard boundary (the LLM advises but can never override a cap); Python (Flask) middleware; and a zero-credential mock mode that simulates the complete PayPal lifecycle offline so anyone can run the full demo in 30 seconds.
Challenges
Making the policy engine the single source of truth: webhook events can arrive after a capture resolves, so the ledger is append-only and every decision records the policy state it was made against. The demo also never silently degrades — with no PayPal credentials or AI key present, mock mode exercises the identical code paths.
Accomplishments
A complete, working agent → policy → PayPal → webhook → dashboard loop, runnable offline in mock mode. Policy denials that read like a good CFO: every rejection names the exact rule, the limit, and the attempted amount. And an LLM that can flag a suspicious purchase but mathematically cannot approve one cent over the hard caps.
What We Learned
Agentic commerce doesn't fail on payments — PayPal's sandbox, Vault, and Orders APIs already move money well. It fails on authority: who said this agent could spend this much, at this merchant, this often? That authority layer is what AgentGuard adds.
What's Next
Per-agent Vault tokens with independent budgets for multi-agent swarms; human-in-the-loop approval pushes for transactions above a threshold; live (non-sandbox) rollout behind the same policy engine; LangChain/CrewAI tool wrappers.