Demo

AI agent that drafts. You approve.

An AI agent reads order emails and PDFs, checks stock and drafts the order, a low stock flag and a reply. Nothing is saved until a person clicks Approve. Every tool call is logged.

The business and all its data are made up. The run in the video is real.

42-second recording, no sound

In the video

The PDF asks for 12 caramel syrup and only 9 are in stock. The agent leaves it off and flags it. I approve the order and the flag (orders 18 to 19, cups 30 to 25) and reject the reply.

What I checked

After the run

The approval queue and the database after the run: the order and the flag approved, the reply rejected

All 12 emails

Model: gemini-3.8-flash.

EmailDraftedAs expected
Order for this weekorder: 20 x CB-ESP-1K, 4 x CUP-12-1000; replyyes
PO 2291 attached (PDF)order: 10 x CB-FIL-1K, 6 x SYR-VAN-750, 3 x SUG-STK-1000; replyyes
Decaf top uporder: 15 x CB-DEC-1K, 2 x SUG-STK-1000; low stock flag: CB-DEC-1K; replyyes
Order 0457 (PDF)order: 5 x CUP-8-1000; low stock flag: SYR-CAR-750; replyyes
Delivery day?replyyes
New customer, first orderreplyyes
the usualreplyyes
Double your cafe foot traffic in 30 daysnothing (marketing email)yes
Tea order (PO 118) (PDF)order: 30 x TEA-EB-100, 2 x NAP-2PLY-2000; low stock flag: TEA-GRN-100; replyyes
Change to yesterday's orderreplyyes
Order pleaseorder: 8 x CB-ESP-1K, 2 x CUP-8-1000, 4 x MLK-OAT-6; replyyes
Invoice copyreplyyes

The only code that saves

def approve(draft_id):
    """Write one approved draft to the ERP, in one transaction. Stock is checked again at this moment."""
    d = _draft(draft_id)
    if d["status"] != "pending":
        raise ValueError(f"draft {draft_id} is already {d['status']}")
    p = json.loads(d["payload"])
    erp = sqlite3.connect(ERP, timeout=10)
    try:
        with erp:
            if d["kind"] == "create_order":
                for line in p["lines"]:
                    stock = erp.execute("SELECT stock FROM products WHERE sku = ?", (line["sku"],)).fetchone()[0]
                    if stock < line["qty"]:
                        raise ValueError(f"not enough stock now for {line['sku']}: {stock} left, {line['qty']} asked")
                oid = erp.execute("SELECT MAX(id) + 1 FROM orders").fetchone()[0]
                erp.execute("INSERT INTO orders VALUES (?,?,?,?,?)", (oid, p["customer_id"], now()[:10], "new", f"email {d['email_id']}"))
                for line in p["lines"]:
                    price = erp.execute("SELECT price FROM products WHERE sku = ?", (line["sku"],)).fetchone()[0]
                    erp.execute("INSERT INTO order_items VALUES (?,?,?,?)", (oid, line["sku"], line["qty"], price))
                    erp.execute("UPDATE products SET stock = stock - ? WHERE sku = ?", (line["qty"], line["sku"]))
                result = f"Order {oid} written, stock reduced."
            elif d["kind"] == "flag_low_stock":
                fid = erp.execute("INSERT INTO stock_flags (sku, needed_qty, note, created_on) VALUES (?,?,?,?)",
                                  (p["sku"], p["needed_qty"], p["note"], now()[:10])).lastrowid
                result = f"Low stock flag {fid} written for {p['sku']}."
            else:
                mid = erp.execute("INSERT INTO outbox (to_addr, subject, body, created_on) VALUES (?,?,?,?)",
                                  (p["to"], p["subject"], p["body"], now()[:10])).lastrowid
                result = f"Reply {mid} put in the outbox."
    finally:
        erp.close()
    return _decide(draft_id, "approved", result)