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_UNKNOWN and 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/NOTIFY fanned 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_change with "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

Share this project:

Updates

Submission history