Inspiration
A small team needs 30 headsets. The budget is $600. Three supplier quotes arrive as PDFs.
The cheapest quote has the wrong connector. Another hides $160 of shipping in a footnote. Someone says "looks good" in chat. The payment that goes out is not quite what was approved.
Fraud makes it worse. A quote can be edited to fit the budget. "Competing" quotes can be written by the same person. Suppliers can take turns to win.
An AI that "just buys things" would make all of this faster. We wanted an AI that shows its evidence and stops at every point where a person must agree.
What it does
QuoteGuard turns supplier quotes into a verified PayPal purchase.
- Describe. You write the purchase in plain English. The agent drafts typed requirements. You confirm them (consent 1 of 3).
- Read and cite. The agent extracts every term from each PDF. Each number must cite a line on the page. QuoteGuard checks that the line exists and highlights it.
- Check the documents. Integrity Radar recovers hidden PDF revisions. It links "competing" quotes that share an author, a file or a phone number. It also runs bid-rigging screens (Huber & Imhof, 2019).
- Decide. The decision is plain arithmetic, not a model's opinion. Each check is pass, fail or unknown. Missing evidence is never a pass.
- Approve. An approver signs a SHA-256 hash of the exact purchase: supplier, amount, PayPal merchant and expiry (consent 2 of 3).
- Pay. Checkout is built only from the approved snapshot. The buyer approves in PayPal's window (consent 3 of 3). We verify the order with PayPal before capture. A signed webhook confirms it.
- Prove. You get a receipt with PayPal IDs, a decision replay and a downloadable evidence package.
Demo Lab lets judges attack the purchase. Try an edited bill, staged competition, a rotating cartel, a payee change after approval or a PDF that tells the AI to pay someone else.
How we built it
- Backend: Python 3.12, FastAPI, PostgreSQL 16, SQLAlchemy and Alembic.
- Agent: a LangGraph workflow with progress saved in PostgreSQL. The model returns JSON only. It has no tools that can approve or pay.
- AI: Claude Sonnet 5.5 via NanoGPT for extraction and explanations.
- PayPal: Orders v2, Payments v2, the JS SDK, webhook signature checks and the Agent Toolkit for read-only lookups.
- Forensics: pdfplumber and pypdf for hidden revisions and patched amounts.
- Research: pandas, scikit-learn and SciPy on public cartel data.
- Frontend: React 19, TypeScript, Vite, Tailwind and AG Grid.
- Tests: 75 backend tests on real PostgreSQL, plus Playwright runs against the live site with a real Sandbox purchase.
Challenges we ran into
- Saying "unknown". A missing shipping line must not count as zero. We made "unknown" a real answer.
- Trusting the model less. Our holdout test found a quote that passed by mistake. It said "charges over USB-C; audio through the 3.5 mm jack". We fixed the checker, not the labels.
- Concurrency. Our tests found a deadlock between capture and refund. We fixed the lock order and added a test.
- Clean-looking fraud. A cartel can send perfect documents. We needed purchase history to catch it, not just the PDFs.
Accomplishments that we're proud of
- A real PayPal Sandbox purchase of $570.00, captured with status COMPLETED. The payment matches what the approver signed.
- On 82 labelled synthetic cases: 0 of 38 honest cases flagged and 40 of 44 attacks caught. The original amount was recovered in 15 of 15 hidden revisions. We publish the 4 misses.
- Our research. We trained a cartel-pattern model on 23,793 bidder groups from proven cartel cases (Imhof & Wallimann 2021 data, CC BY 4.0). We tested it in countries it had never seen. It scored a mean AUC of 0.818, against 0.765 for the best published-style baseline. It is best on average and best or tied-best in every unseen market.
What we learned
- Make the AI cite, then check the citation. A number without its line is not evidence.
- Keep the AI out of the money path. The model reads and explains. Code decides and pays.
- Build a test set the system has never seen, and freeze its labels before the first run.
- Publish the misses. Judges and users trust numbers that admit their limits.
What's next for QuoteGuard: Safe Supplier Purchases with PayPal
- Run observed sessions with three to five real operations teams.
- Support more than one PayPal merchant and more currencies.
- Test the forensics on real supplier documents, not only synthetic ones.
Limits today: synthetic documents only, PayPal Sandbox only, one sandbox merchant and USD only. The cartel model gives a review signal, never proof.
Built With
- ag-grid
- alembic
- claude
- fastapi
- langgraph
- nanogpt
- paypal-agent-toolkit
- paypal-js-sdk
- paypal-orders-api
- pdfplumber
- postgresql
- pypdf
- python
- react
- scikit-learn
- sqlalchemy
- tailwindcss
- tanstack-query
- typescript
- vite