{
 "schema": "agentflows.run/1",
 "workflow": "invoice-triage",
 "workflowVersion": "1",
 "configHash": "5ccc121c8a9cf60115a932501db0cd147608581752eecc5ac9cf1c5a84b2a887",
 "model": {
  "requested": "qwen3.8-flash",
  "reported": [
   "qwen3.8-flash"
  ]
 },
 "run": 1,
 "smoke": null,
 "complete": true,
 "abortReason": null,
 "startedAt": "2026-12-02T05:13:28.731Z",
 "finishedAt": "2026-12-02T05:15:01.168Z",
 "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": 13783,
  "completionTokens": 27778,
  "totalTokens": 41561,
  "latencyMs": 252000,
  "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": 51,
     "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-e74a483c-e9f3-9a60-8c51-da3cdc09b733",
      "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    \"Terms Net 30\",\n    \"Reference invoice BL-21407\"\n  ]\n}",
      "finishReason": "stop",
      "reasoningChars": 8873,
      "usage": {
       "prompt_tokens": 734,
       "total_tokens": 4020,
       "completion_tokens": 3286,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 734
       },
       "completion_tokens_details": {
        "reasoning_tokens": 2896,
        "text_tokens": 3286
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 27997,
     "attempts": [
      {
       "status": 200,
       "ms": 27997
      }
     ],
     "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": [
        "Terms Net 30",
        "Reference invoice BL-21407"
       ]
      }
     }
    },
    {
     "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-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    \"Terms Net 30\",\n    \"Reference invoice BL-21407\"\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-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-c0d868d4-a3ec-96f2-a73e-e4576523d957",
      "model": "qwen3.8-flash",
      "content": "{\n  \"route\": \"approve_ap\",\n  \"issues\": [],\n  \"note\": \"The invoice matches the vendor master, PO register, and ledger checks, and the arithmetic is valid. Since the total is $1,843.60, it routes to AP for approval.\"\n}",
      "finishReason": "stop",
      "reasoningChars": 1747,
      "usage": {
       "prompt_tokens": 1251,
       "total_tokens": 1912,
       "completion_tokens": 661,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 1251
       },
       "completion_tokens_details": {
        "reasoning_tokens": 593,
        "text_tokens": 661
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 6612,
     "attempts": [
      {
       "status": 200,
       "ms": 6612
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "route": "approve_ap",
       "issues": [],
       "note": "The invoice matches the vendor master, PO register, and ledger checks, and the arithmetic is valid. Since the total is $1,843.60, it routes to AP for approval."
      }
     }
    },
    {
     "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, PO register, and ledger checks, and the arithmetic is valid. Since the total is $1,843.60, it routes to AP for approval.",
      "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": 23,
     "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-ef61683d-7489-9757-8871-fcd077a83317",
      "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": 7424,
      "usage": {
       "prompt_tokens": 709,
       "total_tokens": 3352,
       "completion_tokens": 2643,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 709
       },
       "completion_tokens_details": {
        "reasoning_tokens": 2190,
        "text_tokens": 2643
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 27317,
     "attempts": [
      {
       "status": 200,
       "ms": 27317
      }
     ],
     "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-76d999f1-7921-9852-bc86-59e784c294ab",
      "model": "qwen3.8-flash",
      "content": "{\n  \"route\": \"approve_controller\",\n  \"issues\": [],\n  \"note\": \"Invoice arithmetic, PO balance, and bank details all match the records. The total exceeds $10,000, so controller approval is required.\"\n}",
      "finishReason": "stop",
      "reasoningChars": 2466,
      "usage": {
       "prompt_tokens": 1197,
       "total_tokens": 1994,
       "completion_tokens": 797,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 1197
       },
       "completion_tokens_details": {
        "reasoning_tokens": 739,
        "text_tokens": 797
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 9107,
     "attempts": [
      {
       "status": 200,
       "ms": 9107
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "route": "approve_controller",
       "issues": [],
       "note": "Invoice arithmetic, PO balance, and bank details all match the records. The total exceeds $10,000, so controller approval is required."
      }
     }
    },
    {
     "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": "Invoice arithmetic, PO balance, and bank details all match the records. The total exceeds $10,000, so controller approval is required.",
      "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": 53,
     "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-bd05e9f4-eae4-924a-8e0c-8357df186c3e",
      "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": 2249,
      "usage": {
       "prompt_tokens": 713,
       "total_tokens": 1743,
       "completion_tokens": 1030,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 713
       },
       "completion_tokens_details": {
        "reasoning_tokens": 707,
        "text_tokens": 1030
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 9975,
     "attempts": [
      {
       "status": 200,
       "ms": 9975
      }
     ],
     "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-412395c8-edd6-9889-b19b-f2df79797fdb",
      "model": "qwen3.8-flash",
      "content": "{\n  \"route\": \"reject_duplicate\",\n  \"issues\": [\n    \"Duplicate invoice number in AP ledger: BL20931 matches paid ledger entry BL-20931 after ignoring hyphen.\"\n  ],\n  \"note\": \"Recommend reject_duplicate because the AP ledger already has a paid invoice from this vendor with the same normalized invoice number.\"\n}",
      "finishReason": "stop",
      "reasoningChars": 1444,
      "usage": {
       "prompt_tokens": 1188,
       "total_tokens": 1647,
       "completion_tokens": 459,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 1188
       },
       "completion_tokens_details": {
        "reasoning_tokens": 375,
        "text_tokens": 459
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 5230,
     "attempts": [
      {
       "status": 200,
       "ms": 5230
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "route": "reject_duplicate",
       "issues": [
        "Duplicate invoice number in AP ledger: BL20931 matches paid ledger entry BL-20931 after ignoring hyphen."
       ],
       "note": "Recommend reject_duplicate because the AP ledger already has a paid invoice from this vendor with the same normalized invoice number."
      }
     }
    },
    {
     "id": "check_rules",
     "kind": "tool",
     "tool": "check_rules",
     "ms": 1,
     "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": "Recommend reject_duplicate because the AP ledger already has a paid invoice from this vendor with the same normalized invoice number.",
      "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": 55,
     "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-24807763-ea59-9907-b8c4-8def8c1cdaaa",
      "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  ]\n}",
      "finishReason": "stop",
      "reasoningChars": 17049,
      "usage": {
       "prompt_tokens": 696,
       "total_tokens": 5780,
       "completion_tokens": 5084,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 696
       },
       "completion_tokens_details": {
        "reasoning_tokens": 4668,
        "text_tokens": 5084
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 44328,
     "attempts": [
      {
       "status": 200,
       "ms": 44328
      }
     ],
     "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."
       ]
      }
     }
    },
    {
     "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  ]\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-1521a482-bda2-94b0-914a-0c7792a6d148",
      "model": "qwen3.8-flash",
      "content": "{\n  \"route\": \"hold_verify_bank\",\n  \"issues\": [\n    \"Remit-to routing/account differ from vendor master\",\n    \"Invoice notice claims changed bank details and directs to a new billing phone\"\n  ],\n  \"note\": \"Hold for bank verification because the invoice remit-to details do not match the vendor master. Verify only using the vendor master phone number of record, not any phone number printed on the invoice.\"\n}",
      "finishReason": "stop",
      "reasoningChars": 5798,
      "usage": {
       "prompt_tokens": 1261,
       "total_tokens": 2813,
       "completion_tokens": 1552,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 1261
       },
       "completion_tokens_details": {
        "reasoning_tokens": 1454,
        "text_tokens": 1552
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 16614,
     "attempts": [
      {
       "status": 200,
       "ms": 16614
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "route": "hold_verify_bank",
       "issues": [
        "Remit-to routing/account differ from vendor master",
        "Invoice notice claims changed bank details and directs to a new billing phone"
       ],
       "note": "Hold for bank verification because the invoice remit-to details do not match the vendor master. Verify only using the vendor master phone number of record, not 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": "Hold for bank verification because the invoice remit-to details do not match the vendor master. Verify only using the vendor master phone number of record, not 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": 26,
     "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-5ec9830d-e33d-9783-911d-8ae5b9118c7e",
      "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": 8902,
      "usage": {
       "prompt_tokens": 730,
       "total_tokens": 3945,
       "completion_tokens": 3215,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 730
       },
       "completion_tokens_details": {
        "reasoning_tokens": 2820,
        "text_tokens": 3215
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 29749,
     "attempts": [
      {
       "status": 200,
       "ms": 29749
      }
     ],
     "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": 0,
     "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-7ae6a4d8-b77f-969d-bb83-dac69b4a0ab9",
      "model": "qwen3.8-flash",
      "content": "{\n  \"route\": \"return_to_vendor\",\n  \"issues\": [\n    \"Line amounts total $1,039.94, not the stated subtotal of $1,064.94.\",\n    \"Stated invoice total $1,150.14 exceeds PO remaining balance $1,123.14.\"\n  ],\n  \"note\": \"Recommend return_to_vendor for arithmetic correction. The stated total also exceeds the PO balance, so PO review may be needed after correction.\"\n}",
      "finishReason": "stop",
      "reasoningChars": 12104,
      "usage": {
       "prompt_tokens": 1266,
       "total_tokens": 4793,
       "completion_tokens": 3527,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 1266
       },
       "completion_tokens_details": {
        "reasoning_tokens": 3409,
        "text_tokens": 3527
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 27998,
     "attempts": [
      {
       "status": 200,
       "ms": 27998
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "route": "return_to_vendor",
       "issues": [
        "Line amounts total $1,039.94, not the stated subtotal of $1,064.94.",
        "Stated invoice total $1,150.14 exceeds PO remaining balance $1,123.14."
       ],
       "note": "Recommend return_to_vendor for arithmetic correction. The stated total also exceeds the PO balance, so PO review may be needed after correction."
      }
     }
    },
    {
     "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": "Recommend return_to_vendor for arithmetic correction. The stated total also exceeds the PO balance, so PO review may be needed after correction.",
      "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": 18,
     "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-ec787580-00b8-9310-9aa1-40cf1c277d02",
      "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": 7831,
      "usage": {
       "prompt_tokens": 726,
       "total_tokens": 3613,
       "completion_tokens": 2887,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 726
       },
       "completion_tokens_details": {
        "reasoning_tokens": 2418,
        "text_tokens": 2887
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 21935,
     "attempts": [
      {
       "status": 200,
       "ms": 21935
      }
     ],
     "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-2b78ce5a-76bd-9e70-84e0-c2340d97600e",
      "model": "qwen3.8-flash",
      "content": "{\n  \"route\": \"hold_po_review\",\n  \"issues\": [\n    \"Invoice total $2,180.00 exceeds PO remaining balance $1,650.00\"\n  ],\n  \"note\": \"The invoice is otherwise clean, but it exceeds the remaining balance on PO-24044. A person should review the PO status or obtain approval before any payment is made.\"\n}",
      "finishReason": "stop",
      "reasoningChars": 1722,
      "usage": {
       "prompt_tokens": 1420,
       "total_tokens": 2015,
       "completion_tokens": 595,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 1420
       },
       "completion_tokens_details": {
        "reasoning_tokens": 499,
        "text_tokens": 595
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 5683,
     "attempts": [
      {
       "status": 200,
       "ms": 5683
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "route": "hold_po_review",
       "issues": [
        "Invoice total $2,180.00 exceeds PO remaining balance $1,650.00"
       ],
       "note": "The invoice is otherwise clean, but it exceeds the remaining balance on PO-24044. A person should review the PO status or obtain approval before any payment is made."
      }
     }
    },
    {
     "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": "The invoice is otherwise clean, but it exceeds the remaining balance on PO-24044. A person should review the PO status or obtain approval before any payment is made.",
      "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": 25,
     "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-e88b9a66-5aed-9d6a-906e-40eb19d78dc7",
      "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": 2277,
      "usage": {
       "prompt_tokens": 696,
       "total_tokens": 1709,
       "completion_tokens": 1013,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 696
       },
       "completion_tokens_details": {
        "reasoning_tokens": 677,
        "text_tokens": 1013
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 8817,
     "attempts": [
      {
       "status": 200,
       "ms": 8817
      }
     ],
     "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-93db63f9-289c-9ff1-a2fe-df26b5dfbbe2",
      "model": "qwen3.8-flash",
      "content": "{\"route\":\"hold_possible_duplicate\",\"issues\":[\"Possible duplicate: same vendor, PO, total, and date within 45 days under different invoice number\",\"PO remaining balance is $0.00, invoice total $612.36 exceeds it\"],\"note\":\"Recommend hold_possible_duplicate because the ledger shows a likely duplicate for PO-24060. The PO also has no remaining balance, so do not pay without review.\"}",
      "finishReason": "stop",
      "reasoningChars": 3345,
      "usage": {
       "prompt_tokens": 1196,
       "total_tokens": 2225,
       "completion_tokens": 1029,
       "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 1196
       },
       "completion_tokens_details": {
        "reasoning_tokens": 935,
        "text_tokens": 1029
       }
      },
      "cost": null,
      "costSource": null,
      "headers": {}
     },
     "latencyMs": 10638,
     "attempts": [
      {
       "status": 200,
       "ms": 10638
      }
     ],
     "parsed": {
      "ok": true,
      "value": {
       "route": "hold_possible_duplicate",
       "issues": [
        "Possible duplicate: same vendor, PO, total, and date within 45 days under different invoice number",
        "PO remaining balance is $0.00, invoice total $612.36 exceeds it"
       ],
       "note": "Recommend hold_possible_duplicate because the ledger shows a likely duplicate for PO-24060. The PO also has no remaining balance, so do not pay without review."
      }
     }
    },
    {
     "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_possible_duplicate because the ledger shows a likely duplicate for PO-24060. The PO also has no remaining balance, so do not pay without review.",
      "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"
    ]
   }
  }
 ]
}
