Invoice intake that books the routine and escalates the rest

Trigger: watched folder · Pattern: extract → threshold gate → book or pause · Sample: examples/use-cases/invoice-approval.toml · Status: runs today (intel-remote,schema,tools-http-tls,trigger-fs-watch)

The problem

Accounts payable is a pipeline of judgment calls that are 95% routine: vendor, amount, PO number, book it. The 5% — an amount that's too big, a PO that's missing, a vendor nobody recognizes — is why a human reads all 100%. Automating the 95% with classic OCR templates breaks every time a vendor redesigns their invoice; automating it with an unsupervised LLM means the one hallucinated amount ends up in your ledger.

The shape you actually want: a machine that extracts and routes, a threshold that's written down, and a human who only sees exceptions.

What the agent does

  1. Your scanner/email pipeline drops invoice text into a watched folder; the workflow fires on file creation (fs_watch, debounced).
  2. One LLM step extracts {vendor, amount, currency, po_number, requires_review} — schema-enforced, with up to two repair rounds if the model emits something malformed. The prompt encodes the policy: over $2,500, missing PO, or any uncertaintyrequires_review: true. The schema makes that a hard boolean.
  3. A condition node routes on the boolean:
    • false → POST to the accounting API; the invoice is booked.
    • true → the run checkpoints (pause_for_approval) until the controller resumes it after a look.
  4. Either way, the structured record is archived next to the books, and the audit log holds the whole story per invoice.
[[nodes]]
id = "gate"
type = "condition"
expr = "extract.parsed.requires_review"

One boolean, one declared edge each way. That's the approval policy — versioned, diffable, signable.

Why finance can sign off on this

Honest limits