{
  "schema": "agentflows.config/1",
  "id": "expense-report-review",
  "version": "1",
  "title": "Expense report review",
  "short": "Read each expense line and receipt, apply the travel policy, and hand the manager a report with every problem flagged.",
  "owner": "Finance",
  "items": [
    "ER-3107",
    "ER-3112",
    "ER-3120"
  ],
  "steps": [
    {
      "kind": "tool",
      "id": "load_report",
      "title": "Load the report",
      "tool": "load_report"
    },
    {
      "kind": "model",
      "id": "review_lines",
      "title": "Read receipts, categorize, flag",
      "system": "You review employee expense reports for a finance team against the company policy. You read each line and its receipt, categorize it, report the facts printed on the receipt and flag policy problems. You can't approve, reject or pay anything; a manager decides. Answer with one JSON object and nothing else.",
      "user": "Expense policy:\n\"\"\"\n{{policy}}\n\"\"\"\n\nReport {{report_id}}: {{employee}}, {{department}}\nTrip: {{trip}}\nLines (receipt is null when none was attached):\n{{lines}}\n\nFor every line, return its category, the policy flags that apply to it, and these facts when the receipt shows them (otherwise null): room_rate (nightly room rate before tax, lodging only), city (lodging only), pretax (bill before tax and tip, meals only), tip (meals only).\n\nReturn JSON:\n{\"lines\": [{\"line_id\": string, \"category\": one of {{categories}}, \"flags\": [zero or more of {{flags}}], \"room_rate\": number|null, \"city\": string|null, \"pretax\": number|null, \"tip\": number|null, \"note\": \"short reason, or empty\"}]}",
      "maxTokens": 16384,
      "optional": false
    },
    {
      "kind": "tool",
      "id": "policy_checks",
      "title": "Apply the arithmetic rules in code",
      "tool": "policy_checks"
    },
    {
      "kind": "checkpoint",
      "id": "manager_approval",
      "title": "Manager approval",
      "checkpoint": "manager_approval"
    }
  ],
  "tools": [
    {
      "name": "load_report",
      "does": "Reads one expense report with its receipt text.",
      "access": "read",
      "data": "3 sample reports",
      "production": "Read access to submitted reports in the expense tool; no access to card statements or payroll."
    },
    {
      "name": "policy_checks",
      "does": "Computes receipt, meal-cap, room-rate, mileage, tip and duplicate flags from amounts and the model's facts.",
      "access": "compute",
      "data": "The report + the model's facts",
      "production": "Runs inside the workflow."
    },
    {
      "name": "queue_decision",
      "does": "After the manager decides, records approve or return per report in a local list.",
      "access": "sandbox-write",
      "data": "In-memory list",
      "production": "Sets the report's status. Reimbursement runs through payroll as usual."
    }
  ],
  "permissions": [
    {
      "resource": "Expense reports and receipt text",
      "grant": "read",
      "why": "Needed to review lines."
    },
    {
      "resource": "Report status (approve, return)",
      "grant": "write after approval",
      "why": "The manager decides; the workflow only prepares the review."
    },
    {
      "resource": "Payroll or reimbursement payments",
      "grant": "none",
      "why": "Nothing in the workflow can pay an employee."
    },
    {
      "resource": "Employee HR record",
      "grant": "none",
      "why": "Not needed to apply the policy."
    }
  ],
  "checkpoints": [
    {
      "id": "manager_approval",
      "reviewer": "The employee's manager",
      "sees": [
        "Each line with its receipt",
        "Flags, and whether code or the model raised each one",
        "The policy rule behind each flag"
      ],
      "onApprove": "The report is approved with the flagged lines removed or explained.",
      "onReject": "The report goes back to the employee with the flags as comments."
    }
  ],
  "runner": {
    "temperature": 0.2
  },
  "fixtures": {
    "policy": "Larkfield Supply Co. travel and expense policy (rev. 2026-07)\n\n1. receipt_missing: any expense of $25.00 or more needs an itemized receipt. Mileage needs no receipt.\n2. meal_over_cap: meals the employee eats alone are capped at $75.00 per day, all of that day's meals combined, tax and tip included. When a day goes over, every solo meal line on that day is flagged. Client meals are exempt when the attendees and the business purpose are listed.\n3. alcohol: alcohol is not reimbursable, except at a client meal with attendees and business purpose listed.\n4. lodging_over_cap: the nightly room rate, before taxes and fees, may not exceed $325 in New York City, $250 in Chicago and $200 anywhere else.\n5. personal_item: in-room movies, minibar, spa charges, and laundry on trips shorter than 5 nights are personal and not reimbursable.\n6. mileage_rate: personal car mileage is paid at $0.70 per mile; the amount claimed must equal miles x $0.70.\n7. tip_over_cap: tips above 20% of the pre-tax bill are not reimbursable.\n8. duplicate_line: the same merchant, date and amount claimed twice in one report; flag the second line.",
    "reports": [
      {
        "id": "ER-3107",
        "employee": "Alex Moreno",
        "department": "Sales",
        "trip": "New York City client visit, Nov 16 to 18, 2026 (2 nights)",
        "lines": [
          {
            "id": "1",
            "date": "2026-11-16",
            "merchant": "Skyharbor Air",
            "description": "Airfare CMH-LGA round trip",
            "amount": 412.8,
            "receipt": "SKYHARBOR AIR e-ticket receipt\nPassenger: ALEX MORENO\nCMH-LGA 16NOV  LGA-CMH 18NOV  Economy\nFare 352.00\nTaxes and fees 60.80\nTotal USD 412.80"
          },
          {
            "id": "2",
            "date": "2026-11-16",
            "merchant": "NYC yellow cab",
            "description": "Taxi LGA to hotel",
            "amount": 38,
            "receipt": null
          },
          {
            "id": "3",
            "date": "2026-11-18",
            "merchant": "The Corliss Hotel",
            "description": "Hotel, 2 nights",
            "amount": 910.75,
            "receipt": "THE CORLISS HOTEL  New York, NY\nGuest: Alex Moreno   Arrive 11/16/2026   Depart 11/18/2026\n11/16 Room charge 389.00\n11/16 Occupancy tax 57.38\n11/17 Room charge 389.00\n11/17 Occupancy tax 57.38\n11/17 In-room movie 17.99\nBalance due 910.75\nPaid Visa ****0098"
          },
          {
            "id": "4",
            "date": "2026-11-17",
            "merchant": "Ostrander's Grill",
            "description": "Client dinner",
            "amount": 309.3,
            "attendees": "Alex Moreno; Priya Shah and Tom Ellery (Harbor Line Logistics)",
            "purpose": "2027 freight contract renewal",
            "receipt": "OSTRANDER'S GRILL  New York, NY\n11/17/2026  Table 14  Guests 3\nDry-aged strip x2 108.00\nRoast halibut 42.00\nSides 18.00\nBottle Cabernet 72.00\nSubtotal 240.00\nTax 21.30\nTip 48.00\nTotal 309.30"
          },
          {
            "id": "5",
            "date": "2026-11-17",
            "merchant": "Fulton Street Bagels",
            "description": "Breakfast",
            "amount": 14.25,
            "receipt": null
          },
          {
            "id": "6",
            "date": "2026-11-18",
            "merchant": "Concourse Cafe",
            "description": "Lunch",
            "amount": 23.4,
            "receipt": null
          }
        ]
      },
      {
        "id": "ER-3112",
        "employee": "Jordan Ellis",
        "department": "Warehouse operations",
        "trip": "Local supplier visits, Nov 20 to 24, 2026",
        "lines": [
          {
            "id": "1",
            "date": "2026-11-20",
            "merchant": "Personal car",
            "description": "Mileage: Columbus warehouse to Brightline Packaging, Groveport, round trip",
            "amount": 63,
            "receipt": null,
            "miles": 84
          },
          {
            "id": "2",
            "date": "2026-11-20",
            "merchant": "Groveport Municipal Lot",
            "description": "Parking",
            "amount": 12,
            "receipt": null
          },
          {
            "id": "3",
            "date": "2026-11-20",
            "merchant": "Groveport Municipal Lot",
            "description": "Parking",
            "amount": 12,
            "receipt": null
          },
          {
            "id": "4",
            "date": "2026-11-21",
            "merchant": "Bricktown Deli",
            "description": "Lunch",
            "amount": 36.08,
            "receipt": "BRICKTOWN DELI  Columbus OH\n11/21/2026 12:41\nReuben 15.50\nTomato soup 6.50\nIced tea 4.00\nSubtotal 26.00\nTax 2.08\nTip 8.00\nTotal 36.08"
          },
          {
            "id": "5",
            "date": "2026-11-24",
            "merchant": "Pinegate Office Supply",
            "description": "Label maker tape for receiving",
            "amount": 31.5,
            "receipt": "PINEGATE OFFICE SUPPLY\n11/24/2026\nLabel tape 12mm x3  29.17\nSubtotal 29.17\nTax 2.33\nTotal 31.50"
          },
          {
            "id": "6",
            "date": "2026-11-24",
            "merchant": "Gridnote",
            "description": "Gridnote Pro, monthly",
            "amount": 15,
            "receipt": null
          }
        ]
      },
      {
        "id": "ER-3120",
        "employee": "Sam Okafor",
        "department": "Marketing",
        "trip": "Chicago trade show, Nov 9 to 12, 2026 (3 nights)",
        "lines": [
          {
            "id": "1",
            "date": "2026-11-09",
            "merchant": "Skyharbor Air",
            "description": "Airfare CMH-ORD round trip",
            "amount": 318.4,
            "receipt": "SKYHARBOR AIR e-ticket receipt\nPassenger: SAM OKAFOR\nCMH-ORD 09NOV  ORD-CMH 12NOV  Economy\nFare 271.00\nTaxes and fees 47.40\nTotal USD 318.40"
          },
          {
            "id": "2",
            "date": "2026-11-12",
            "merchant": "Lakeview Tower Hotel",
            "description": "Hotel, 3 nights",
            "amount": 869.77,
            "receipt": "LAKEVIEW TOWER HOTEL  Chicago, IL\nGuest: Sam Okafor   Arrive 11/09/2026   Depart 11/12/2026\n11/09 Room 239.00  Tax 41.59\n11/10 Room 239.00  Tax 41.59\n11/11 Room 239.00  Tax 41.59\n11/11 Laundry service 28.00\nTotal 869.77"
          },
          {
            "id": "3",
            "date": "2026-11-10",
            "merchant": "Corner Bakery Stand",
            "description": "Breakfast",
            "amount": 14.6,
            "receipt": null
          },
          {
            "id": "4",
            "date": "2026-11-10",
            "merchant": "McCormick Hall food court",
            "description": "Lunch",
            "amount": 21.8,
            "receipt": null
          },
          {
            "id": "5",
            "date": "2026-11-10",
            "merchant": "Wabash Tap House",
            "description": "Dinner",
            "amount": 70.34,
            "receipt": "WABASH TAP HOUSE  Chicago IL\n11/10/2026  Guests 1\nBurger 19.00\nChopped salad 12.00\nFries 7.00\nCraft beer x2 16.00\nSubtotal 54.00\nTax 5.54\nTip 10.80\nTotal 70.34"
          },
          {
            "id": "6",
            "date": "2026-11-09",
            "merchant": "Midwest Expo Freight",
            "description": "Booth crate shipping",
            "amount": 412,
            "receipt": "MIDWEST EXPO FREIGHT\nInvoice 7782\nBooth crate inbound and outbound, 1 crate  412.00\nTotal 412.00"
          },
          {
            "id": "7",
            "date": "2026-11-11",
            "merchant": "Pilsen Taqueria",
            "description": "Dinner",
            "amount": 24.1,
            "receipt": null
          }
        ]
      }
    ]
  },
  "files": [],
  "configHash": "e41f86ba78dd714640f2e745e2872fceb4ba6740e237d3ac9607021c1247a7a1"
}
