-
-
LastCall: tonight's leftovers from local food shops, every item shown, checked against your allergies and paid with PayPal.
-
Checkout in PayPal's own window. The order is created on the server from LastCall's quote and paid straight to the shop.
-
Ask LastCall, the shopping agent, turns "dinner for 2 tonight, severe nut allergy" into a strict rule and checks every open shop.
-
An itemised bundle with photos, the shop's own price and how each part of the request is met, with allergens verified by the shop.
-
Every PayPal webhook is signature-verified, de-duplicated and matched to its payment or refund.
-
The failure drill in Platform ops: arm a lost PayPal capture response to test recovery on the live app.
-
The close-out agent's plan before close: a 20% price cut and two slot closures, checked against the price floor and live stock.
-
Four AI teammates per shop. They use tools, but can't change a price or move money without a manager.
-
Every agent run is traced: model turns, tool calls and rejected calls, each timed in Platform ops.
-
A walk-in buys the last samosas: the bundle proposes a swap, and payment waits until the shopper approves it.
-
PayPal took the payment but the reply was lost. LastCall asks PayPal, finds the capture and confirms the order once.
-
The pickup pass: paid and verified with PayPal, with a 4-digit code and QR, updating live as the shop packs.
-
LastCall's 10% fee, billed weekly to each shop with a PayPal invoice. Shoppers pay nothing extra.
-
"Was I charged twice?" The support agent checks the payment with PayPal before drafting a reply staff review and send.
Inspiration
Every day, households alone throw away more than a billion meals' worth of food, and restaurants, cafés and shops account for another 40% of all food waste (UNEP Food Waste Index Report 2024). Surplus food apps help, but they sell a mystery bag: you pay first and find out what's inside at pickup. That rules them out for the 33 million people in the U.S. with food allergies (FARE), and for anyone feeding a family on a budget.
We wanted the opposite: say who you're feeding, see exactly what you'd get from tonight's real leftovers, know it's safe for your allergies, and pay the shop directly.
What it does
For shoppers. Type a request like "dinner for 2 tonight, my partner has a severe nut allergy." Ask LastCall, a shopping agent, checks every open shop's live stock, prices, pickup times and allergen records, and returns itemised bundles with photos, the shop's own price, and how each part of the request is met. A severe allergy becomes a hard rule enforced in code: only items the shop has verified free of that allergen, with no listed cross-contact, are offered, and the answer shows what was left out. If stock changes while you're deciding, the bundle proposes a swap and payment waits for your OK. Holding a bundle reserves the food so nothing sells twice. You pay in PayPal's own window, and a live pickup pass with a 4-digit code updates as the shop packs and hands over.
For shops. A shop sets up in minutes: photos, its own prices and allergen records, and a PayPal merchant ID that LastCall verifies with PayPal before saving. A tablet-friendly console runs the pickup queue, code handoff, one-step refunds, team roles and insights. Four AI teammates help sell out before close, but none can change a price or move money without a person:
- Ask LastCall suggests the shop's bundles to shoppers.
- Close-out drafts price cuts and slot changes for what's left, checked against a price floor and live stock. A manager approves.
- Watch alerts emails shoppers who asked to be told when a fitting bundle appears.
- Support replies looks the payment and any refund up with PayPal, then drafts an answer for staff to send.
For the platform. LastCall keeps 10% of each order's items (min $0.25), billed to each shop weekly with a PayPal invoice. Shoppers pay nothing extra. Platform ops reviews new shops and shows every payment trace, verified webhook, model call and agent run.
How we built it
PayPal, end to end
- Orders v2: each order is created on the server from LastCall's own quote (never the browser's numbers), with the shop as payee, captured on the server, and retried safely with
PayPal-Request-Id. - Payments v2: refunds go back through the account that was actually paid, using
PayPal-Auth-Assertion. Live capture and refund lookups feed the support agent and reconciliation. - Invoicing v2: weekly fee invoices, reduced by refunds and waived on full refunds.
- Webhooks: every event is signature-verified, de-duplicated and matched to its payment or refund.
- Recovery: a capture whose response is lost or times out becomes
OUTCOME_UNKNOWNand is resolved by asking PayPal, so nobody is charged twice and no order is confirmed without a verified capture. Platform ops can inject these failures on purpose, as the demo shows.
AI agents with tools, not authority
- Four tool-calling agents and four single-shot model calls (request understanding, bundle and substitution explanations, product copy), built with LangChain on a model served through Ollama.
- Every output is schema-validated and cross-checked. Rejected tool calls go back to the agent to correct, a slow turn is retried once, and every agent falls back to plain rules if the model is unavailable.
- Shop-written text reaches the model only as labelled data, so prompt injection in a product description can't change constraints or prices.
- Every run, model turn and tool call is traced and timed in Platform ops.
Platform
- Next.js 16, React 19 and MUI on the front end, with a Bryntum scheduler for the pickup timeline. FastAPI with Python 3.12 and PostgreSQL behind it, deployed on Render.
- Stock never oversells: availability is derived from holds and paid orders, with row locks taken in a fixed order.
- Live updates use PostgreSQL
LISTEN/NOTIFYfanned out over server-sent events. A durable job queue runs holds, reconciliation, close-out plans and invoices. - 262 backend tests on real PostgreSQL, covering acceptance criteria AT-01 to AT-15 (concurrent buyers for the last item, a lost capture response, duplicate webhooks, prompt injection and more). Playwright browser tests pay in the PayPal Sandbox and run accessibility scans.
Challenges we ran into
- A payment whose answer never arrives. If PayPal captures the money but the response is lost, the shopper is charged and the order still looks unpaid. We made "unknown" an explicit state, resolved it only by asking PayPal, and built a failure drill to prove it works.
- Paying each shop directly. Each shop is the payee on its own orders, and refunds act on the shop's behalf with
PayPal-Auth-Assertion. Taking a platform fee inside the payment needs partner onboarding, so LastCall bills its fee with weekly PayPal invoices instead. - Models don't always speak the schema. While recording the demo we found the close-out agent wrote price cuts as
price_changewith"new_price": "$4.80". That call was rejected, and on retry the price was left out, so every suggested price cut was silently dropped. LastCall now reads the model's own wording, while the 30% price floor and "only lower" checks still decide. - Refund webhooks. PayPal's refund events name the capture only through a link, so refunds weren't matched to their orders. Following that link fixed it, and refunds started outside LastCall now raise an alert.
- Allergies are not a ranking problem. It's tempting to let the model judge whether something is "probably fine". We kept that decision entirely in code and made it fail closed.
Accomplishments that we're proud of
- A complete product running live: shopper, shop and platform views, real PayPal Sandbox payments, refunds, invoices and webhooks.
- AI that is genuinely useful for shopping, support and close-out, yet can't touch money or safety without code checks and a person's approval.
- Recovering from a lost payment response on camera, charged once and confirmed once.
What we learned
- Let the model talk and plan, and let code decide anything involving money, stock or safety.
- Idempotency keys and a second source of truth (webhooks plus direct lookups) are what make payments trustworthy.
- Tracing every agent step is what made the agents debuggable. The close-out price-cut bug was found by reading a trace.
What's next for LastCall
- Production payouts through PayPal partner onboarding, with the fee taken at checkout.
- A food-safety, labelling and allergen review before real sales.
- More shops and neighbourhoods, multi-shop baskets, and shop-set price floors.
Payments run in the PayPal Sandbox. The showcase shops, people and addresses are fictional.
Built With
- ai-agents
- alembic
- bryntum
- docker
- fastapi
- langchain
- llm
- material-ui
- next.js
- ollama
- paypal
- paypal-invoicing-api
- paypal-orders-api
- paypal-payments-api
- paypal-webhooks
- playwright
- postgresql
- pytest
- python
- react
- render
- server-sent-events
- sqlalchemy
- typescript
- uv