Inspiration

When a supplier cancels a delivery the night before, a small business owner spends their evening on the phone, and if they can't fix it, customers go without it in the morning. Big companies have procurement teams for this. Independent businesses have one stressed owner.

We picked bakeries as our test case because the deadlines are unforgiving: if flour isn't there by 05:00, 60 sourdough loaves don't exist at 06:00. But the same problem hits every small business that depends on deliveries, from cafés and restaurants to florists.

What it does

Crumbly is an emergency purchasing agent. When a supplier cancellation email arrives, it:

  1. Detects the email and matches it to the purchase order.
  2. Understands the impact: which customer orders are at risk, and by which bake time.
  3. Investigates: emails the bakery's approved suppliers and uses Linkup to find and fact-check new ones on the live web.
  4. Coordinates: turns messy replies ("Seven bags for £147. Delivery tomorrow.") into structured quotes, spots what's missing (delivery charge, exact time) and asks for it. Silent suppliers are chased, then dropped.
  5. Decides: runs 7 checks in code (approved product, enough quantity, arrives in time, full cost known, within the spending limit, approved supplier, no duplicate order), then ranks offers by reliability, then cost.
  6. Executes: places the order automatically if it's within the owner's rules, otherwise asks the owner. It checks the supplier's confirmation field by field, and a mismatch (e.g. 6 bags instead of 7) is never quietly accepted.
  7. Updates: tracks flour on order separately from flour on the shelf, and recalculates whether every order is covered.

The owner sets the rules once. Owners can reject a choice with a reason ("too expensive"), and Crumbly re-plans and suggests a rule change for them to accept. A plain-English "Ask Crumbly" assistant helps owners who aren't comfortable with technology. It answers from live data and can never place an order without a click.

How we built it

Core principle: models interpret, code decides. AI reads emails and chooses what to investigate. Every number, check and consequential action is deterministic code or SQL.

The shortage maths, for example, is never left to the model:

$$\text{shortage} = 200 - 40 = 160\text{ kg}, \qquad \left\lceil \tfrac{160}{25} \right\rceil = 7 \text{ bags}$$

  • Prototyping & Design: Before writing the application code, we first built the entire end-to-end Crumbly experience as an interactive prototype in Figma. This covered the complete journey, from receiving a supplier cancellation and identifying a shortage to sourcing alternatives, comparing quotes, approving purchases and confirming deliveries.
  • Backend: Python, FastAPI and Pydantic. An orchestrator runs three agents (Production, Sourcing, Recovery) plus a code-only execution service, the only component allowed to act.
  • Frontend: React, Vite, TypeScript and Tailwind, designed in Figma for calm, non-technical owners, with live updates via Server-Sent Events.

Databricks

  • Operational data (inventory, recipes, orders, deliveries, supplier history) lives in Delta tables in Unity Catalog.
  • The agents' only data tools are Unity Catalog SQL functions, called with parameterised SQL through a SQL warehouse:
    • calculate_shortage
    • get_affected_orders
    • coverage_by_slot
    • supplier_reliability
  • coverage_by_slot is time-phased: a 07:00 delivery can save the 07:00 bake but not the 06:00 one.
  • Supplier reliability (96% vs 91% on time) is computed in SQL from delivery history, not hard-coded.
  • We also built a bronze → silver email pipeline using ai_query, Lakebase for live state, MLflow tracing per agent step, and a Databricks App config, all ready to switch on.

Linkup

  • Discover: structured /search for suppliers near the bakery's postcode.
  • Verify: each claim (delivers to the area, sells the pack size, delivery time, trade minimum) is cross-checked against the supplier's own page (/fetch) and an independent search that excludes their domain. Claims are labelled confirmed, conflicting or unverified, with clickable sources.
  • Privacy: queries are built only from ingredient, pack size and postcode. A test guarantees customer names, orders and recipes never leave the app.
  • Safety: new suppliers can be contacted automatically, but buying from them always needs the owner's OK.

Reliability

  • An append-only event log with replay and export.
  • Idempotent purchase orders, so an order is never sent twice.
  • State saved after every step, so a crash resumes instead of restarting.
  • Four seeded demo scenarios and 21 automated tests.

Challenges we ran into

  • Messy, incomplete information. Supplier replies leave things out. Getting the agent to notice what is missing, and ask only for that, was harder than parsing what was there.
  • Keeping the AI away from the money. We had to draw a hard line: the model can propose, but only code can validate, spend or send.
  • Time, not just quantity. A delivery can cover the right number of kilos and still be useless if it arrives after the first bake, so we built coverage per bake slot.
  • "Verified" is subtle. Published information isn't live stock, and two sources can disagree. We keep both values and flag the conflict instead of guessing.
  • Overnight integration risk. We made every integration (Databricks, Linkup, LLM, email) switchable, so the demo stays reliable while the real services come online one at a time.

Accomplishments that we're proud of

  • An agent that finishes a real transaction: from cancellation email to confirmed replacement order, with zero owner decisions on the happy path.
  • Catching a short confirmation (6 bags instead of 7) and proposing a fix that itself passes every rule.
  • Live Linkup research with per-claim verification and sources, and live Databricks UC functions that produce the numbers on screen.
  • A design that feels calm and usable for owners who aren't comfortable with technology.

What we learned

  • The most valuable part of an agent is often the boring part: validation, idempotency and checking what came back.
  • Separating interpretation (AI) from decisions (code) makes an agent far easier to trust and to debug.
  • Unity Catalog functions are a clean way to give an agent a small, governed set of tools instead of free-form SQL.

What's next

  • Turn on the remaining Databricks pieces end to end: Lakebase state, ai_query parsing, MLflow traces in Unity Catalog, and deployment as a Databricks App.
  • Run pilots with real bakeries to confirm how often this happens and what it's worth to them.
  • Expand beyond flour and bakeries to any small business with perishable inputs and morning deadlines: cafés, restaurants, florists, caterers.

Built With

  • ai-agents
  • ai-query
  • databricks
  • databricks-sql
  • delta-lake
  • fastapi
  • figma
  • gmail-api
  • imap
  • lakebase
  • linkup
  • llm
  • mlflow
  • postgresql
  • pydantic
  • pytest
  • python
  • react
  • server-sent-events
  • smtp
  • tailwindcss
  • typescript
  • unity-catalog
  • vite
Share this project:

Updates

Submission history