{
 "schema": "agentflows.run/1",
 "workflow": "invoice-triage",
 "workflowVersion": "1",
 "configHash": "5ccc121c8a9cf60115a932501db0cd147608581752eecc5ac9cf1c5a84b2a887",
 "model": {
  "requested": "qwen3.8-flash",
  "reported": [
   "qwen3.8-flash"
  ]
 },
 "run": 3,
 "smoke": null,
 "complete": true,
 "abortReason": null,
 "startedAt": "2026-12-02T05:16:53.351Z",
 "finishedAt": "2026-12-02T05:18:39.425Z",
 "endpoint": "OpenAI-compatible /chat/completions (base URL not recorded)",
 "runner": {
  "node": "v25.6.1",
  "temperature": 0.2,
  "timeoutMs": 240000,
  "retries": 2,
  "concurrency": 3
 },
 "totals": {
  "modelCalls": 14,
  "attempts": 14,
  "promptTokens": 13774,
  "completionTokens": 27560,
  "totalTokens": 41334,
  "latencyMs": 265537,
  "cost": null,
  "costNote": "the endpoint did not report cost for every call",
  "itemsPassed": 7,
  "items": 7
 },
 "items": [
  {
   "id": "inv-a",
   "label": "Brightline Packaging Inc. BL-21407",
   "steps": [
    {
     "id": "read_pdf",
     "kind": "tool",
     "tool": "read_pdf_text",
     "ms": 33,
     "output": "Brightline Packaging Inc.\nINVOICE\n41 Harbor Road\nInvoice no.  BL-21407\nGroveport, OH 43125\nInvoice date 11/18/2026\n(614) 555-0142 · billing@brightline-packaging.example.com\nTerms  Net 30\nDue date 12/18/2026\nCustomer PO  PO-24017\nBILL TO  SHIP TO\nLarkfield Supply Co.  Larkfield Supply Co.\nAccounts Payable  Receiving, Dock 2\n2200 Mill Race Road  2200 Mill Race Road\nColumbus, OH 43215  Columbus, OH 43215\nap@larkfield.example.com\nDescription  Qty  Unit price  Amount\nStretch film, 18 in x 1500 ft, 80 gauge (roll)  40  38.50  1,540.00\nCarton sealing tape, 2 in x 110 yd (case of 36)  12  14.25  171.00\nSubtotal  1,711.00\nSales tax 7.75%  132.60\nTotal due (USD)  $1,843.60\nRemit to: First Example Bank · Routing (ABA) 999000111 · Account 9900004417 · Reference invoice BL-21407"
    },
    {
     "id": "extract",
     "kind": "model",
     "request": {
      "model": "qwen3.8-flash",
      "messages": [
       {
        "role": "system",
        "content": "You extract data from vendor invoices for an accounts payable team. Copy values exactly as printed. Don't correct arithmetic, don't fill in values that aren't printed, and don't guess. Answer with one JSON object and nothing else."
       },
       {
        "role": "user",
        "content": "Extract these fields from the invoice text below. The invoice was sent to Larkfield Supply Co.; the vendor is the company that issued it.\n\nReturn JSON with exactly these keys:\n{\n  \"vendor_name\": string,\n  \"invoice_number\": string, as printed,\n  \"invoice_date\": \"YYYY-MM-DD\",\n  \"due_date\": \"YYYY-MM-DD\" or null,\n  \"po_number\": string or null,\n  \"line_items\": [{\"description\": string, \"quantity\": number, \"unit_price\": number, \"amount\": number}],\n  \"subtotal\": number,\n  \"tax\": number,\n  \"total\": number,\n  \"remit_to\": {\"bank_name\": string or null, \"routing_number\": string or null, \"account_number\": string or null},\n  \"phone_numbers_on_invoice\": [string],\n  \"notices\": [string]\n}\nAmounts are plain numbers without currency symbols or commas, as printed (don't recompute them). \"notices\" holds any printed notice, stamp or request, word for word; [] if there is none.\n\nInvoice text (extracted from brightline-bl-21407.pdf):\n\"\"\"\nBrightline Packaging Inc.\nINVOICE\n41 Harbor Road\nInvoice no.  BL-21407\nGroveport, OH 43125\nInvoice date 11/18/2026\n(614) 555-0142 · billing@brightline-packaging.example.com\nTerms  Net 30\nDue date 12/18/2026\nCustomer PO  PO-24017\nBILL TO  SHIP TO\nLarkfield Supply Co.  Larkfield Supply Co.\nAccounts Payable  Receiving, Dock 2\n2200 Mill Race Road  2200 Mill Race Road\nColumbus, OH 43215  Columbus, OH 43215\nap@larkfield.example.com\nDescription  Qty  Unit price  Amount\nStretch film, 18 in x 1500 ft, 80 gauge (roll)  40  38.50  1,540.00\nCarton sealing tape, 2 in x 110 yd (case of 36)  12  14.25  171.00\nSubtotal  1,711.00\nSales tax 7.75%  132.60\nTotal due (USD)  $1,843.60\nRemit to: First Example Bank · Routing (ABA) 999000111 · Account 9900004417 · Reference invoice BL-21407\n\"\"\""
       }
      ],
      "temperature": 0.2,
      "max_tokens": 16384,
      "stream": false
     },
     "response": {
      "id": "chatcmpl-448781d2-3925-9f10-ab07-f3fe78dd39c3",
      "model": "qwen3.8-flash",
      "content": "{\n  \"vendor_name\": \"Brightline Packaging Inc.\",\n  \"invoice_number\": \"BL-21407\",\n  \"invoice_date\": \"2026-11-18\",\n  \"due_date\": \"2026-12-18\",\n  \"po_number\": \"PO-24017\",\n  \"line_items\": [\n    {\n      \"description\": \"Stretch film, 18 in x 1500 ft, 80 gauge (roll)\",\n      \"quantity\": 40,\n      \"unit_price\": 38.50,\n      \"amount\": 1540.00\n    },\n    {\n      \"description\": \"Carton sealing tape, 2 in x 110 yd (case of 36)\",\n      \"quantity\": 12,\n      \"unit_price\": 14.25,\n      \"amount\": 171.00\n    }\n  ],\n  \"subtotal\": 1711.00,\n  \"tax\": 132.60,\n  \"total\": 1843.60,\n  \"remit_to\": {\n    \"bank_name\": \"First Example Bank\",\n    \"routing_number\": \"999000111\",\n    \"account_number\": \"9900004417\"\n  },\n  \"phone_numbers_on_invoice\": [\n    \"(614) 555-0142\"\n  ],\n  \"notices\": []\n}",
      "finishReason": "stop",
      "reasoningChars": 4059,
      "usage": {
       "prompt_tokens": 734,
       "total_tokens": 2335,
       "completion_tokens": 1601,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 734
       },
       "completion_tokens_details": {
        "reasoning_tokens": 1236,
        "text_tokens": 1601
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 14641,
     "attempts": [
      {
       "status": 200,
       "ms": 14641
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "vendor_name": "Brightline Packaging Inc.",
       "invoice_number": "BL-21407",
       "invoice_date": "2026-11-18",
       "due_date": "2026-12-18",
       "po_number": "PO-24017",
       "line_items": [
        {
         "description": "Stretch film, 18 in x 1500 ft, 80 gauge (roll)",
         "quantity": 40,
         "unit_price": 38.5,
         "amount": 1540
        },
        {
         "description": "Carton sealing tape, 2 in x 110 yd (case of 36)",
         "quantity": 12,
         "unit_price": 14.25,
         "amount": 171
        }
       ],
       "subtotal": 1711,
       "tax": 132.6,
       "total": 1843.6,
       "remit_to": {
        "bank_name": "First Example Bank",
        "routing_number": "999000111",
        "account_number": "9900004417"
       },
       "phone_numbers_on_invoice": [
        "(614) 555-0142"
       ],
       "notices": []
      }
     }
    },
    {
     "id": "lookup",
     "kind": "tool",
     "tool": "lookup_records",
     "ms": 1,
     "output": {
      "vendor": {
       "id": "V-1001",
       "name": "Brightline Packaging Inc.",
       "phoneOnFile": "(614) 555-0142",
       "routing": "999000111",
       "account": "9900004417",
       "terms": "Net 30"
      },
      "po": {
       "po": "PO-24017",
       "vendorId": "V-1001",
       "description": "Stretch film and carton tape, November",
       "amount": 1843.6,
       "billedToDate": 0,
       "remaining": 1843.6
      },
      "ledger": [
       {
        "vendorId": "V-1001",
        "invoiceNumber": "BL-20931",
        "invoiceDate": "2026-10-14",
        "total": 1120.6,
        "po": "PO-23988",
        "status": "paid 2026-11-12"
       }
      ]
     }
    },
    {
     "id": "review",
     "kind": "model",
     "request": {
      "model": "qwen3.8-flash",
      "messages": [
       {
        "role": "system",
        "content": "You are an accounts payable reviewer at Larkfield Supply Co.. You recommend a route for one invoice under the AP policy. You can't pay, approve or contact anyone; a person decides after reading your recommendation. Answer with one JSON object and nothing else."
       },
       {
        "role": "user",
        "content": "AP policy:\n\"\"\"\nLarkfield Supply Co. accounts payable routing policy (rev. 2026-10)\n\nPick exactly one route. When more than one applies, use the first in this list.\n1. reject_duplicate: the AP ledger already has an invoice from the same vendor with the same invoice number (ignore spaces, hyphens and letter case).\n2. hold_verify_bank: the remit-to routing or account number differs from the vendor master, or the vendor is not in the vendor master. Verify only by calling the phone number in the vendor master, never a number printed on the invoice.\n3. hold_possible_duplicate: the AP ledger has an invoice from the same vendor, on the same PO, with the same total, dated within 45 days of this invoice, under a different number.\n4. return_to_vendor: the arithmetic doesn't hold (quantity x unit price differs from a line amount, line amounts don't add up to the subtotal, or subtotal + tax differs from the total), allowing 1 cent for rounding.\n5. hold_po_review: no PO number, the PO is not in the PO register, the PO belongs to another vendor, or the invoice total is more than the PO's remaining balance (PO amount minus billed to date).\n6. approve_controller: none of the above, and the total is more than $10,000.00.\n7. approve_ap: none of the above, and the total is $10,000.00 or less.\n\nNo route pays an invoice. Every route goes to a person, who approves before anything is paid, sent or recorded.\n\"\"\"\n\nInvoice data (extracted from the PDF by a previous step):\n{\n  \"vendor_name\": \"Brightline Packaging Inc.\",\n  \"invoice_number\": \"BL-21407\",\n  \"invoice_date\": \"2026-11-18\",\n  \"due_date\": \"2026-12-18\",\n  \"po_number\": \"PO-24017\",\n  \"line_items\": [\n    {\n      \"description\": \"Stretch film, 18 in x 1500 ft, 80 gauge (roll)\",\n      \"quantity\": 40,\n      \"unit_price\": 38.5,\n      \"amount\": 1540\n    },\n    {\n      \"description\": \"Carton sealing tape, 2 in x 110 yd (case of 36)\",\n      \"quantity\": 12,\n      \"unit_price\": 14.25,\n      \"amount\": 171\n    }\n  ],\n  \"subtotal\": 1711,\n  \"tax\": 132.6,\n  \"total\": 1843.6,\n  \"remit_to\": {\n    \"bank_name\": \"First Example Bank\",\n    \"routing_number\": \"999000111\",\n    \"account_number\": \"9900004417\"\n  },\n  \"phone_numbers_on_invoice\": [\n    \"(614) 555-0142\"\n  ],\n  \"notices\": []\n}\n\nVendor master record for this vendor (null if there is no match):\n{\n  \"id\": \"V-1001\",\n  \"name\": \"Brightline Packaging Inc.\",\n  \"phoneOnFile\": \"(614) 555-0142\",\n  \"routing\": \"999000111\",\n  \"account\": \"9900004417\",\n  \"terms\": \"Net 30\"\n}\n\nPO register entry for the invoice's PO number (null if none). \"remaining\" is the amount minus billed to date:\n{\n  \"po\": \"PO-24017\",\n  \"vendorId\": \"V-1001\",\n  \"description\": \"Stretch film and carton tape, November\",\n  \"amount\": 1843.6,\n  \"billedToDate\": 0,\n  \"remaining\": 1843.6\n}\n\nAP ledger entries already recorded for this vendor:\n[\n  {\n    \"vendorId\": \"V-1001\",\n    \"invoiceNumber\": \"BL-20931\",\n    \"invoiceDate\": \"2026-10-14\",\n    \"total\": 1120.6,\n    \"po\": \"PO-23988\",\n    \"status\": \"paid 2026-11-12\"\n  }\n]\n\nCheck the invoice against the policy and the records. Return JSON:\n{\"route\": one of [\"reject_duplicate\",\"hold_verify_bank\",\"hold_possible_duplicate\",\"return_to_vendor\",\"hold_po_review\",\"approve_controller\",\"approve_ap\"], \"issues\": [one short string per problem you found; [] if none], \"note\": \"one or two sentences for the approver\"}"
       }
      ],
      "temperature": 0.2,
      "max_tokens": 16384,
      "stream": false
     },
     "response": {
      "id": "chatcmpl-253f6ba1-d72a-9b53-baa3-675aa61ddf31",
      "model": "qwen3.8-flash",
      "content": "{\"route\":\"approve_ap\",\"issues\":[],\"note\":\"The invoice matches the vendor master, arithmetic checks out, and the PO remaining balance covers the total. No duplicate or routing issues were found.\"}",
      "finishReason": "stop",
      "reasoningChars": 1525,
      "usage": {
       "prompt_tokens": 1226,
       "total_tokens": 1765,
       "completion_tokens": 539,
       "prompt_tokens_details": {
        "cached_tokens": 1024,
        "text_tokens": 1226
       },
       "completion_tokens_details": {
        "reasoning_tokens": 496,
        "text_tokens": 539
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 5159,
     "attempts": [
      {
       "status": 200,
       "ms": 5159
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "route": "approve_ap",
       "issues": [],
       "note": "The invoice matches the vendor master, arithmetic checks out, and the PO remaining balance covers the total. No duplicate or routing issues were found."
      }
     }
    },
    {
     "id": "check_rules",
     "kind": "tool",
     "tool": "check_rules",
     "ms": 0,
     "output": {
      "flags": [],
      "policyRoute": "approve_ap"
     }
    },
    {
     "id": "guardrail",
     "kind": "tool",
     "tool": "guardrail",
     "ms": 0,
     "output": {
      "finalRoute": "approve_ap",
      "modelRoute": "approve_ap",
      "policyRoute": "approve_ap",
      "override": false,
      "reason": "model and coded policy agree"
     }
    },
    {
     "id": "approval",
     "kind": "checkpoint",
     "checkpoint": "ap_approval",
     "status": "pending",
     "note": "Run stopped for human approval; nothing after this step was executed.",
     "packet": {
      "invoice": "brightline-bl-21407.pdf",
      "vendor": "Brightline Packaging Inc.",
      "invoiceNumber": "BL-21407",
      "total": 1843.6,
      "route": "approve_ap",
      "routeLabel": "AP lead approval",
      "flags": [],
      "modelNote": "The invoice matches the vendor master, arithmetic checks out, and the PO remaining balance covers the total. No duplicate or routing issues were found.",
      "guardrail": "model and coded policy agree",
      "onApprove": "Add to the next payment run (sandbox list)"
     }
    }
   ],
   "failure": null,
   "unusable": [],
   "score": {
    "pass": true,
    "checks": [
     {
      "id": "invoice_number",
      "label": "Invoice number",
      "stage": "model",
      "expected": "BL-21407",
      "got": "BL-21407",
      "ok": true
     },
     {
      "id": "invoice_date",
      "label": "Invoice date",
      "stage": "model",
      "expected": "2026-11-18",
      "got": "2026-11-18",
      "ok": true
     },
     {
      "id": "po_number",
      "label": "PO number",
      "stage": "model",
      "expected": "PO-24017",
      "got": "PO-24017",
      "ok": true
     },
     {
      "id": "line_count",
      "label": "Line items",
      "stage": "model",
      "expected": 2,
      "got": 2,
      "ok": true
     },
     {
      "id": "subtotal",
      "label": "Subtotal",
      "stage": "model",
      "expected": 1711,
      "got": 1711,
      "ok": true
     },
     {
      "id": "tax",
      "label": "Tax",
      "stage": "model",
      "expected": 132.6,
      "got": 132.6,
      "ok": true
     },
     {
      "id": "total",
      "label": "Total",
      "stage": "model",
      "expected": 1843.6,
      "got": 1843.6,
      "ok": true
     },
     {
      "id": "account",
      "label": "Remit-to account",
      "stage": "model",
      "expected": "9900004417",
      "got": "9900004417",
      "ok": true
     },
     {
      "id": "model_route",
      "label": "Model's own route",
      "stage": "model",
      "expected": "approve_ap",
      "got": "approve_ap",
      "ok": true
     },
     {
      "id": "final_route",
      "label": "Route sent to the approver",
      "stage": "final",
      "expected": "approve_ap",
      "got": "approve_ap",
      "ok": true
     }
    ],
    "informational": [
     "model_route"
    ]
   }
  },
  {
   "id": "inv-b",
   "label": "Ostara Industrial Parts Co. OIP-88213",
   "steps": [
    {
     "id": "read_pdf",
     "kind": "tool",
     "tool": "read_pdf_text",
     "ms": 32,
     "output": "INVOICE OIP-88213\nOSTARA INDUSTRIAL PARTS CO.\n(419) 555-0185\n1550 Matzinger Road · Toledo, OH 43612\nDATE  DUE  TERMS  YOUR PO\n11/20/2026  01/04/2027  Net 45  PO-24031\nCustomer  Remit payment to\nLarkfield Supply Co.  Maumee Example Bank\n2200 Mill Race Road  ABA routing: 999000177\nColumbus, OH 43215  Account no.: 9900005532\nITEM  QTY  PRICE  EXT.\nConveyor drive motor, 5 HP, 1750 RPM, TEFC  2  6,150.00  12,300.00\nGear reducer, 30:1 ratio, hollow bore  4  1,400.00  5,600.00\nFreight, flatbed delivery to Columbus OH  1  600.00  600.00\nSubtotal  18,500.00\nSales tax (exempt, certificate\n0.00\non file)\nAmount due  18,500.00\nQuestions about this invoice: receivables@ostara-parts.example.com"
    },
    {
     "id": "extract",
     "kind": "model",
     "request": {
      "model": "qwen3.8-flash",
      "messages": [
       {
        "role": "system",
        "content": "You extract data from vendor invoices for an accounts payable team. Copy values exactly as printed. Don't correct arithmetic, don't fill in values that aren't printed, and don't guess. Answer with one JSON object and nothing else."
       },
       {
        "role": "user",
        "content": "Extract these fields from the invoice text below. The invoice was sent to Larkfield Supply Co.; the vendor is the company that issued it.\n\nReturn JSON with exactly these keys:\n{\n  \"vendor_name\": string,\n  \"invoice_number\": string, as printed,\n  \"invoice_date\": \"YYYY-MM-DD\",\n  \"due_date\": \"YYYY-MM-DD\" or null,\n  \"po_number\": string or null,\n  \"line_items\": [{\"description\": string, \"quantity\": number, \"unit_price\": number, \"amount\": number}],\n  \"subtotal\": number,\n  \"tax\": number,\n  \"total\": number,\n  \"remit_to\": {\"bank_name\": string or null, \"routing_number\": string or null, \"account_number\": string or null},\n  \"phone_numbers_on_invoice\": [string],\n  \"notices\": [string]\n}\nAmounts are plain numbers without currency symbols or commas, as printed (don't recompute them). \"notices\" holds any printed notice, stamp or request, word for word; [] if there is none.\n\nInvoice text (extracted from ostara-oip-88213.pdf):\n\"\"\"\nINVOICE OIP-88213\nOSTARA INDUSTRIAL PARTS CO.\n(419) 555-0185\n1550 Matzinger Road · Toledo, OH 43612\nDATE  DUE  TERMS  YOUR PO\n11/20/2026  01/04/2027  Net 45  PO-24031\nCustomer  Remit payment to\nLarkfield Supply Co.  Maumee Example Bank\n2200 Mill Race Road  ABA routing: 999000177\nColumbus, OH 43215  Account no.: 9900005532\nITEM  QTY  PRICE  EXT.\nConveyor drive motor, 5 HP, 1750 RPM, TEFC  2  6,150.00  12,300.00\nGear reducer, 30:1 ratio, hollow bore  4  1,400.00  5,600.00\nFreight, flatbed delivery to Columbus OH  1  600.00  600.00\nSubtotal  18,500.00\nSales tax (exempt, certificate\n0.00\non file)\nAmount due  18,500.00\nQuestions about this invoice: receivables@ostara-parts.example.com\n\"\"\""
       }
      ],
      "temperature": 0.2,
      "max_tokens": 16384,
      "stream": false
     },
     "response": {
      "id": "chatcmpl-8ae97775-18c3-9ae4-9ac0-d43c7905391a",
      "model": "qwen3.8-flash",
      "content": "{\n  \"vendor_name\": \"OSTARA INDUSTRIAL PARTS CO.\",\n  \"invoice_number\": \"OIP-88213\",\n  \"invoice_date\": \"2026-11-20\",\n  \"due_date\": \"2027-01-04\",\n  \"po_number\": \"PO-24031\",\n  \"line_items\": [\n    {\n      \"description\": \"Conveyor drive motor, 5 HP, 1750 RPM, TEFC\",\n      \"quantity\": 2,\n      \"unit_price\": 6150.00,\n      \"amount\": 12300.00\n    },\n    {\n      \"description\": \"Gear reducer, 30:1 ratio, hollow bore\",\n      \"quantity\": 4,\n      \"unit_price\": 1400.00,\n      \"amount\": 5600.00\n    },\n    {\n      \"description\": \"Freight, flatbed delivery to Columbus OH\",\n      \"quantity\": 1,\n      \"unit_price\": 600.00,\n      \"amount\": 600.00\n    }\n  ],\n  \"subtotal\": 18500.00,\n  \"tax\": 0.00,\n  \"total\": 18500.00,\n  \"remit_to\": {\n    \"bank_name\": \"Maumee Example Bank\",\n    \"routing_number\": \"999000177\",\n    \"account_number\": \"9900005532\"\n  },\n  \"phone_numbers_on_invoice\": [\n    \"(419) 555-0185\"\n  ],\n  \"notices\": [\n    \"Sales tax (exempt, certificate on file)\",\n    \"Questions about this invoice: receivables@ostara-parts.example.com\"\n  ]\n}",
      "finishReason": "stop",
      "reasoningChars": 12180,
      "usage": {
       "prompt_tokens": 709,
       "total_tokens": 4927,
       "completion_tokens": 4218,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 709
       },
       "completion_tokens_details": {
        "reasoning_tokens": 3765,
        "text_tokens": 4218
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 42208,
     "attempts": [
      {
       "status": 200,
       "ms": 42208
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "vendor_name": "OSTARA INDUSTRIAL PARTS CO.",
       "invoice_number": "OIP-88213",
       "invoice_date": "2026-11-20",
       "due_date": "2027-01-04",
       "po_number": "PO-24031",
       "line_items": [
        {
         "description": "Conveyor drive motor, 5 HP, 1750 RPM, TEFC",
         "quantity": 2,
         "unit_price": 6150,
         "amount": 12300
        },
        {
         "description": "Gear reducer, 30:1 ratio, hollow bore",
         "quantity": 4,
         "unit_price": 1400,
         "amount": 5600
        },
        {
         "description": "Freight, flatbed delivery to Columbus OH",
         "quantity": 1,
         "unit_price": 600,
         "amount": 600
        }
       ],
       "subtotal": 18500,
       "tax": 0,
       "total": 18500,
       "remit_to": {
        "bank_name": "Maumee Example Bank",
        "routing_number": "999000177",
        "account_number": "9900005532"
       },
       "phone_numbers_on_invoice": [
        "(419) 555-0185"
       ],
       "notices": [
        "Sales tax (exempt, certificate on file)",
        "Questions about this invoice: receivables@ostara-parts.example.com"
       ]
      }
     }
    },
    {
     "id": "lookup",
     "kind": "tool",
     "tool": "lookup_records",
     "ms": 0,
     "output": {
      "vendor": {
       "id": "V-1004",
       "name": "Ostara Industrial Parts Co.",
       "phoneOnFile": "(419) 555-0185",
       "routing": "999000177",
       "account": "9900005532",
       "terms": "Net 45"
      },
      "po": {
       "po": "PO-24031",
       "vendorId": "V-1004",
       "description": "Line 2 conveyor drive replacement",
       "amount": 18500,
       "billedToDate": 0,
       "remaining": 18500
      },
      "ledger": []
     }
    },
    {
     "id": "review",
     "kind": "model",
     "request": {
      "model": "qwen3.8-flash",
      "messages": [
       {
        "role": "system",
        "content": "You are an accounts payable reviewer at Larkfield Supply Co.. You recommend a route for one invoice under the AP policy. You can't pay, approve or contact anyone; a person decides after reading your recommendation. Answer with one JSON object and nothing else."
       },
       {
        "role": "user",
        "content": "AP policy:\n\"\"\"\nLarkfield Supply Co. accounts payable routing policy (rev. 2026-10)\n\nPick exactly one route. When more than one applies, use the first in this list.\n1. reject_duplicate: the AP ledger already has an invoice from the same vendor with the same invoice number (ignore spaces, hyphens and letter case).\n2. hold_verify_bank: the remit-to routing or account number differs from the vendor master, or the vendor is not in the vendor master. Verify only by calling the phone number in the vendor master, never a number printed on the invoice.\n3. hold_possible_duplicate: the AP ledger has an invoice from the same vendor, on the same PO, with the same total, dated within 45 days of this invoice, under a different number.\n4. return_to_vendor: the arithmetic doesn't hold (quantity x unit price differs from a line amount, line amounts don't add up to the subtotal, or subtotal + tax differs from the total), allowing 1 cent for rounding.\n5. hold_po_review: no PO number, the PO is not in the PO register, the PO belongs to another vendor, or the invoice total is more than the PO's remaining balance (PO amount minus billed to date).\n6. approve_controller: none of the above, and the total is more than $10,000.00.\n7. approve_ap: none of the above, and the total is $10,000.00 or less.\n\nNo route pays an invoice. Every route goes to a person, who approves before anything is paid, sent or recorded.\n\"\"\"\n\nInvoice data (extracted from the PDF by a previous step):\n{\n  \"vendor_name\": \"OSTARA INDUSTRIAL PARTS CO.\",\n  \"invoice_number\": \"OIP-88213\",\n  \"invoice_date\": \"2026-11-20\",\n  \"due_date\": \"2027-01-04\",\n  \"po_number\": \"PO-24031\",\n  \"line_items\": [\n    {\n      \"description\": \"Conveyor drive motor, 5 HP, 1750 RPM, TEFC\",\n      \"quantity\": 2,\n      \"unit_price\": 6150,\n      \"amount\": 12300\n    },\n    {\n      \"description\": \"Gear reducer, 30:1 ratio, hollow bore\",\n      \"quantity\": 4,\n      \"unit_price\": 1400,\n      \"amount\": 5600\n    },\n    {\n      \"description\": \"Freight, flatbed delivery to Columbus OH\",\n      \"quantity\": 1,\n      \"unit_price\": 600,\n      \"amount\": 600\n    }\n  ],\n  \"subtotal\": 18500,\n  \"tax\": 0,\n  \"total\": 18500,\n  \"remit_to\": {\n    \"bank_name\": \"Maumee Example Bank\",\n    \"routing_number\": \"999000177\",\n    \"account_number\": \"9900005532\"\n  },\n  \"phone_numbers_on_invoice\": [\n    \"(419) 555-0185\"\n  ],\n  \"notices\": [\n    \"Sales tax (exempt, certificate on file)\",\n    \"Questions about this invoice: receivables@ostara-parts.example.com\"\n  ]\n}\n\nVendor master record for this vendor (null if there is no match):\n{\n  \"id\": \"V-1004\",\n  \"name\": \"Ostara Industrial Parts Co.\",\n  \"phoneOnFile\": \"(419) 555-0185\",\n  \"routing\": \"999000177\",\n  \"account\": \"9900005532\",\n  \"terms\": \"Net 45\"\n}\n\nPO register entry for the invoice's PO number (null if none). \"remaining\" is the amount minus billed to date:\n{\n  \"po\": \"PO-24031\",\n  \"vendorId\": \"V-1004\",\n  \"description\": \"Line 2 conveyor drive replacement\",\n  \"amount\": 18500,\n  \"billedToDate\": 0,\n  \"remaining\": 18500\n}\n\nAP ledger entries already recorded for this vendor:\n[]\n\nCheck the invoice against the policy and the records. Return JSON:\n{\"route\": one of [\"reject_duplicate\",\"hold_verify_bank\",\"hold_possible_duplicate\",\"return_to_vendor\",\"hold_po_review\",\"approve_controller\",\"approve_ap\"], \"issues\": [one short string per problem you found; [] if none], \"note\": \"one or two sentences for the approver\"}"
       }
      ],
      "temperature": 0.2,
      "max_tokens": 16384,
      "stream": false
     },
     "response": {
      "id": "chatcmpl-66956ce5-aa39-9277-addd-155e78c27ce2",
      "model": "qwen3.8-flash",
      "content": "{\n  \"route\": \"approve_controller\",\n  \"issues\": [],\n  \"note\": \"No policy issues found; invoice arithmetic, bank details, and PO balance check out. Route to controller because the total exceeds $10,000.\"\n}",
      "finishReason": "stop",
      "reasoningChars": 2121,
      "usage": {
       "prompt_tokens": 1197,
       "total_tokens": 1822,
       "completion_tokens": 625,
       "prompt_tokens_details": {
        "cached_tokens": 1024,
        "text_tokens": 1197
       },
       "completion_tokens_details": {
        "reasoning_tokens": 566,
        "text_tokens": 625
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 8285,
     "attempts": [
      {
       "status": 200,
       "ms": 8285
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "route": "approve_controller",
       "issues": [],
       "note": "No policy issues found; invoice arithmetic, bank details, and PO balance check out. Route to controller because the total exceeds $10,000."
      }
     }
    },
    {
     "id": "check_rules",
     "kind": "tool",
     "tool": "check_rules",
     "ms": 0,
     "output": {
      "flags": [],
      "policyRoute": "approve_controller"
     }
    },
    {
     "id": "guardrail",
     "kind": "tool",
     "tool": "guardrail",
     "ms": 0,
     "output": {
      "finalRoute": "approve_controller",
      "modelRoute": "approve_controller",
      "policyRoute": "approve_controller",
      "override": false,
      "reason": "model and coded policy agree"
     }
    },
    {
     "id": "approval",
     "kind": "checkpoint",
     "checkpoint": "ap_approval",
     "status": "pending",
     "note": "Run stopped for human approval; nothing after this step was executed.",
     "packet": {
      "invoice": "ostara-oip-88213.pdf",
      "vendor": "OSTARA INDUSTRIAL PARTS CO.",
      "invoiceNumber": "OIP-88213",
      "total": 18500,
      "route": "approve_controller",
      "routeLabel": "Controller approval",
      "flags": [],
      "modelNote": "No policy issues found; invoice arithmetic, bank details, and PO balance check out. Route to controller because the total exceeds $10,000.",
      "guardrail": "model and coded policy agree",
      "onApprove": "Add to the next payment run after controller sign-off (sandbox list)"
     }
    }
   ],
   "failure": null,
   "unusable": [],
   "score": {
    "pass": true,
    "checks": [
     {
      "id": "invoice_number",
      "label": "Invoice number",
      "stage": "model",
      "expected": "OIP-88213",
      "got": "OIP-88213",
      "ok": true
     },
     {
      "id": "invoice_date",
      "label": "Invoice date",
      "stage": "model",
      "expected": "2026-11-20",
      "got": "2026-11-20",
      "ok": true
     },
     {
      "id": "po_number",
      "label": "PO number",
      "stage": "model",
      "expected": "PO-24031",
      "got": "PO-24031",
      "ok": true
     },
     {
      "id": "line_count",
      "label": "Line items",
      "stage": "model",
      "expected": 3,
      "got": 3,
      "ok": true
     },
     {
      "id": "subtotal",
      "label": "Subtotal",
      "stage": "model",
      "expected": 18500,
      "got": 18500,
      "ok": true
     },
     {
      "id": "tax",
      "label": "Tax",
      "stage": "model",
      "expected": 0,
      "got": 0,
      "ok": true
     },
     {
      "id": "total",
      "label": "Total",
      "stage": "model",
      "expected": 18500,
      "got": 18500,
      "ok": true
     },
     {
      "id": "account",
      "label": "Remit-to account",
      "stage": "model",
      "expected": "9900005532",
      "got": "9900005532",
      "ok": true
     },
     {
      "id": "model_route",
      "label": "Model's own route",
      "stage": "model",
      "expected": "approve_controller",
      "got": "approve_controller",
      "ok": true
     },
     {
      "id": "final_route",
      "label": "Route sent to the approver",
      "stage": "final",
      "expected": "approve_controller",
      "got": "approve_controller",
      "ok": true
     }
    ],
    "informational": [
     "model_route"
    ]
   }
  },
  {
   "id": "inv-c",
   "label": "Brightline Packaging Inc. BL20931",
   "steps": [
    {
     "id": "read_pdf",
     "kind": "tool",
     "tool": "read_pdf_text",
     "ms": 36,
     "output": "Brightline Packaging Inc.\nINVOICE\n41 Harbor Road\nInvoice no.  BL20931\nGroveport, OH 43125\nInvoice date 10/14/2026\n(614) 555-0142 · billing@brightline-packaging.example.com\nTerms  Net 30\nDue date 11/13/2026\nCustomer PO  PO-23988\nSECOND NOTICE: PAST DUE. Please remit promptly to avoid a hold on your account.\nBILL TO  SHIP TO\nLarkfield Supply Co.  Larkfield Supply Co.\nAccounts Payable  Receiving, Dock 2\n2200 Mill Race Road  2200 Mill Race Road\nColumbus, OH 43215  Columbus, OH 43215\nap@larkfield.example.com\nDescription  Qty  Unit price  Amount\nCorrugated shipping box, 18 x 12 x 12 in, 32 ECT  500  2.08  1,040.00\nSubtotal  1,040.00\nSales tax 7.75%  80.60\nTotal due (USD)  $1,120.60\nRemit to: First Example Bank · Routing (ABA) 999000111 · Account 9900004417 · Reference invoice BL20931"
    },
    {
     "id": "extract",
     "kind": "model",
     "request": {
      "model": "qwen3.8-flash",
      "messages": [
       {
        "role": "system",
        "content": "You extract data from vendor invoices for an accounts payable team. Copy values exactly as printed. Don't correct arithmetic, don't fill in values that aren't printed, and don't guess. Answer with one JSON object and nothing else."
       },
       {
        "role": "user",
        "content": "Extract these fields from the invoice text below. The invoice was sent to Larkfield Supply Co.; the vendor is the company that issued it.\n\nReturn JSON with exactly these keys:\n{\n  \"vendor_name\": string,\n  \"invoice_number\": string, as printed,\n  \"invoice_date\": \"YYYY-MM-DD\",\n  \"due_date\": \"YYYY-MM-DD\" or null,\n  \"po_number\": string or null,\n  \"line_items\": [{\"description\": string, \"quantity\": number, \"unit_price\": number, \"amount\": number}],\n  \"subtotal\": number,\n  \"tax\": number,\n  \"total\": number,\n  \"remit_to\": {\"bank_name\": string or null, \"routing_number\": string or null, \"account_number\": string or null},\n  \"phone_numbers_on_invoice\": [string],\n  \"notices\": [string]\n}\nAmounts are plain numbers without currency symbols or commas, as printed (don't recompute them). \"notices\" holds any printed notice, stamp or request, word for word; [] if there is none.\n\nInvoice text (extracted from brightline-bl20931-second-notice.pdf):\n\"\"\"\nBrightline Packaging Inc.\nINVOICE\n41 Harbor Road\nInvoice no.  BL20931\nGroveport, OH 43125\nInvoice date 10/14/2026\n(614) 555-0142 · billing@brightline-packaging.example.com\nTerms  Net 30\nDue date 11/13/2026\nCustomer PO  PO-23988\nSECOND NOTICE: PAST DUE. Please remit promptly to avoid a hold on your account.\nBILL TO  SHIP TO\nLarkfield Supply Co.  Larkfield Supply Co.\nAccounts Payable  Receiving, Dock 2\n2200 Mill Race Road  2200 Mill Race Road\nColumbus, OH 43215  Columbus, OH 43215\nap@larkfield.example.com\nDescription  Qty  Unit price  Amount\nCorrugated shipping box, 18 x 12 x 12 in, 32 ECT  500  2.08  1,040.00\nSubtotal  1,040.00\nSales tax 7.75%  80.60\nTotal due (USD)  $1,120.60\nRemit to: First Example Bank · Routing (ABA) 999000111 · Account 9900004417 · Reference invoice BL20931\n\"\"\""
       }
      ],
      "temperature": 0.2,
      "max_tokens": 16384,
      "stream": false
     },
     "response": {
      "id": "chatcmpl-591493fc-9ea0-9a19-aa94-164acd3cba76",
      "model": "qwen3.8-flash",
      "content": "{\n  \"vendor_name\": \"Brightline Packaging Inc.\",\n  \"invoice_number\": \"BL20931\",\n  \"invoice_date\": \"2026-10-14\",\n  \"due_date\": \"2026-11-13\",\n  \"po_number\": \"PO-23988\",\n  \"line_items\": [\n    {\n      \"description\": \"Corrugated shipping box, 18 x 12 x 12 in, 32 ECT\",\n      \"quantity\": 500,\n      \"unit_price\": 2.08,\n      \"amount\": 1040.00\n    }\n  ],\n  \"subtotal\": 1040.00,\n  \"tax\": 80.60,\n  \"total\": 1120.60,\n  \"remit_to\": {\n    \"bank_name\": \"First Example Bank\",\n    \"routing_number\": \"999000111\",\n    \"account_number\": \"9900004417\"\n  },\n  \"phone_numbers_on_invoice\": [\n    \"(614) 555-0142\"\n  ],\n  \"notices\": [\n    \"SECOND NOTICE: PAST DUE. Please remit promptly to avoid a hold on your account.\"\n  ]\n}",
      "finishReason": "stop",
      "reasoningChars": 2254,
      "usage": {
       "prompt_tokens": 713,
       "total_tokens": 1787,
       "completion_tokens": 1074,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 713
       },
       "completion_tokens_details": {
        "reasoning_tokens": 751,
        "text_tokens": 1074
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 12984,
     "attempts": [
      {
       "status": 200,
       "ms": 12984
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "vendor_name": "Brightline Packaging Inc.",
       "invoice_number": "BL20931",
       "invoice_date": "2026-10-14",
       "due_date": "2026-11-13",
       "po_number": "PO-23988",
       "line_items": [
        {
         "description": "Corrugated shipping box, 18 x 12 x 12 in, 32 ECT",
         "quantity": 500,
         "unit_price": 2.08,
         "amount": 1040
        }
       ],
       "subtotal": 1040,
       "tax": 80.6,
       "total": 1120.6,
       "remit_to": {
        "bank_name": "First Example Bank",
        "routing_number": "999000111",
        "account_number": "9900004417"
       },
       "phone_numbers_on_invoice": [
        "(614) 555-0142"
       ],
       "notices": [
        "SECOND NOTICE: PAST DUE. Please remit promptly to avoid a hold on your account."
       ]
      }
     }
    },
    {
     "id": "lookup",
     "kind": "tool",
     "tool": "lookup_records",
     "ms": 0,
     "output": {
      "vendor": {
       "id": "V-1001",
       "name": "Brightline Packaging Inc.",
       "phoneOnFile": "(614) 555-0142",
       "routing": "999000111",
       "account": "9900004417",
       "terms": "Net 30"
      },
      "po": {
       "po": "PO-23988",
       "vendorId": "V-1001",
       "description": "Corrugated shipping boxes, October",
       "amount": 1120.6,
       "billedToDate": 1120.6,
       "remaining": 0
      },
      "ledger": [
       {
        "vendorId": "V-1001",
        "invoiceNumber": "BL-20931",
        "invoiceDate": "2026-10-14",
        "total": 1120.6,
        "po": "PO-23988",
        "status": "paid 2026-11-12"
       }
      ]
     }
    },
    {
     "id": "review",
     "kind": "model",
     "request": {
      "model": "qwen3.8-flash",
      "messages": [
       {
        "role": "system",
        "content": "You are an accounts payable reviewer at Larkfield Supply Co.. You recommend a route for one invoice under the AP policy. You can't pay, approve or contact anyone; a person decides after reading your recommendation. Answer with one JSON object and nothing else."
       },
       {
        "role": "user",
        "content": "AP policy:\n\"\"\"\nLarkfield Supply Co. accounts payable routing policy (rev. 2026-10)\n\nPick exactly one route. When more than one applies, use the first in this list.\n1. reject_duplicate: the AP ledger already has an invoice from the same vendor with the same invoice number (ignore spaces, hyphens and letter case).\n2. hold_verify_bank: the remit-to routing or account number differs from the vendor master, or the vendor is not in the vendor master. Verify only by calling the phone number in the vendor master, never a number printed on the invoice.\n3. hold_possible_duplicate: the AP ledger has an invoice from the same vendor, on the same PO, with the same total, dated within 45 days of this invoice, under a different number.\n4. return_to_vendor: the arithmetic doesn't hold (quantity x unit price differs from a line amount, line amounts don't add up to the subtotal, or subtotal + tax differs from the total), allowing 1 cent for rounding.\n5. hold_po_review: no PO number, the PO is not in the PO register, the PO belongs to another vendor, or the invoice total is more than the PO's remaining balance (PO amount minus billed to date).\n6. approve_controller: none of the above, and the total is more than $10,000.00.\n7. approve_ap: none of the above, and the total is $10,000.00 or less.\n\nNo route pays an invoice. Every route goes to a person, who approves before anything is paid, sent or recorded.\n\"\"\"\n\nInvoice data (extracted from the PDF by a previous step):\n{\n  \"vendor_name\": \"Brightline Packaging Inc.\",\n  \"invoice_number\": \"BL20931\",\n  \"invoice_date\": \"2026-10-14\",\n  \"due_date\": \"2026-11-13\",\n  \"po_number\": \"PO-23988\",\n  \"line_items\": [\n    {\n      \"description\": \"Corrugated shipping box, 18 x 12 x 12 in, 32 ECT\",\n      \"quantity\": 500,\n      \"unit_price\": 2.08,\n      \"amount\": 1040\n    }\n  ],\n  \"subtotal\": 1040,\n  \"tax\": 80.6,\n  \"total\": 1120.6,\n  \"remit_to\": {\n    \"bank_name\": \"First Example Bank\",\n    \"routing_number\": \"999000111\",\n    \"account_number\": \"9900004417\"\n  },\n  \"phone_numbers_on_invoice\": [\n    \"(614) 555-0142\"\n  ],\n  \"notices\": [\n    \"SECOND NOTICE: PAST DUE. Please remit promptly to avoid a hold on your account.\"\n  ]\n}\n\nVendor master record for this vendor (null if there is no match):\n{\n  \"id\": \"V-1001\",\n  \"name\": \"Brightline Packaging Inc.\",\n  \"phoneOnFile\": \"(614) 555-0142\",\n  \"routing\": \"999000111\",\n  \"account\": \"9900004417\",\n  \"terms\": \"Net 30\"\n}\n\nPO register entry for the invoice's PO number (null if none). \"remaining\" is the amount minus billed to date:\n{\n  \"po\": \"PO-23988\",\n  \"vendorId\": \"V-1001\",\n  \"description\": \"Corrugated shipping boxes, October\",\n  \"amount\": 1120.6,\n  \"billedToDate\": 1120.6,\n  \"remaining\": 0\n}\n\nAP ledger entries already recorded for this vendor:\n[\n  {\n    \"vendorId\": \"V-1001\",\n    \"invoiceNumber\": \"BL-20931\",\n    \"invoiceDate\": \"2026-10-14\",\n    \"total\": 1120.6,\n    \"po\": \"PO-23988\",\n    \"status\": \"paid 2026-11-12\"\n  }\n]\n\nCheck the invoice against the policy and the records. Return JSON:\n{\"route\": one of [\"reject_duplicate\",\"hold_verify_bank\",\"hold_possible_duplicate\",\"return_to_vendor\",\"hold_po_review\",\"approve_controller\",\"approve_ap\"], \"issues\": [one short string per problem you found; [] if none], \"note\": \"one or two sentences for the approver\"}"
       }
      ],
      "temperature": 0.2,
      "max_tokens": 16384,
      "stream": false
     },
     "response": {
      "id": "chatcmpl-7a9e0b93-7fdd-948f-aae7-41818d25bdb6",
      "model": "qwen3.8-flash",
      "content": "{\n  \"route\": \"reject_duplicate\",\n  \"issues\": [\n    \"AP ledger already contains a paid invoice for Brightline Packaging Inc. with the same invoice number after ignoring hyphens: BL20931 vs BL-20931.\"\n  ],\n  \"note\": \"This invoice matches an already paid ledger entry when invoice numbers are normalized. Reject as a duplicate before any further routing.\"\n}",
      "finishReason": "stop",
      "reasoningChars": 2364,
      "usage": {
       "prompt_tokens": 1188,
       "total_tokens": 1899,
       "completion_tokens": 711,
       "prompt_tokens_details": {
        "cached_tokens": 1024,
        "text_tokens": 1188
       },
       "completion_tokens_details": {
        "reasoning_tokens": 616,
        "text_tokens": 711
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 7859,
     "attempts": [
      {
       "status": 200,
       "ms": 7859
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "route": "reject_duplicate",
       "issues": [
        "AP ledger already contains a paid invoice for Brightline Packaging Inc. with the same invoice number after ignoring hyphens: BL20931 vs BL-20931."
       ],
       "note": "This invoice matches an already paid ledger entry when invoice numbers are normalized. Reject as a duplicate before any further routing."
      }
     }
    },
    {
     "id": "check_rules",
     "kind": "tool",
     "tool": "check_rules",
     "ms": 0,
     "output": {
      "flags": [
       {
        "code": "duplicate",
        "detail": "BL-20931 from 2026-10-14 is already in the AP ledger (paid 2026-11-12)"
       },
       {
        "code": "po_exceeded",
        "detail": "total $1,120.60 is more than the $0.00 left on PO-23988"
       }
      ],
      "policyRoute": "reject_duplicate"
     }
    },
    {
     "id": "guardrail",
     "kind": "tool",
     "tool": "guardrail",
     "ms": 0,
     "output": {
      "finalRoute": "reject_duplicate",
      "modelRoute": "reject_duplicate",
      "policyRoute": "reject_duplicate",
      "override": false,
      "reason": "model and coded policy agree"
     }
    },
    {
     "id": "approval",
     "kind": "checkpoint",
     "checkpoint": "ap_approval",
     "status": "pending",
     "note": "Run stopped for human approval; nothing after this step was executed.",
     "packet": {
      "invoice": "brightline-bl20931-second-notice.pdf",
      "vendor": "Brightline Packaging Inc.",
      "invoiceNumber": "BL20931",
      "total": 1120.6,
      "route": "reject_duplicate",
      "routeLabel": "Reject: duplicate",
      "flags": [
       {
        "code": "duplicate",
        "detail": "BL-20931 from 2026-10-14 is already in the AP ledger (paid 2026-11-12)"
       },
       {
        "code": "po_exceeded",
        "detail": "total $1,120.60 is more than the $0.00 left on PO-23988"
       }
      ],
      "modelNote": "This invoice matches an already paid ledger entry when invoice numbers are normalized. Reject as a duplicate before any further routing.",
      "guardrail": "model and coded policy agree",
      "onApprove": "Mark as duplicate; no payment (sandbox ledger note)"
     }
    }
   ],
   "failure": null,
   "unusable": [],
   "score": {
    "pass": true,
    "checks": [
     {
      "id": "invoice_number",
      "label": "Invoice number",
      "stage": "model",
      "expected": "BL20931",
      "got": "BL20931",
      "ok": true
     },
     {
      "id": "invoice_date",
      "label": "Invoice date",
      "stage": "model",
      "expected": "2026-10-14",
      "got": "2026-10-14",
      "ok": true
     },
     {
      "id": "po_number",
      "label": "PO number",
      "stage": "model",
      "expected": "PO-23988",
      "got": "PO-23988",
      "ok": true
     },
     {
      "id": "line_count",
      "label": "Line items",
      "stage": "model",
      "expected": 1,
      "got": 1,
      "ok": true
     },
     {
      "id": "subtotal",
      "label": "Subtotal",
      "stage": "model",
      "expected": 1040,
      "got": 1040,
      "ok": true
     },
     {
      "id": "tax",
      "label": "Tax",
      "stage": "model",
      "expected": 80.6,
      "got": 80.6,
      "ok": true
     },
     {
      "id": "total",
      "label": "Total",
      "stage": "model",
      "expected": 1120.6,
      "got": 1120.6,
      "ok": true
     },
     {
      "id": "account",
      "label": "Remit-to account",
      "stage": "model",
      "expected": "9900004417",
      "got": "9900004417",
      "ok": true
     },
     {
      "id": "model_route",
      "label": "Model's own route",
      "stage": "model",
      "expected": "reject_duplicate",
      "got": "reject_duplicate",
      "ok": true
     },
     {
      "id": "final_route",
      "label": "Route sent to the approver",
      "stage": "final",
      "expected": "reject_duplicate",
      "got": "reject_duplicate",
      "ok": true
     }
    ],
    "informational": [
     "model_route"
    ]
   }
  },
  {
   "id": "inv-d",
   "label": "Kestrel Facility Services KFS-1108",
   "steps": [
    {
     "id": "read_pdf",
     "kind": "tool",
     "tool": "read_pdf_text",
     "ms": 17,
     "output": "Kestrel Facility Services\n300 E Fourth Street, Suite 12, Cincinnati, OH 45202 · (513) 555-0119\nLarkfield Supply Co.\nAttn: Accounts Payable\n2200 Mill Race Road\nColumbus, OH 43215\nInvoice KFS-1108 Dated 11/30/2026 Net 30, due 12/30/2026 Purchase order PO-24052\nIMPORTANT: Our bank details have changed. Please update your records and send this and all\nfuture payments to the new account below. Questions? Call our new billing line at (513) 555-0190.\nService  Qty  Rate  Amount\nJanitorial service, November 2026, warehouse and office  1  2,150.00  2,150.00\nFloor scrub and seal, loading dock  1  250.00  250.00\nSubtotal  2,400.00\nSales tax (services, not taxable)  0.00\nPlease pay  $2,400.00\nPayment by ACH to: Queen City Example Bank, routing 999000244, account 9900008862.\nThank you for your business.\nBilling Department"
    },
    {
     "id": "extract",
     "kind": "model",
     "request": {
      "model": "qwen3.8-flash",
      "messages": [
       {
        "role": "system",
        "content": "You extract data from vendor invoices for an accounts payable team. Copy values exactly as printed. Don't correct arithmetic, don't fill in values that aren't printed, and don't guess. Answer with one JSON object and nothing else."
       },
       {
        "role": "user",
        "content": "Extract these fields from the invoice text below. The invoice was sent to Larkfield Supply Co.; the vendor is the company that issued it.\n\nReturn JSON with exactly these keys:\n{\n  \"vendor_name\": string,\n  \"invoice_number\": string, as printed,\n  \"invoice_date\": \"YYYY-MM-DD\",\n  \"due_date\": \"YYYY-MM-DD\" or null,\n  \"po_number\": string or null,\n  \"line_items\": [{\"description\": string, \"quantity\": number, \"unit_price\": number, \"amount\": number}],\n  \"subtotal\": number,\n  \"tax\": number,\n  \"total\": number,\n  \"remit_to\": {\"bank_name\": string or null, \"routing_number\": string or null, \"account_number\": string or null},\n  \"phone_numbers_on_invoice\": [string],\n  \"notices\": [string]\n}\nAmounts are plain numbers without currency symbols or commas, as printed (don't recompute them). \"notices\" holds any printed notice, stamp or request, word for word; [] if there is none.\n\nInvoice text (extracted from kestrel-kfs-1108.pdf):\n\"\"\"\nKestrel Facility Services\n300 E Fourth Street, Suite 12, Cincinnati, OH 45202 · (513) 555-0119\nLarkfield Supply Co.\nAttn: Accounts Payable\n2200 Mill Race Road\nColumbus, OH 43215\nInvoice KFS-1108 Dated 11/30/2026 Net 30, due 12/30/2026 Purchase order PO-24052\nIMPORTANT: Our bank details have changed. Please update your records and send this and all\nfuture payments to the new account below. Questions? Call our new billing line at (513) 555-0190.\nService  Qty  Rate  Amount\nJanitorial service, November 2026, warehouse and office  1  2,150.00  2,150.00\nFloor scrub and seal, loading dock  1  250.00  250.00\nSubtotal  2,400.00\nSales tax (services, not taxable)  0.00\nPlease pay  $2,400.00\nPayment by ACH to: Queen City Example Bank, routing 999000244, account 9900008862.\nThank you for your business.\nBilling Department\n\"\"\""
       }
      ],
      "temperature": 0.2,
      "max_tokens": 16384,
      "stream": false
     },
     "response": {
      "id": "chatcmpl-331b2689-fb62-95c2-99a0-9679deca20e6",
      "model": "qwen3.8-flash",
      "content": "{\n  \"vendor_name\": \"Kestrel Facility Services\",\n  \"invoice_number\": \"KFS-1108\",\n  \"invoice_date\": \"2026-11-30\",\n  \"due_date\": \"2026-12-30\",\n  \"po_number\": \"PO-24052\",\n  \"line_items\": [\n    {\n      \"description\": \"Janitorial service, November 2026, warehouse and office\",\n      \"quantity\": 1,\n      \"unit_price\": 2150.00,\n      \"amount\": 2150.00\n    },\n    {\n      \"description\": \"Floor scrub and seal, loading dock\",\n      \"quantity\": 1,\n      \"unit_price\": 250.00,\n      \"amount\": 250.00\n    }\n  ],\n  \"subtotal\": 2400.00,\n  \"tax\": 0.00,\n  \"total\": 2400.00,\n  \"remit_to\": {\n    \"bank_name\": \"Queen City Example Bank\",\n    \"routing_number\": \"999000244\",\n    \"account_number\": \"9900008862\"\n  },\n  \"phone_numbers_on_invoice\": [\n    \"(513) 555-0119\",\n    \"(513) 555-0190\"\n  ],\n  \"notices\": [\n    \"IMPORTANT: Our bank details have changed. Please update your records and send this and all future payments to the new account below. Questions? Call our new billing line at (513) 555-0190.\",\n    \"Please pay  $2,400.00\"\n  ]\n}",
      "finishReason": "stop",
      "reasoningChars": 27213,
      "usage": {
       "prompt_tokens": 696,
       "total_tokens": 8536,
       "completion_tokens": 7840,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 696
       },
       "completion_tokens_details": {
        "reasoning_tokens": 7408,
        "text_tokens": 7840
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 80078,
     "attempts": [
      {
       "status": 200,
       "ms": 80078
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "vendor_name": "Kestrel Facility Services",
       "invoice_number": "KFS-1108",
       "invoice_date": "2026-11-30",
       "due_date": "2026-12-30",
       "po_number": "PO-24052",
       "line_items": [
        {
         "description": "Janitorial service, November 2026, warehouse and office",
         "quantity": 1,
         "unit_price": 2150,
         "amount": 2150
        },
        {
         "description": "Floor scrub and seal, loading dock",
         "quantity": 1,
         "unit_price": 250,
         "amount": 250
        }
       ],
       "subtotal": 2400,
       "tax": 0,
       "total": 2400,
       "remit_to": {
        "bank_name": "Queen City Example Bank",
        "routing_number": "999000244",
        "account_number": "9900008862"
       },
       "phone_numbers_on_invoice": [
        "(513) 555-0119",
        "(513) 555-0190"
       ],
       "notices": [
        "IMPORTANT: Our bank details have changed. Please update your records and send this and all future payments to the new account below. Questions? Call our new billing line at (513) 555-0190.",
        "Please pay  $2,400.00"
       ]
      }
     }
    },
    {
     "id": "lookup",
     "kind": "tool",
     "tool": "lookup_records",
     "ms": 0,
     "output": {
      "vendor": {
       "id": "V-1003",
       "name": "Kestrel Facility Services",
       "phoneOnFile": "(513) 555-0119",
       "routing": "999000155",
       "account": "9900007051",
       "terms": "Net 30"
      },
      "po": {
       "po": "PO-24052",
       "vendorId": "V-1003",
       "description": "Janitorial service, November",
       "amount": 2400,
       "billedToDate": 0,
       "remaining": 2400
      },
      "ledger": [
       {
        "vendorId": "V-1003",
        "invoiceNumber": "KFS-1031",
        "invoiceDate": "2026-10-31",
        "total": 2400,
        "po": "PO-23990",
        "status": "paid 2026-11-28"
       }
      ]
     }
    },
    {
     "id": "review",
     "kind": "model",
     "request": {
      "model": "qwen3.8-flash",
      "messages": [
       {
        "role": "system",
        "content": "You are an accounts payable reviewer at Larkfield Supply Co.. You recommend a route for one invoice under the AP policy. You can't pay, approve or contact anyone; a person decides after reading your recommendation. Answer with one JSON object and nothing else."
       },
       {
        "role": "user",
        "content": "AP policy:\n\"\"\"\nLarkfield Supply Co. accounts payable routing policy (rev. 2026-10)\n\nPick exactly one route. When more than one applies, use the first in this list.\n1. reject_duplicate: the AP ledger already has an invoice from the same vendor with the same invoice number (ignore spaces, hyphens and letter case).\n2. hold_verify_bank: the remit-to routing or account number differs from the vendor master, or the vendor is not in the vendor master. Verify only by calling the phone number in the vendor master, never a number printed on the invoice.\n3. hold_possible_duplicate: the AP ledger has an invoice from the same vendor, on the same PO, with the same total, dated within 45 days of this invoice, under a different number.\n4. return_to_vendor: the arithmetic doesn't hold (quantity x unit price differs from a line amount, line amounts don't add up to the subtotal, or subtotal + tax differs from the total), allowing 1 cent for rounding.\n5. hold_po_review: no PO number, the PO is not in the PO register, the PO belongs to another vendor, or the invoice total is more than the PO's remaining balance (PO amount minus billed to date).\n6. approve_controller: none of the above, and the total is more than $10,000.00.\n7. approve_ap: none of the above, and the total is $10,000.00 or less.\n\nNo route pays an invoice. Every route goes to a person, who approves before anything is paid, sent or recorded.\n\"\"\"\n\nInvoice data (extracted from the PDF by a previous step):\n{\n  \"vendor_name\": \"Kestrel Facility Services\",\n  \"invoice_number\": \"KFS-1108\",\n  \"invoice_date\": \"2026-11-30\",\n  \"due_date\": \"2026-12-30\",\n  \"po_number\": \"PO-24052\",\n  \"line_items\": [\n    {\n      \"description\": \"Janitorial service, November 2026, warehouse and office\",\n      \"quantity\": 1,\n      \"unit_price\": 2150,\n      \"amount\": 2150\n    },\n    {\n      \"description\": \"Floor scrub and seal, loading dock\",\n      \"quantity\": 1,\n      \"unit_price\": 250,\n      \"amount\": 250\n    }\n  ],\n  \"subtotal\": 2400,\n  \"tax\": 0,\n  \"total\": 2400,\n  \"remit_to\": {\n    \"bank_name\": \"Queen City Example Bank\",\n    \"routing_number\": \"999000244\",\n    \"account_number\": \"9900008862\"\n  },\n  \"phone_numbers_on_invoice\": [\n    \"(513) 555-0119\",\n    \"(513) 555-0190\"\n  ],\n  \"notices\": [\n    \"IMPORTANT: Our bank details have changed. Please update your records and send this and all future payments to the new account below. Questions? Call our new billing line at (513) 555-0190.\",\n    \"Please pay  $2,400.00\"\n  ]\n}\n\nVendor master record for this vendor (null if there is no match):\n{\n  \"id\": \"V-1003\",\n  \"name\": \"Kestrel Facility Services\",\n  \"phoneOnFile\": \"(513) 555-0119\",\n  \"routing\": \"999000155\",\n  \"account\": \"9900007051\",\n  \"terms\": \"Net 30\"\n}\n\nPO register entry for the invoice's PO number (null if none). \"remaining\" is the amount minus billed to date:\n{\n  \"po\": \"PO-24052\",\n  \"vendorId\": \"V-1003\",\n  \"description\": \"Janitorial service, November\",\n  \"amount\": 2400,\n  \"billedToDate\": 0,\n  \"remaining\": 2400\n}\n\nAP ledger entries already recorded for this vendor:\n[\n  {\n    \"vendorId\": \"V-1003\",\n    \"invoiceNumber\": \"KFS-1031\",\n    \"invoiceDate\": \"2026-10-31\",\n    \"total\": 2400,\n    \"po\": \"PO-23990\",\n    \"status\": \"paid 2026-11-28\"\n  }\n]\n\nCheck the invoice against the policy and the records. Return JSON:\n{\"route\": one of [\"reject_duplicate\",\"hold_verify_bank\",\"hold_possible_duplicate\",\"return_to_vendor\",\"hold_po_review\",\"approve_controller\",\"approve_ap\"], \"issues\": [one short string per problem you found; [] if none], \"note\": \"one or two sentences for the approver\"}"
       }
      ],
      "temperature": 0.2,
      "max_tokens": 16384,
      "stream": false
     },
     "response": {
      "id": "chatcmpl-2f8de656-9d43-9618-a167-f75c799b0f7c",
      "model": "qwen3.8-flash",
      "content": "{\n  \"route\": \"hold_verify_bank\",\n  \"issues\": [\n    \"Remit-to routing and account numbers differ from the vendor master.\",\n    \"Invoice notice claims bank details changed and provides a new billing phone number, but only the vendor master phone may be used for verification.\"\n  ],\n  \"note\": \"The invoice is otherwise arithmetically clean and matches the PO, but the bank details do not match the vendor master. Hold for bank verification using the vendor master phone number only; do not use any phone number printed on the invoice.\"\n}",
      "finishReason": "stop",
      "reasoningChars": 1812,
      "usage": {
       "prompt_tokens": 1277,
       "total_tokens": 1927,
       "completion_tokens": 650,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 1277
       },
       "completion_tokens_details": {
        "reasoning_tokens": 526,
        "text_tokens": 650
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 6143,
     "attempts": [
      {
       "status": 200,
       "ms": 6143
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "route": "hold_verify_bank",
       "issues": [
        "Remit-to routing and account numbers differ from the vendor master.",
        "Invoice notice claims bank details changed and provides a new billing phone number, but only the vendor master phone may be used for verification."
       ],
       "note": "The invoice is otherwise arithmetically clean and matches the PO, but the bank details do not match the vendor master. Hold for bank verification using the vendor master phone number only; do not use any phone number printed on the invoice."
      }
     }
    },
    {
     "id": "check_rules",
     "kind": "tool",
     "tool": "check_rules",
     "ms": 0,
     "output": {
      "flags": [
       {
        "code": "bank_mismatch",
        "detail": "invoice remits to routing 999000244, account 9900008862; vendor master has routing 999000155, account 9900007051"
       }
      ],
      "policyRoute": "hold_verify_bank"
     }
    },
    {
     "id": "guardrail",
     "kind": "tool",
     "tool": "guardrail",
     "ms": 0,
     "output": {
      "finalRoute": "hold_verify_bank",
      "modelRoute": "hold_verify_bank",
      "policyRoute": "hold_verify_bank",
      "override": false,
      "reason": "model and coded policy agree"
     }
    },
    {
     "id": "approval",
     "kind": "checkpoint",
     "checkpoint": "ap_approval",
     "status": "pending",
     "note": "Run stopped for human approval; nothing after this step was executed.",
     "packet": {
      "invoice": "kestrel-kfs-1108.pdf",
      "vendor": "Kestrel Facility Services",
      "invoiceNumber": "KFS-1108",
      "total": 2400,
      "route": "hold_verify_bank",
      "routeLabel": "Hold: verify bank details",
      "flags": [
       {
        "code": "bank_mismatch",
        "detail": "invoice remits to routing 999000244, account 9900008862; vendor master has routing 999000155, account 9900007051"
       }
      ],
      "modelNote": "The invoice is otherwise arithmetically clean and matches the PO, but the bank details do not match the vendor master. Hold for bank verification using the vendor master phone number only; do not use any phone number printed on the invoice.",
      "guardrail": "model and coded policy agree",
      "onApprove": "Open a call-back task to the vendor phone number on file (sandbox task)"
     }
    }
   ],
   "failure": null,
   "unusable": [],
   "score": {
    "pass": true,
    "checks": [
     {
      "id": "invoice_number",
      "label": "Invoice number",
      "stage": "model",
      "expected": "KFS-1108",
      "got": "KFS-1108",
      "ok": true
     },
     {
      "id": "invoice_date",
      "label": "Invoice date",
      "stage": "model",
      "expected": "2026-11-30",
      "got": "2026-11-30",
      "ok": true
     },
     {
      "id": "po_number",
      "label": "PO number",
      "stage": "model",
      "expected": "PO-24052",
      "got": "PO-24052",
      "ok": true
     },
     {
      "id": "line_count",
      "label": "Line items",
      "stage": "model",
      "expected": 2,
      "got": 2,
      "ok": true
     },
     {
      "id": "subtotal",
      "label": "Subtotal",
      "stage": "model",
      "expected": 2400,
      "got": 2400,
      "ok": true
     },
     {
      "id": "tax",
      "label": "Tax",
      "stage": "model",
      "expected": 0,
      "got": 0,
      "ok": true
     },
     {
      "id": "total",
      "label": "Total",
      "stage": "model",
      "expected": 2400,
      "got": 2400,
      "ok": true
     },
     {
      "id": "account",
      "label": "Remit-to account",
      "stage": "model",
      "expected": "9900008862",
      "got": "9900008862",
      "ok": true
     },
     {
      "id": "model_route",
      "label": "Model's own route",
      "stage": "model",
      "expected": "hold_verify_bank",
      "got": "hold_verify_bank",
      "ok": true
     },
     {
      "id": "final_route",
      "label": "Route sent to the approver",
      "stage": "final",
      "expected": "hold_verify_bank",
      "got": "hold_verify_bank",
      "ok": true
     }
    ],
    "informational": [
     "model_route"
    ]
   }
  },
  {
   "id": "inv-e",
   "label": "Pinegate Office Supply 55187",
   "steps": [
    {
     "id": "read_pdf",
     "kind": "tool",
     "tool": "read_pdf_text",
     "ms": 12,
     "output": "Pinegate Office Supply\nINVOICE\n880 Euclid Avenue\nInvoice no.  55187\nCleveland, OH 44115\nInvoice date 11/24/2026\n(216) 555-0127 · ar@pinegate.example.com\nTerms  Net 30\nDue date 12/24/2026\nCustomer PO  PO-24071\nBILL TO  SHIP TO\nLarkfield Supply Co.  Larkfield Supply Co.\nAccounts Payable  Receiving, Dock 2\n2200 Mill Race Road  2200 Mill Race Road\nColumbus, OH 43215  Columbus, OH 43215\nap@larkfield.example.com\nDescription  Qty  Unit price  Amount\nToner cartridge 58X, black  6  89.99  539.94\nCopy paper, letter, 10-ream case  10  42.50  425.00\nDesk organizer, mesh, 5 compartment  4  18.75  75.00\nSubtotal  1,064.94\nSales tax 8.00%  85.20\nTotal due (USD)  $1,150.14\nRemit to: Lakeshore Example Bank · Routing (ABA) 999000199 · Account 9900001180 · Reference invoice 55187"
    },
    {
     "id": "extract",
     "kind": "model",
     "request": {
      "model": "qwen3.8-flash",
      "messages": [
       {
        "role": "system",
        "content": "You extract data from vendor invoices for an accounts payable team. Copy values exactly as printed. Don't correct arithmetic, don't fill in values that aren't printed, and don't guess. Answer with one JSON object and nothing else."
       },
       {
        "role": "user",
        "content": "Extract these fields from the invoice text below. The invoice was sent to Larkfield Supply Co.; the vendor is the company that issued it.\n\nReturn JSON with exactly these keys:\n{\n  \"vendor_name\": string,\n  \"invoice_number\": string, as printed,\n  \"invoice_date\": \"YYYY-MM-DD\",\n  \"due_date\": \"YYYY-MM-DD\" or null,\n  \"po_number\": string or null,\n  \"line_items\": [{\"description\": string, \"quantity\": number, \"unit_price\": number, \"amount\": number}],\n  \"subtotal\": number,\n  \"tax\": number,\n  \"total\": number,\n  \"remit_to\": {\"bank_name\": string or null, \"routing_number\": string or null, \"account_number\": string or null},\n  \"phone_numbers_on_invoice\": [string],\n  \"notices\": [string]\n}\nAmounts are plain numbers without currency symbols or commas, as printed (don't recompute them). \"notices\" holds any printed notice, stamp or request, word for word; [] if there is none.\n\nInvoice text (extracted from pinegate-55187.pdf):\n\"\"\"\nPinegate Office Supply\nINVOICE\n880 Euclid Avenue\nInvoice no.  55187\nCleveland, OH 44115\nInvoice date 11/24/2026\n(216) 555-0127 · ar@pinegate.example.com\nTerms  Net 30\nDue date 12/24/2026\nCustomer PO  PO-24071\nBILL TO  SHIP TO\nLarkfield Supply Co.  Larkfield Supply Co.\nAccounts Payable  Receiving, Dock 2\n2200 Mill Race Road  2200 Mill Race Road\nColumbus, OH 43215  Columbus, OH 43215\nap@larkfield.example.com\nDescription  Qty  Unit price  Amount\nToner cartridge 58X, black  6  89.99  539.94\nCopy paper, letter, 10-ream case  10  42.50  425.00\nDesk organizer, mesh, 5 compartment  4  18.75  75.00\nSubtotal  1,064.94\nSales tax 8.00%  85.20\nTotal due (USD)  $1,150.14\nRemit to: Lakeshore Example Bank · Routing (ABA) 999000199 · Account 9900001180 · Reference invoice 55187\n\"\"\""
       }
      ],
      "temperature": 0.2,
      "max_tokens": 16384,
      "stream": false
     },
     "response": {
      "id": "chatcmpl-7f238741-92e8-9556-b9a8-ba8d08f55fa3",
      "model": "qwen3.8-flash",
      "content": "{\n  \"vendor_name\": \"Pinegate Office Supply\",\n  \"invoice_number\": \"55187\",\n  \"invoice_date\": \"2026-11-24\",\n  \"due_date\": \"2026-12-24\",\n  \"po_number\": \"PO-24071\",\n  \"line_items\": [\n    {\n      \"description\": \"Toner cartridge 58X, black\",\n      \"quantity\": 6,\n      \"unit_price\": 89.99,\n      \"amount\": 539.94\n    },\n    {\n      \"description\": \"Copy paper, letter, 10-ream case\",\n      \"quantity\": 10,\n      \"unit_price\": 42.50,\n      \"amount\": 425.00\n    },\n    {\n      \"description\": \"Desk organizer, mesh, 5 compartment\",\n      \"quantity\": 4,\n      \"unit_price\": 18.75,\n      \"amount\": 75.00\n    }\n  ],\n  \"subtotal\": 1064.94,\n  \"tax\": 85.20,\n  \"total\": 1150.14,\n  \"remit_to\": {\n    \"bank_name\": \"Lakeshore Example Bank\",\n    \"routing_number\": \"999000199\",\n    \"account_number\": \"9900001180\"\n  },\n  \"phone_numbers_on_invoice\": [\n    \"(216) 555-0127\"\n  ],\n  \"notices\": []\n}",
      "finishReason": "stop",
      "reasoningChars": 2729,
      "usage": {
       "prompt_tokens": 730,
       "total_tokens": 2028,
       "completion_tokens": 1298,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 730
       },
       "completion_tokens_details": {
        "reasoning_tokens": 903,
        "text_tokens": 1298
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 14760,
     "attempts": [
      {
       "status": 200,
       "ms": 14760
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "vendor_name": "Pinegate Office Supply",
       "invoice_number": "55187",
       "invoice_date": "2026-11-24",
       "due_date": "2026-12-24",
       "po_number": "PO-24071",
       "line_items": [
        {
         "description": "Toner cartridge 58X, black",
         "quantity": 6,
         "unit_price": 89.99,
         "amount": 539.94
        },
        {
         "description": "Copy paper, letter, 10-ream case",
         "quantity": 10,
         "unit_price": 42.5,
         "amount": 425
        },
        {
         "description": "Desk organizer, mesh, 5 compartment",
         "quantity": 4,
         "unit_price": 18.75,
         "amount": 75
        }
       ],
       "subtotal": 1064.94,
       "tax": 85.2,
       "total": 1150.14,
       "remit_to": {
        "bank_name": "Lakeshore Example Bank",
        "routing_number": "999000199",
        "account_number": "9900001180"
       },
       "phone_numbers_on_invoice": [
        "(216) 555-0127"
       ],
       "notices": []
      }
     }
    },
    {
     "id": "lookup",
     "kind": "tool",
     "tool": "lookup_records",
     "ms": 1,
     "output": {
      "vendor": {
       "id": "V-1005",
       "name": "Pinegate Office Supply",
       "phoneOnFile": "(216) 555-0127",
       "routing": "999000199",
       "account": "9900001180",
       "terms": "Net 30"
      },
      "po": {
       "po": "PO-24071",
       "vendorId": "V-1005",
       "description": "Toner, paper and desk supplies",
       "amount": 1123.14,
       "billedToDate": 0,
       "remaining": 1123.14
      },
      "ledger": [
       {
        "vendorId": "V-1005",
        "invoiceNumber": "55120",
        "invoiceDate": "2026-11-10",
        "total": 612.36,
        "po": "PO-24060",
        "status": "approved, in the 2026-12-10 payment run"
       }
      ]
     }
    },
    {
     "id": "review",
     "kind": "model",
     "request": {
      "model": "qwen3.8-flash",
      "messages": [
       {
        "role": "system",
        "content": "You are an accounts payable reviewer at Larkfield Supply Co.. You recommend a route for one invoice under the AP policy. You can't pay, approve or contact anyone; a person decides after reading your recommendation. Answer with one JSON object and nothing else."
       },
       {
        "role": "user",
        "content": "AP policy:\n\"\"\"\nLarkfield Supply Co. accounts payable routing policy (rev. 2026-10)\n\nPick exactly one route. When more than one applies, use the first in this list.\n1. reject_duplicate: the AP ledger already has an invoice from the same vendor with the same invoice number (ignore spaces, hyphens and letter case).\n2. hold_verify_bank: the remit-to routing or account number differs from the vendor master, or the vendor is not in the vendor master. Verify only by calling the phone number in the vendor master, never a number printed on the invoice.\n3. hold_possible_duplicate: the AP ledger has an invoice from the same vendor, on the same PO, with the same total, dated within 45 days of this invoice, under a different number.\n4. return_to_vendor: the arithmetic doesn't hold (quantity x unit price differs from a line amount, line amounts don't add up to the subtotal, or subtotal + tax differs from the total), allowing 1 cent for rounding.\n5. hold_po_review: no PO number, the PO is not in the PO register, the PO belongs to another vendor, or the invoice total is more than the PO's remaining balance (PO amount minus billed to date).\n6. approve_controller: none of the above, and the total is more than $10,000.00.\n7. approve_ap: none of the above, and the total is $10,000.00 or less.\n\nNo route pays an invoice. Every route goes to a person, who approves before anything is paid, sent or recorded.\n\"\"\"\n\nInvoice data (extracted from the PDF by a previous step):\n{\n  \"vendor_name\": \"Pinegate Office Supply\",\n  \"invoice_number\": \"55187\",\n  \"invoice_date\": \"2026-11-24\",\n  \"due_date\": \"2026-12-24\",\n  \"po_number\": \"PO-24071\",\n  \"line_items\": [\n    {\n      \"description\": \"Toner cartridge 58X, black\",\n      \"quantity\": 6,\n      \"unit_price\": 89.99,\n      \"amount\": 539.94\n    },\n    {\n      \"description\": \"Copy paper, letter, 10-ream case\",\n      \"quantity\": 10,\n      \"unit_price\": 42.5,\n      \"amount\": 425\n    },\n    {\n      \"description\": \"Desk organizer, mesh, 5 compartment\",\n      \"quantity\": 4,\n      \"unit_price\": 18.75,\n      \"amount\": 75\n    }\n  ],\n  \"subtotal\": 1064.94,\n  \"tax\": 85.2,\n  \"total\": 1150.14,\n  \"remit_to\": {\n    \"bank_name\": \"Lakeshore Example Bank\",\n    \"routing_number\": \"999000199\",\n    \"account_number\": \"9900001180\"\n  },\n  \"phone_numbers_on_invoice\": [\n    \"(216) 555-0127\"\n  ],\n  \"notices\": []\n}\n\nVendor master record for this vendor (null if there is no match):\n{\n  \"id\": \"V-1005\",\n  \"name\": \"Pinegate Office Supply\",\n  \"phoneOnFile\": \"(216) 555-0127\",\n  \"routing\": \"999000199\",\n  \"account\": \"9900001180\",\n  \"terms\": \"Net 30\"\n}\n\nPO register entry for the invoice's PO number (null if none). \"remaining\" is the amount minus billed to date:\n{\n  \"po\": \"PO-24071\",\n  \"vendorId\": \"V-1005\",\n  \"description\": \"Toner, paper and desk supplies\",\n  \"amount\": 1123.14,\n  \"billedToDate\": 0,\n  \"remaining\": 1123.14\n}\n\nAP ledger entries already recorded for this vendor:\n[\n  {\n    \"vendorId\": \"V-1005\",\n    \"invoiceNumber\": \"55120\",\n    \"invoiceDate\": \"2026-11-10\",\n    \"total\": 612.36,\n    \"po\": \"PO-24060\",\n    \"status\": \"approved, in the 2026-12-10 payment run\"\n  }\n]\n\nCheck the invoice against the policy and the records. Return JSON:\n{\"route\": one of [\"reject_duplicate\",\"hold_verify_bank\",\"hold_possible_duplicate\",\"return_to_vendor\",\"hold_po_review\",\"approve_controller\",\"approve_ap\"], \"issues\": [one short string per problem you found; [] if none], \"note\": \"one or two sentences for the approver\"}"
       }
      ],
      "temperature": 0.2,
      "max_tokens": 16384,
      "stream": false
     },
     "response": {
      "id": "chatcmpl-2bab5c3a-3364-99bf-8ad7-2845fcc73baf",
      "model": "qwen3.8-flash",
      "content": "{\n  \"route\": \"return_to_vendor\",\n  \"issues\": [\n    \"Line amounts sum to $1,039.94, not stated subtotal $1,064.94.\",\n    \"Invoice total $1,150.14 exceeds PO remaining balance $1,123.14.\"\n  ],\n  \"note\": \"Return to vendor for a corrected invoice because the line-item arithmetic does not support the subtotal. The current total also exceeds the PO remaining balance.\"\n}",
      "finishReason": "stop",
      "reasoningChars": 4424,
      "usage": {
       "prompt_tokens": 1266,
       "total_tokens": 2679,
       "completion_tokens": 1413,
       "prompt_tokens_details": {
        "cached_tokens": 1024,
        "text_tokens": 1266
       },
       "completion_tokens_details": {
        "reasoning_tokens": 1296,
        "text_tokens": 1413
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 12039,
     "attempts": [
      {
       "status": 200,
       "ms": 12039
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "route": "return_to_vendor",
       "issues": [
        "Line amounts sum to $1,039.94, not stated subtotal $1,064.94.",
        "Invoice total $1,150.14 exceeds PO remaining balance $1,123.14."
       ],
       "note": "Return to vendor for a corrected invoice because the line-item arithmetic does not support the subtotal. The current total also exceeds the PO remaining balance."
      }
     }
    },
    {
     "id": "check_rules",
     "kind": "tool",
     "tool": "check_rules",
     "ms": 0,
     "output": {
      "flags": [
       {
        "code": "math_error",
        "detail": "lines add up to $1,039.94, subtotal says $1,064.94"
       },
       {
        "code": "po_exceeded",
        "detail": "total $1,150.14 is more than the $1,123.14 left on PO-24071"
       }
      ],
      "policyRoute": "return_to_vendor"
     }
    },
    {
     "id": "guardrail",
     "kind": "tool",
     "tool": "guardrail",
     "ms": 0,
     "output": {
      "finalRoute": "return_to_vendor",
      "modelRoute": "return_to_vendor",
      "policyRoute": "return_to_vendor",
      "override": false,
      "reason": "model and coded policy agree"
     }
    },
    {
     "id": "approval",
     "kind": "checkpoint",
     "checkpoint": "ap_approval",
     "status": "pending",
     "note": "Run stopped for human approval; nothing after this step was executed.",
     "packet": {
      "invoice": "pinegate-55187.pdf",
      "vendor": "Pinegate Office Supply",
      "invoiceNumber": "55187",
      "total": 1150.14,
      "route": "return_to_vendor",
      "routeLabel": "Return to vendor",
      "flags": [
       {
        "code": "math_error",
        "detail": "lines add up to $1,039.94, subtotal says $1,064.94"
       },
       {
        "code": "po_exceeded",
        "detail": "total $1,150.14 is more than the $1,123.14 left on PO-24071"
       }
      ],
      "modelNote": "Return to vendor for a corrected invoice because the line-item arithmetic does not support the subtotal. The current total also exceeds the PO remaining balance.",
      "guardrail": "model and coded policy agree",
      "onApprove": "Draft a correction request to the vendor's billing email on file (sandbox draft, not sent)"
     }
    }
   ],
   "failure": null,
   "unusable": [],
   "score": {
    "pass": true,
    "checks": [
     {
      "id": "invoice_number",
      "label": "Invoice number",
      "stage": "model",
      "expected": "55187",
      "got": "55187",
      "ok": true
     },
     {
      "id": "invoice_date",
      "label": "Invoice date",
      "stage": "model",
      "expected": "2026-11-24",
      "got": "2026-11-24",
      "ok": true
     },
     {
      "id": "po_number",
      "label": "PO number",
      "stage": "model",
      "expected": "PO-24071",
      "got": "PO-24071",
      "ok": true
     },
     {
      "id": "line_count",
      "label": "Line items",
      "stage": "model",
      "expected": 3,
      "got": 3,
      "ok": true
     },
     {
      "id": "subtotal",
      "label": "Subtotal",
      "stage": "model",
      "expected": 1064.94,
      "got": 1064.94,
      "ok": true
     },
     {
      "id": "tax",
      "label": "Tax",
      "stage": "model",
      "expected": 85.2,
      "got": 85.2,
      "ok": true
     },
     {
      "id": "total",
      "label": "Total",
      "stage": "model",
      "expected": 1150.14,
      "got": 1150.14,
      "ok": true
     },
     {
      "id": "account",
      "label": "Remit-to account",
      "stage": "model",
      "expected": "9900001180",
      "got": "9900001180",
      "ok": true
     },
     {
      "id": "model_route",
      "label": "Model's own route",
      "stage": "model",
      "expected": "return_to_vendor",
      "got": "return_to_vendor",
      "ok": true
     },
     {
      "id": "final_route",
      "label": "Route sent to the approver",
      "stage": "final",
      "expected": "return_to_vendor",
      "got": "return_to_vendor",
      "ok": true
     }
    ],
    "informational": [
     "model_route"
    ]
   }
  },
  {
   "id": "inv-f",
   "label": "Harlow Freight LLC HF-78140",
   "steps": [
    {
     "id": "read_pdf",
     "kind": "tool",
     "tool": "read_pdf_text",
     "ms": 12,
     "output": "INVOICE HF-78140\nHARLOW FREIGHT LLC\n(317) 555-0168\n5100 W Raymond Street · Indianapolis, IN 46241\nDATE  DUE  TERMS  YOUR PO\n11/25/2026  12/10/2026  Net 15  PO-24044\nCustomer  Remit payment to\nLarkfield Supply Co.  Circle City Example Bank\n2200 Mill Race Road  ABA routing: 999000133\nColumbus, OH 43215  Account no.: 9900002290\nITEM  QTY  PRICE  EXT.\nLTL freight, Columbus OH to Indianapolis IN, PRO 4471-208 (11/12)  1  735.00  735.00\nLTL freight, Columbus OH to Louisville KY, PRO 4471-311 (11/18)  1  812.50  812.50\nLTL freight, Columbus OH to Fort Wayne IN, PRO 4471-356 (11/21)  1  632.50  632.50\nSubtotal  2,180.00\nTax  0.00\nAmount due  2,180.00\nQuestions about this invoice: invoices@harlowfreight.example.com"
    },
    {
     "id": "extract",
     "kind": "model",
     "request": {
      "model": "qwen3.8-flash",
      "messages": [
       {
        "role": "system",
        "content": "You extract data from vendor invoices for an accounts payable team. Copy values exactly as printed. Don't correct arithmetic, don't fill in values that aren't printed, and don't guess. Answer with one JSON object and nothing else."
       },
       {
        "role": "user",
        "content": "Extract these fields from the invoice text below. The invoice was sent to Larkfield Supply Co.; the vendor is the company that issued it.\n\nReturn JSON with exactly these keys:\n{\n  \"vendor_name\": string,\n  \"invoice_number\": string, as printed,\n  \"invoice_date\": \"YYYY-MM-DD\",\n  \"due_date\": \"YYYY-MM-DD\" or null,\n  \"po_number\": string or null,\n  \"line_items\": [{\"description\": string, \"quantity\": number, \"unit_price\": number, \"amount\": number}],\n  \"subtotal\": number,\n  \"tax\": number,\n  \"total\": number,\n  \"remit_to\": {\"bank_name\": string or null, \"routing_number\": string or null, \"account_number\": string or null},\n  \"phone_numbers_on_invoice\": [string],\n  \"notices\": [string]\n}\nAmounts are plain numbers without currency symbols or commas, as printed (don't recompute them). \"notices\" holds any printed notice, stamp or request, word for word; [] if there is none.\n\nInvoice text (extracted from harlow-hf-78140.pdf):\n\"\"\"\nINVOICE HF-78140\nHARLOW FREIGHT LLC\n(317) 555-0168\n5100 W Raymond Street · Indianapolis, IN 46241\nDATE  DUE  TERMS  YOUR PO\n11/25/2026  12/10/2026  Net 15  PO-24044\nCustomer  Remit payment to\nLarkfield Supply Co.  Circle City Example Bank\n2200 Mill Race Road  ABA routing: 999000133\nColumbus, OH 43215  Account no.: 9900002290\nITEM  QTY  PRICE  EXT.\nLTL freight, Columbus OH to Indianapolis IN, PRO 4471-208 (11/12)  1  735.00  735.00\nLTL freight, Columbus OH to Louisville KY, PRO 4471-311 (11/18)  1  812.50  812.50\nLTL freight, Columbus OH to Fort Wayne IN, PRO 4471-356 (11/21)  1  632.50  632.50\nSubtotal  2,180.00\nTax  0.00\nAmount due  2,180.00\nQuestions about this invoice: invoices@harlowfreight.example.com\n\"\"\""
       }
      ],
      "temperature": 0.2,
      "max_tokens": 16384,
      "stream": false
     },
     "response": {
      "id": "chatcmpl-4b808955-d7bd-9bb3-8a1e-725006214885",
      "model": "qwen3.8-flash",
      "content": "{\n  \"vendor_name\": \"HARLOW FREIGHT LLC\",\n  \"invoice_number\": \"HF-78140\",\n  \"invoice_date\": \"2026-11-25\",\n  \"due_date\": \"2026-12-10\",\n  \"po_number\": \"PO-24044\",\n  \"line_items\": [\n    {\n      \"description\": \"LTL freight, Columbus OH to Indianapolis IN, PRO 4471-208 (11/12)\",\n      \"quantity\": 1,\n      \"unit_price\": 735.00,\n      \"amount\": 735.00\n    },\n    {\n      \"description\": \"LTL freight, Columbus OH to Louisville KY, PRO 4471-311 (11/18)\",\n      \"quantity\": 1,\n      \"unit_price\": 812.50,\n      \"amount\": 812.50\n    },\n    {\n      \"description\": \"LTL freight, Columbus OH to Fort Wayne IN, PRO 4471-356 (11/21)\",\n      \"quantity\": 1,\n      \"unit_price\": 632.50,\n      \"amount\": 632.50\n    }\n  ],\n  \"subtotal\": 2180.00,\n  \"tax\": 0.00,\n  \"total\": 2180.00,\n  \"remit_to\": {\n    \"bank_name\": \"Circle City Example Bank\",\n    \"routing_number\": \"999000133\",\n    \"account_number\": \"9900002290\"\n  },\n  \"phone_numbers_on_invoice\": [\n    \"(317) 555-0168\"\n  ],\n  \"notices\": [\n    \"Questions about this invoice: invoices@harlowfreight.example.com\"\n  ]\n}",
      "finishReason": "stop",
      "reasoningChars": 4339,
      "usage": {
       "prompt_tokens": 726,
       "total_tokens": 2767,
       "completion_tokens": 2041,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 726
       },
       "completion_tokens_details": {
        "reasoning_tokens": 1572,
        "text_tokens": 2041
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 12705,
     "attempts": [
      {
       "status": 200,
       "ms": 12705
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "vendor_name": "HARLOW FREIGHT LLC",
       "invoice_number": "HF-78140",
       "invoice_date": "2026-11-25",
       "due_date": "2026-12-10",
       "po_number": "PO-24044",
       "line_items": [
        {
         "description": "LTL freight, Columbus OH to Indianapolis IN, PRO 4471-208 (11/12)",
         "quantity": 1,
         "unit_price": 735,
         "amount": 735
        },
        {
         "description": "LTL freight, Columbus OH to Louisville KY, PRO 4471-311 (11/18)",
         "quantity": 1,
         "unit_price": 812.5,
         "amount": 812.5
        },
        {
         "description": "LTL freight, Columbus OH to Fort Wayne IN, PRO 4471-356 (11/21)",
         "quantity": 1,
         "unit_price": 632.5,
         "amount": 632.5
        }
       ],
       "subtotal": 2180,
       "tax": 0,
       "total": 2180,
       "remit_to": {
        "bank_name": "Circle City Example Bank",
        "routing_number": "999000133",
        "account_number": "9900002290"
       },
       "phone_numbers_on_invoice": [
        "(317) 555-0168"
       ],
       "notices": [
        "Questions about this invoice: invoices@harlowfreight.example.com"
       ]
      }
     }
    },
    {
     "id": "lookup",
     "kind": "tool",
     "tool": "lookup_records",
     "ms": 0,
     "output": {
      "vendor": {
       "id": "V-1002",
       "name": "Harlow Freight LLC",
       "phoneOnFile": "(317) 555-0168",
       "routing": "999000133",
       "account": "9900002290",
       "terms": "Net 15"
      },
      "po": {
       "po": "PO-24044",
       "vendorId": "V-1002",
       "description": "Blanket PO: LTL freight, Q4",
       "amount": 6000,
       "billedToDate": 4350,
       "remaining": 1650
      },
      "ledger": [
       {
        "vendorId": "V-1002",
        "invoiceNumber": "HF-77650",
        "invoiceDate": "2026-10-06",
        "total": 2900,
        "po": "PO-24044",
        "status": "paid 2026-10-21"
       },
       {
        "vendorId": "V-1002",
        "invoiceNumber": "HF-77812",
        "invoiceDate": "2026-11-03",
        "total": 1450,
        "po": "PO-24044",
        "status": "paid 2026-11-18"
       }
      ]
     }
    },
    {
     "id": "review",
     "kind": "model",
     "request": {
      "model": "qwen3.8-flash",
      "messages": [
       {
        "role": "system",
        "content": "You are an accounts payable reviewer at Larkfield Supply Co.. You recommend a route for one invoice under the AP policy. You can't pay, approve or contact anyone; a person decides after reading your recommendation. Answer with one JSON object and nothing else."
       },
       {
        "role": "user",
        "content": "AP policy:\n\"\"\"\nLarkfield Supply Co. accounts payable routing policy (rev. 2026-10)\n\nPick exactly one route. When more than one applies, use the first in this list.\n1. reject_duplicate: the AP ledger already has an invoice from the same vendor with the same invoice number (ignore spaces, hyphens and letter case).\n2. hold_verify_bank: the remit-to routing or account number differs from the vendor master, or the vendor is not in the vendor master. Verify only by calling the phone number in the vendor master, never a number printed on the invoice.\n3. hold_possible_duplicate: the AP ledger has an invoice from the same vendor, on the same PO, with the same total, dated within 45 days of this invoice, under a different number.\n4. return_to_vendor: the arithmetic doesn't hold (quantity x unit price differs from a line amount, line amounts don't add up to the subtotal, or subtotal + tax differs from the total), allowing 1 cent for rounding.\n5. hold_po_review: no PO number, the PO is not in the PO register, the PO belongs to another vendor, or the invoice total is more than the PO's remaining balance (PO amount minus billed to date).\n6. approve_controller: none of the above, and the total is more than $10,000.00.\n7. approve_ap: none of the above, and the total is $10,000.00 or less.\n\nNo route pays an invoice. Every route goes to a person, who approves before anything is paid, sent or recorded.\n\"\"\"\n\nInvoice data (extracted from the PDF by a previous step):\n{\n  \"vendor_name\": \"HARLOW FREIGHT LLC\",\n  \"invoice_number\": \"HF-78140\",\n  \"invoice_date\": \"2026-11-25\",\n  \"due_date\": \"2026-12-10\",\n  \"po_number\": \"PO-24044\",\n  \"line_items\": [\n    {\n      \"description\": \"LTL freight, Columbus OH to Indianapolis IN, PRO 4471-208 (11/12)\",\n      \"quantity\": 1,\n      \"unit_price\": 735,\n      \"amount\": 735\n    },\n    {\n      \"description\": \"LTL freight, Columbus OH to Louisville KY, PRO 4471-311 (11/18)\",\n      \"quantity\": 1,\n      \"unit_price\": 812.5,\n      \"amount\": 812.5\n    },\n    {\n      \"description\": \"LTL freight, Columbus OH to Fort Wayne IN, PRO 4471-356 (11/21)\",\n      \"quantity\": 1,\n      \"unit_price\": 632.5,\n      \"amount\": 632.5\n    }\n  ],\n  \"subtotal\": 2180,\n  \"tax\": 0,\n  \"total\": 2180,\n  \"remit_to\": {\n    \"bank_name\": \"Circle City Example Bank\",\n    \"routing_number\": \"999000133\",\n    \"account_number\": \"9900002290\"\n  },\n  \"phone_numbers_on_invoice\": [\n    \"(317) 555-0168\"\n  ],\n  \"notices\": [\n    \"Questions about this invoice: invoices@harlowfreight.example.com\"\n  ]\n}\n\nVendor master record for this vendor (null if there is no match):\n{\n  \"id\": \"V-1002\",\n  \"name\": \"Harlow Freight LLC\",\n  \"phoneOnFile\": \"(317) 555-0168\",\n  \"routing\": \"999000133\",\n  \"account\": \"9900002290\",\n  \"terms\": \"Net 15\"\n}\n\nPO register entry for the invoice's PO number (null if none). \"remaining\" is the amount minus billed to date:\n{\n  \"po\": \"PO-24044\",\n  \"vendorId\": \"V-1002\",\n  \"description\": \"Blanket PO: LTL freight, Q4\",\n  \"amount\": 6000,\n  \"billedToDate\": 4350,\n  \"remaining\": 1650\n}\n\nAP ledger entries already recorded for this vendor:\n[\n  {\n    \"vendorId\": \"V-1002\",\n    \"invoiceNumber\": \"HF-77650\",\n    \"invoiceDate\": \"2026-10-06\",\n    \"total\": 2900,\n    \"po\": \"PO-24044\",\n    \"status\": \"paid 2026-10-21\"\n  },\n  {\n    \"vendorId\": \"V-1002\",\n    \"invoiceNumber\": \"HF-77812\",\n    \"invoiceDate\": \"2026-11-03\",\n    \"total\": 1450,\n    \"po\": \"PO-24044\",\n    \"status\": \"paid 2026-11-18\"\n  }\n]\n\nCheck the invoice against the policy and the records. Return JSON:\n{\"route\": one of [\"reject_duplicate\",\"hold_verify_bank\",\"hold_possible_duplicate\",\"return_to_vendor\",\"hold_po_review\",\"approve_controller\",\"approve_ap\"], \"issues\": [one short string per problem you found; [] if none], \"note\": \"one or two sentences for the approver\"}"
       }
      ],
      "temperature": 0.2,
      "max_tokens": 16384,
      "stream": false
     },
     "response": {
      "id": "chatcmpl-7e413d7c-91bb-99db-ac9f-e2162111d01a",
      "model": "qwen3.8-flash",
      "content": "{\n  \"route\": \"hold_po_review\",\n  \"issues\": [\n    \"Invoice total $2,180.00 exceeds PO-24044 remaining balance $1,650.00 by $530.00.\"\n  ],\n  \"note\": \"No duplicate, bank, arithmetic, or vendor master issues found. Route to PO review to confirm whether the PO balance should be increased or the invoice should be split/authorized.\"\n}",
      "finishReason": "stop",
      "reasoningChars": 2977,
      "usage": {
       "prompt_tokens": 1420,
       "total_tokens": 2526,
       "completion_tokens": 1106,
       "prompt_tokens_details": {
        "cached_tokens": 1024,
        "text_tokens": 1420
       },
       "completion_tokens_details": {
        "reasoning_tokens": 998,
        "text_tokens": 1106
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 10292,
     "attempts": [
      {
       "status": 200,
       "ms": 10292
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "route": "hold_po_review",
       "issues": [
        "Invoice total $2,180.00 exceeds PO-24044 remaining balance $1,650.00 by $530.00."
       ],
       "note": "No duplicate, bank, arithmetic, or vendor master issues found. Route to PO review to confirm whether the PO balance should be increased or the invoice should be split/authorized."
      }
     }
    },
    {
     "id": "check_rules",
     "kind": "tool",
     "tool": "check_rules",
     "ms": 1,
     "output": {
      "flags": [
       {
        "code": "po_exceeded",
        "detail": "total $2,180.00 is more than the $1,650.00 left on PO-24044"
       }
      ],
      "policyRoute": "hold_po_review"
     }
    },
    {
     "id": "guardrail",
     "kind": "tool",
     "tool": "guardrail",
     "ms": 0,
     "output": {
      "finalRoute": "hold_po_review",
      "modelRoute": "hold_po_review",
      "policyRoute": "hold_po_review",
      "override": false,
      "reason": "model and coded policy agree"
     }
    },
    {
     "id": "approval",
     "kind": "checkpoint",
     "checkpoint": "ap_approval",
     "status": "pending",
     "note": "Run stopped for human approval; nothing after this step was executed.",
     "packet": {
      "invoice": "harlow-hf-78140.pdf",
      "vendor": "HARLOW FREIGHT LLC",
      "invoiceNumber": "HF-78140",
      "total": 2180,
      "route": "hold_po_review",
      "routeLabel": "Hold: PO review",
      "flags": [
       {
        "code": "po_exceeded",
        "detail": "total $2,180.00 is more than the $1,650.00 left on PO-24044"
       }
      ],
      "modelNote": "No duplicate, bank, arithmetic, or vendor master issues found. Route to PO review to confirm whether the PO balance should be increased or the invoice should be split/authorized.",
      "guardrail": "model and coded policy agree",
      "onApprove": "Open a review task for the buyer who owns the PO (sandbox task)"
     }
    }
   ],
   "failure": null,
   "unusable": [],
   "score": {
    "pass": true,
    "checks": [
     {
      "id": "invoice_number",
      "label": "Invoice number",
      "stage": "model",
      "expected": "HF-78140",
      "got": "HF-78140",
      "ok": true
     },
     {
      "id": "invoice_date",
      "label": "Invoice date",
      "stage": "model",
      "expected": "2026-11-25",
      "got": "2026-11-25",
      "ok": true
     },
     {
      "id": "po_number",
      "label": "PO number",
      "stage": "model",
      "expected": "PO-24044",
      "got": "PO-24044",
      "ok": true
     },
     {
      "id": "line_count",
      "label": "Line items",
      "stage": "model",
      "expected": 3,
      "got": 3,
      "ok": true
     },
     {
      "id": "subtotal",
      "label": "Subtotal",
      "stage": "model",
      "expected": 2180,
      "got": 2180,
      "ok": true
     },
     {
      "id": "tax",
      "label": "Tax",
      "stage": "model",
      "expected": 0,
      "got": 0,
      "ok": true
     },
     {
      "id": "total",
      "label": "Total",
      "stage": "model",
      "expected": 2180,
      "got": 2180,
      "ok": true
     },
     {
      "id": "account",
      "label": "Remit-to account",
      "stage": "model",
      "expected": "9900002290",
      "got": "9900002290",
      "ok": true
     },
     {
      "id": "model_route",
      "label": "Model's own route",
      "stage": "model",
      "expected": "hold_po_review",
      "got": "hold_po_review",
      "ok": true
     },
     {
      "id": "final_route",
      "label": "Route sent to the approver",
      "stage": "final",
      "expected": "hold_po_review",
      "got": "hold_po_review",
      "ok": true
     }
    ],
    "informational": [
     "model_route"
    ]
   }
  },
  {
   "id": "inv-g",
   "label": "Pinegate Office Supply 55190",
   "steps": [
    {
     "id": "read_pdf",
     "kind": "tool",
     "tool": "read_pdf_text",
     "ms": 13,
     "output": "Pinegate Office Supply\nINVOICE\n880 Euclid Avenue\nInvoice no.  55190\nCleveland, OH 44115\nInvoice date 11/12/2026\n(216) 555-0127 · ar@pinegate.example.com\nTerms  Net 30\nDue date 12/12/2026\nCustomer PO  PO-24060\nBILL TO  SHIP TO\nLarkfield Supply Co.  Larkfield Supply Co.\nAccounts Payable  Receiving, Dock 2\n2200 Mill Race Road  2200 Mill Race Road\nColumbus, OH 43215  Columbus, OH 43215\nap@larkfield.example.com\nDescription  Qty  Unit price  Amount\nErgonomic task chair, mesh back, black  2  249.00  498.00\nMonitor arm, single, clamp mount  1  69.00  69.00\nSubtotal  567.00\nSales tax 8.00%  45.36\nTotal due (USD)  $612.36\nRemit to: Lakeshore Example Bank · Routing (ABA) 999000199 · Account 9900001180 · Reference invoice 55190"
    },
    {
     "id": "extract",
     "kind": "model",
     "request": {
      "model": "qwen3.8-flash",
      "messages": [
       {
        "role": "system",
        "content": "You extract data from vendor invoices for an accounts payable team. Copy values exactly as printed. Don't correct arithmetic, don't fill in values that aren't printed, and don't guess. Answer with one JSON object and nothing else."
       },
       {
        "role": "user",
        "content": "Extract these fields from the invoice text below. The invoice was sent to Larkfield Supply Co.; the vendor is the company that issued it.\n\nReturn JSON with exactly these keys:\n{\n  \"vendor_name\": string,\n  \"invoice_number\": string, as printed,\n  \"invoice_date\": \"YYYY-MM-DD\",\n  \"due_date\": \"YYYY-MM-DD\" or null,\n  \"po_number\": string or null,\n  \"line_items\": [{\"description\": string, \"quantity\": number, \"unit_price\": number, \"amount\": number}],\n  \"subtotal\": number,\n  \"tax\": number,\n  \"total\": number,\n  \"remit_to\": {\"bank_name\": string or null, \"routing_number\": string or null, \"account_number\": string or null},\n  \"phone_numbers_on_invoice\": [string],\n  \"notices\": [string]\n}\nAmounts are plain numbers without currency symbols or commas, as printed (don't recompute them). \"notices\" holds any printed notice, stamp or request, word for word; [] if there is none.\n\nInvoice text (extracted from pinegate-55190.pdf):\n\"\"\"\nPinegate Office Supply\nINVOICE\n880 Euclid Avenue\nInvoice no.  55190\nCleveland, OH 44115\nInvoice date 11/12/2026\n(216) 555-0127 · ar@pinegate.example.com\nTerms  Net 30\nDue date 12/12/2026\nCustomer PO  PO-24060\nBILL TO  SHIP TO\nLarkfield Supply Co.  Larkfield Supply Co.\nAccounts Payable  Receiving, Dock 2\n2200 Mill Race Road  2200 Mill Race Road\nColumbus, OH 43215  Columbus, OH 43215\nap@larkfield.example.com\nDescription  Qty  Unit price  Amount\nErgonomic task chair, mesh back, black  2  249.00  498.00\nMonitor arm, single, clamp mount  1  69.00  69.00\nSubtotal  567.00\nSales tax 8.00%  45.36\nTotal due (USD)  $612.36\nRemit to: Lakeshore Example Bank · Routing (ABA) 999000199 · Account 9900001180 · Reference invoice 55190\n\"\"\""
       }
      ],
      "temperature": 0.2,
      "max_tokens": 16384,
      "stream": false
     },
     "response": {
      "id": "chatcmpl-0c2e6ca7-8ee9-9460-92fa-3e13c5e99ed3",
      "model": "qwen3.8-flash",
      "content": "{\n  \"vendor_name\": \"Pinegate Office Supply\",\n  \"invoice_number\": \"55190\",\n  \"invoice_date\": \"2026-11-12\",\n  \"due_date\": \"2026-12-12\",\n  \"po_number\": \"PO-24060\",\n  \"line_items\": [\n    {\n      \"description\": \"Ergonomic task chair, mesh back, black\",\n      \"quantity\": 2,\n      \"unit_price\": 249.00,\n      \"amount\": 498.00\n    },\n    {\n      \"description\": \"Monitor arm, single, clamp mount\",\n      \"quantity\": 1,\n      \"unit_price\": 69.00,\n      \"amount\": 69.00\n    }\n  ],\n  \"subtotal\": 567.00,\n  \"tax\": 45.36,\n  \"total\": 612.36,\n  \"remit_to\": {\n    \"bank_name\": \"Lakeshore Example Bank\",\n    \"routing_number\": \"999000199\",\n    \"account_number\": \"9900001180\"\n  },\n  \"phone_numbers_on_invoice\": [\n    \"(216) 555-0127\"\n  ],\n  \"notices\": []\n}",
      "finishReason": "stop",
      "reasoningChars": 10458,
      "usage": {
       "prompt_tokens": 696,
       "total_tokens": 4103,
       "completion_tokens": 3407,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 696
       },
       "completion_tokens_details": {
        "reasoning_tokens": 3071,
        "text_tokens": 3407
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 27162,
     "attempts": [
      {
       "status": 200,
       "ms": 27162
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "vendor_name": "Pinegate Office Supply",
       "invoice_number": "55190",
       "invoice_date": "2026-11-12",
       "due_date": "2026-12-12",
       "po_number": "PO-24060",
       "line_items": [
        {
         "description": "Ergonomic task chair, mesh back, black",
         "quantity": 2,
         "unit_price": 249,
         "amount": 498
        },
        {
         "description": "Monitor arm, single, clamp mount",
         "quantity": 1,
         "unit_price": 69,
         "amount": 69
        }
       ],
       "subtotal": 567,
       "tax": 45.36,
       "total": 612.36,
       "remit_to": {
        "bank_name": "Lakeshore Example Bank",
        "routing_number": "999000199",
        "account_number": "9900001180"
       },
       "phone_numbers_on_invoice": [
        "(216) 555-0127"
       ],
       "notices": []
      }
     }
    },
    {
     "id": "lookup",
     "kind": "tool",
     "tool": "lookup_records",
     "ms": 0,
     "output": {
      "vendor": {
       "id": "V-1005",
       "name": "Pinegate Office Supply",
       "phoneOnFile": "(216) 555-0127",
       "routing": "999000199",
       "account": "9900001180",
       "terms": "Net 30"
      },
      "po": {
       "po": "PO-24060",
       "vendorId": "V-1005",
       "description": "Office furniture, receiving desk",
       "amount": 612.36,
       "billedToDate": 612.36,
       "remaining": 0
      },
      "ledger": [
       {
        "vendorId": "V-1005",
        "invoiceNumber": "55120",
        "invoiceDate": "2026-11-10",
        "total": 612.36,
        "po": "PO-24060",
        "status": "approved, in the 2026-12-10 payment run"
       }
      ]
     }
    },
    {
     "id": "review",
     "kind": "model",
     "request": {
      "model": "qwen3.8-flash",
      "messages": [
       {
        "role": "system",
        "content": "You are an accounts payable reviewer at Larkfield Supply Co.. You recommend a route for one invoice under the AP policy. You can't pay, approve or contact anyone; a person decides after reading your recommendation. Answer with one JSON object and nothing else."
       },
       {
        "role": "user",
        "content": "AP policy:\n\"\"\"\nLarkfield Supply Co. accounts payable routing policy (rev. 2026-10)\n\nPick exactly one route. When more than one applies, use the first in this list.\n1. reject_duplicate: the AP ledger already has an invoice from the same vendor with the same invoice number (ignore spaces, hyphens and letter case).\n2. hold_verify_bank: the remit-to routing or account number differs from the vendor master, or the vendor is not in the vendor master. Verify only by calling the phone number in the vendor master, never a number printed on the invoice.\n3. hold_possible_duplicate: the AP ledger has an invoice from the same vendor, on the same PO, with the same total, dated within 45 days of this invoice, under a different number.\n4. return_to_vendor: the arithmetic doesn't hold (quantity x unit price differs from a line amount, line amounts don't add up to the subtotal, or subtotal + tax differs from the total), allowing 1 cent for rounding.\n5. hold_po_review: no PO number, the PO is not in the PO register, the PO belongs to another vendor, or the invoice total is more than the PO's remaining balance (PO amount minus billed to date).\n6. approve_controller: none of the above, and the total is more than $10,000.00.\n7. approve_ap: none of the above, and the total is $10,000.00 or less.\n\nNo route pays an invoice. Every route goes to a person, who approves before anything is paid, sent or recorded.\n\"\"\"\n\nInvoice data (extracted from the PDF by a previous step):\n{\n  \"vendor_name\": \"Pinegate Office Supply\",\n  \"invoice_number\": \"55190\",\n  \"invoice_date\": \"2026-11-12\",\n  \"due_date\": \"2026-12-12\",\n  \"po_number\": \"PO-24060\",\n  \"line_items\": [\n    {\n      \"description\": \"Ergonomic task chair, mesh back, black\",\n      \"quantity\": 2,\n      \"unit_price\": 249,\n      \"amount\": 498\n    },\n    {\n      \"description\": \"Monitor arm, single, clamp mount\",\n      \"quantity\": 1,\n      \"unit_price\": 69,\n      \"amount\": 69\n    }\n  ],\n  \"subtotal\": 567,\n  \"tax\": 45.36,\n  \"total\": 612.36,\n  \"remit_to\": {\n    \"bank_name\": \"Lakeshore Example Bank\",\n    \"routing_number\": \"999000199\",\n    \"account_number\": \"9900001180\"\n  },\n  \"phone_numbers_on_invoice\": [\n    \"(216) 555-0127\"\n  ],\n  \"notices\": []\n}\n\nVendor master record for this vendor (null if there is no match):\n{\n  \"id\": \"V-1005\",\n  \"name\": \"Pinegate Office Supply\",\n  \"phoneOnFile\": \"(216) 555-0127\",\n  \"routing\": \"999000199\",\n  \"account\": \"9900001180\",\n  \"terms\": \"Net 30\"\n}\n\nPO register entry for the invoice's PO number (null if none). \"remaining\" is the amount minus billed to date:\n{\n  \"po\": \"PO-24060\",\n  \"vendorId\": \"V-1005\",\n  \"description\": \"Office furniture, receiving desk\",\n  \"amount\": 612.36,\n  \"billedToDate\": 612.36,\n  \"remaining\": 0\n}\n\nAP ledger entries already recorded for this vendor:\n[\n  {\n    \"vendorId\": \"V-1005\",\n    \"invoiceNumber\": \"55120\",\n    \"invoiceDate\": \"2026-11-10\",\n    \"total\": 612.36,\n    \"po\": \"PO-24060\",\n    \"status\": \"approved, in the 2026-12-10 payment run\"\n  }\n]\n\nCheck the invoice against the policy and the records. Return JSON:\n{\"route\": one of [\"reject_duplicate\",\"hold_verify_bank\",\"hold_possible_duplicate\",\"return_to_vendor\",\"hold_po_review\",\"approve_controller\",\"approve_ap\"], \"issues\": [one short string per problem you found; [] if none], \"note\": \"one or two sentences for the approver\"}"
       }
      ],
      "temperature": 0.2,
      "max_tokens": 16384,
      "stream": false
     },
     "response": {
      "id": "chatcmpl-1aded39f-bf39-90f5-ba78-0e4db7417707",
      "model": "qwen3.8-flash",
      "content": "{\"route\":\"hold_possible_duplicate\",\"issues\":[\"Possible duplicate: same vendor, PO, and total within 45 days under a different invoice number\",\"PO overbalance: invoice total exceeds PO remaining balance of $0\"],\"note\":\"Recommend hold for duplicate review because the AP ledger already has an approved invoice for the same vendor, PO, and total dated 2026-11-10. The PO also shows no remaining balance, so confirm whether this is a second billing or a correction.\"}",
      "finishReason": "stop",
      "reasoningChars": 3695,
      "usage": {
       "prompt_tokens": 1196,
       "total_tokens": 2233,
       "completion_tokens": 1037,
       "prompt_tokens_details": {
        "cached_tokens": 1024,
        "text_tokens": 1196
       },
       "completion_tokens_details": {
        "reasoning_tokens": 931,
        "text_tokens": 1037
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 11222,
     "attempts": [
      {
       "status": 200,
       "ms": 11222
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "route": "hold_possible_duplicate",
       "issues": [
        "Possible duplicate: same vendor, PO, and total within 45 days under a different invoice number",
        "PO overbalance: invoice total exceeds PO remaining balance of $0"
       ],
       "note": "Recommend hold for duplicate review because the AP ledger already has an approved invoice for the same vendor, PO, and total dated 2026-11-10. The PO also shows no remaining balance, so confirm whether this is a second billing or a correction."
      }
     }
    },
    {
     "id": "check_rules",
     "kind": "tool",
     "tool": "check_rules",
     "ms": 1,
     "output": {
      "flags": [
       {
        "code": "possible_duplicate",
        "detail": "55120 (2026-11-10) has the same total, $612.36, on the same PO"
       },
       {
        "code": "po_exceeded",
        "detail": "total $612.36 is more than the $0.00 left on PO-24060"
       }
      ],
      "policyRoute": "hold_possible_duplicate"
     }
    },
    {
     "id": "guardrail",
     "kind": "tool",
     "tool": "guardrail",
     "ms": 0,
     "output": {
      "finalRoute": "hold_possible_duplicate",
      "modelRoute": "hold_possible_duplicate",
      "policyRoute": "hold_possible_duplicate",
      "override": false,
      "reason": "model and coded policy agree"
     }
    },
    {
     "id": "approval",
     "kind": "checkpoint",
     "checkpoint": "ap_approval",
     "status": "pending",
     "note": "Run stopped for human approval; nothing after this step was executed.",
     "packet": {
      "invoice": "pinegate-55190.pdf",
      "vendor": "Pinegate Office Supply",
      "invoiceNumber": "55190",
      "total": 612.36,
      "route": "hold_possible_duplicate",
      "routeLabel": "Hold: possible duplicate",
      "flags": [
       {
        "code": "possible_duplicate",
        "detail": "55120 (2026-11-10) has the same total, $612.36, on the same PO"
       },
       {
        "code": "po_exceeded",
        "detail": "total $612.36 is more than the $0.00 left on PO-24060"
       }
      ],
      "modelNote": "Recommend hold for duplicate review because the AP ledger already has an approved invoice for the same vendor, PO, and total dated 2026-11-10. The PO also shows no remaining balance, so confirm whether this is a second billing or a correction.",
      "guardrail": "model and coded policy agree",
      "onApprove": "Open a duplicate check task for AP (sandbox task)"
     }
    }
   ],
   "failure": null,
   "unusable": [],
   "score": {
    "pass": true,
    "checks": [
     {
      "id": "invoice_number",
      "label": "Invoice number",
      "stage": "model",
      "expected": "55190",
      "got": "55190",
      "ok": true
     },
     {
      "id": "invoice_date",
      "label": "Invoice date",
      "stage": "model",
      "expected": "2026-11-12",
      "got": "2026-11-12",
      "ok": true
     },
     {
      "id": "po_number",
      "label": "PO number",
      "stage": "model",
      "expected": "PO-24060",
      "got": "PO-24060",
      "ok": true
     },
     {
      "id": "line_count",
      "label": "Line items",
      "stage": "model",
      "expected": 2,
      "got": 2,
      "ok": true
     },
     {
      "id": "subtotal",
      "label": "Subtotal",
      "stage": "model",
      "expected": 567,
      "got": 567,
      "ok": true
     },
     {
      "id": "tax",
      "label": "Tax",
      "stage": "model",
      "expected": 45.36,
      "got": 45.36,
      "ok": true
     },
     {
      "id": "total",
      "label": "Total",
      "stage": "model",
      "expected": 612.36,
      "got": 612.36,
      "ok": true
     },
     {
      "id": "account",
      "label": "Remit-to account",
      "stage": "model",
      "expected": "9900001180",
      "got": "9900001180",
      "ok": true
     },
     {
      "id": "model_route",
      "label": "Model's own route",
      "stage": "model",
      "expected": "hold_possible_duplicate",
      "got": "hold_possible_duplicate",
      "ok": true
     },
     {
      "id": "final_route",
      "label": "Route sent to the approver",
      "stage": "final",
      "expected": "hold_possible_duplicate",
      "got": "hold_possible_duplicate",
      "ok": true
     }
    ],
    "informational": [
     "model_route"
    ]
   }
  }
 ]
}
