Northwind ERP Operations
Solve operational tasks for Northwind Components using its shared ERP REST API. The API base URL is supplied by the runtime as <TASK_ENV_BASE_URL> or an equivalent placeholder. All endpoints are read-only (GET). There is no authentication.
Domain Model
Products
Each product has a sku (string, e.g. NW-1000), name, unit_cost (float USD), is_active (boolean), supplier_id, and a product_master flag. Inactive SKUs (is_active: false) cannot be shipped; lines referencing them require manual_review with reason inactive_product.
Customers
Each customer has a customer_id (string, e.g. CUST-200), customer_name, and status fields that drive exception classification:
account_status:active,blocked, orreview_required.blockedmeans reject/held decisions.review_requiredmeans manual review.risk_flag:none,fraud_watch, orcredit_watch.fraud_watchtakes precedence; it triggersmanual_reviewwith reasonfraud_watch.credit_watchtriggersmanual_reviewwith reasoncredit_watch.
When any customer-level block (account blocked, fraud watch, credit watch) is active, every line in that order is held for manual review regardless of inventory status.
Warehouses
Three warehouses: WH_NORTH, WH_CENTRAL, WH_WEST. Each has a warehouse_id, warehouse_name, and a zip_code.
Inventory
Query /inventory?warehouse_id=<id>&sku=<sku> to get per-warehouse per-SKU stock. The response shape varies by API version. Read the actual response fields and adapt:
on_hand: physical units in the warehousereserved: units allocated against open ordersquarantined: units held for quality inspectionavailable: may already be computed by the API ason_hand - reserved
Effective available for all dispatch, allocation, and replenishment decisions:
- If the API response includes a field named
effective_available, use it directly. - If
availableis present and representson_hand - reserved, computeeffective_available = available - quarantined. - If only raw counts are present, compute
effective_available = on_hand - reserved - quarantined. - Treat any missing field (e.g.
quarantined) as 0.
Inventory status for a line against a requested warehouse:
ready: effective available >= line quantitylow_stock: 0 < effective available < line quantityshortage: effective available <= 0inactive_sku: the productis_activeis falseinactive_and_shortage: the SKU is inactive AND effective available <= 0
Orders
Query /orders?wave=<wave>&required_date=<date>&customer_id=<id> or /orders/<order_id>. Each order has order_id, customer_id, warehouse_id (the requested ship-from warehouse), lines (array with line_id, sku, quantity, unit_price), status, and requested_shipping_speed (standard, express, or overnight).
Purchase Orders
Query /purchase_orders?supplier_id=<id>&sku=<sku>&status=<status>. Each PO has po_id, supplier_id, warehouse_id, sku, quantity, delivery_date, unit_cost, and status (draft, open, confirmed, received, closed, cancelled). Only open and confirmed POs count as eligible coverage.
A PO is timely if its delivery_date is on or before the target build or dispatch date.
Suppliers
Query /suppliers or /suppliers/<id>. Each supplier has supplier_id, supplier_name, and quality_status (approved, watch, quality_hold).
BOMs (Bills of Materials)
Query /boms/<bom_id>. Each BOM has bom_id, bom_name, warehouse_id (the build site), and components (array with sku, quantity_per_kit). Some BOM responses include a kit_name field.
Incidents
Query /incidents?start=<YYYY-MM-DD>&end=<YYYY-MM-DD>&supplier_id=<id>&sku=<sku>&incident_type=<type>&status=<status>. Each incident has incident_id, supplier_id, sku, incident_type (RMA or WORK_ORDER), severity (low, medium, high, critical), status (open, closed, in_review), open_date, close_date (null if open), resolution_cost (float USD), and description.
Shipping Quotes
GET /shipping/quote?warehouse_id=<id>&destination_zip=<zip>&weight_lb=<float>&speed=<standard|express|overnight> returns zone_distance (integer), service_days (integer), total_cost_usd (float USD, round to 2 decimals).
Compute total weight for a quote by summing across all lines in the order. If per-product weights are not directly available from the product endpoint, estimate a reasonable per-unit weight (often 1-5 lb) and multiply by line quantities. Use the product master's weight field if present.
Common Computation Rules
Currency
All USD values rounded to 2 decimal places. Use standard rounding (half-up). Extended cost = quantity * unit_cost.
Percentages
Rounded to 1 decimal place. Denominator is always the full filtered population for that analysis.
Durations
Rounded to 2 decimal places. For closed incidents: calendar days from open_date to close_date. For open incidents: calendar days from open_date to analysis date.
List Ordering
Sort by the primary key ascending (string/numeric natural order) unless the answer template specifies a different ordering. For transfer requests the typical sort is sku ascending, then quantity descending, then from_warehouse_id ascending, but always defer to the template when it is explicit.
Top-Level Consistency
Every count/aggregate in the summary must match the detail records. Recompute summaries from the detail records rather than maintaining them independently.
Task-Type Workflows
1. Expedite Dispatch
Given a wave ID and an order list (from a memo), for each order:
- Fetch the order, its customer, and its lines from the API.
- For each line, fetch the product (check
is_active) and inventory at the order's warehouse. - Compute inventory status per line across the order. Aggregate to an order-level inventory status: the worst-case among lines (order of precedence:
inactive_and_shortage>inactive_sku>shortage>low_stock>ready). - Determine customer exception: check
account_status,risk_flag.account_blockedtakes precedence overfraud_watchovercredit_watchoverreview_requiredovernone. - Decision matrix:
account_blockedorfraud_watch→reject_hold/hold_credit_or_fraudcredit_watchorreview_requiredAND inventory not ready →manual_review/send_account_reviewreview_requiredAND inventory ready →manual_review/send_account_review- Any
inactive_sku→manual_review/escalate_product_master shortageorinactive_and_shortagewith no account block →backorder/create_backorderlow_stockwith no account block →delayed_release/delay_and_monitorreadywith no account block →ship_now/release_to_pick
- When an account exception is present alongside inventory issues, the account exception drives the decision (account flags override inventory status).
- Get a shipping quote for each order. Use the order's
requested_shipping_speed, the warehouse'szip_code, and the customer's zip (from/customers/<customer_id>) to call the quote endpoint. Estimate total weight from line quantities. - Populate exception SKU lists:
shortage_skus(lines where effective available <= 0),inactive_skus(lines whereis_activeis false),low_stock_skus(0 < available < qty). Remove duplicates, sort ascending. - Build the summary from the completed records.
2. Kit-Build Replenishment
Given a list of BOMs with target build quantities and dates at a planning warehouse:
- Fetch each BOM. Sum component requirements: for each component SKU,
total_required = sum over all BOMs using that SKU of (build_quantity * quantity_per_kit). - Fetch inventory at the target warehouse for each component SKU. Compute
target_effective_available = effective_available - total_required. A negative value means a gap. - Fetch all purchase orders for each component SKU at the target warehouse with status
openorconfirmed. Sum their quantities astimely_po_qtyifdelivery_dateis on or before the earliest build date that requires that SKU. Some components may only be needed for later builds; the PO deadline is the earliest build date for that component. - For components with a gap after POs: check other warehouses for transferrable stock.
- For each other warehouse, compute effective available. If positive, that quantity is eligible for transfer.
- Allocate transfer quantity from warehouses with the most effective available first (descending order), up to the remaining gap.
- Record each transfer as a separate transfer request line.
- After transfers, any remaining gap requires a purchase requisition.
- Use the SKU's supplier from the product master (
supplier_id). - Use the product's
unit_costfrom the product API. needed_byis the earliest build date requiring that component.
- Use the SKU's supplier from the product master (
- Final action per component:
- Effective available already >= total_required →
no_action_stockedoroverstock_excluded(exclude if > total_required by a margin consistent with overstock policy). - Gap covered entirely by timely POs →
timely_po_covered - Gap covered entirely by transfers →
transfer_only - Gap requires new POs →
purchase_required
- Effective available already >= total_required →
- Excluded components are those with
final_actionofno_action_stocked,overstock_excluded, ortimely_po_covered. Onlytimely_po_coveredandoverstock_excludedandstocked_no_gapappear in theexcluded_componentslist with supporting PO IDs. - Summarize component count, purchase units/cost, transfer units, and timely-PO-covered units.
3. Supplier Incident Scorecard
Given a date range, analysis date, and recommendation policy:
Fetch all incidents within the date range (
open_datebetween start and end inclusive).Fetch all suppliers to get names and quality statuses.
Filter incidents to the date window. Group by
supplier_id.For each supplier with at least one incident:
- Count total incidents, RMA incidents, WORK_ORDER incidents, open incidents, severe incidents (severity
highorcritical). - Sum
resolution_cost. - Compute average duration: for each incident, days =
close_date - open_dateif closed, oranalysis_date - open_dateif open. Average across all supplier incidents. - Compute
incident_percentage= (supplier incident count / total filtered incidents) * 100, rounded to 1 decimal.
- Count total incidents, RMA incidents, WORK_ORDER incidents, open incidents, severe incidents (severity
Apply recommendation policy in precedence order. The task payload (typically a scorecard request JSON or memo) supplies the exact policy rules: thresholds, conditions, and the full precedence chain. Read the policy from the task payload rather than assuming fixed thresholds. The general pattern across the four tiers:
- ESCALATE_SUPPLIER: highest severity; triggered by quality_hold status combined with incident volume, any critical RMA, or high RMA count with high resolution cost.
- PROCESS_REVIEW: triggered when WORK_ORDER count exceeds RMA count by a defined margin.
- WATCHLIST: triggered by watch/quality_hold status, moderate incident count, moderate resolution cost, or moderate severe-incident count.
- MONITOR: fallback when no higher-precedence condition applies.
Evaluate conditions in precedence order and assign the first matching tier. The task payload defines the numeric thresholds for each tier.
highest_cost_supplier_id: supplier with maxtotal_resolution_cost. Break ties by lowestsupplier_id.highest_share_supplier_id: supplier with maxincident_count. Break ties by lowestsupplier_id.top_escalation_suppliers: suppliers with recommendationESCALATE_SUPPLIER, ordered by incident count descending, then total resolution cost descending, then supplier_id ascending.
4. Allocation / Transfer Desk
Given a wave ID and a desk memo with order context:
- Fetch all orders in the wave via
/orders?wave=<wave_id>. - For each order, get the customer and check status fields. Orders with
account_blocked,fraud_watch,credit_watch, orreview_requiredare fully blocked: every line becomesmanual_reviewwith the corresponding primary reason. Add these orders toblocked_orders. - For non-blocked orders, process each line:
- Fetch product master to check
is_active. Inactive product →manual_reviewwith reasoninactive_product. - Fetch inventory at the requested warehouse. Compute
requested_effective_available. - If
requested_effective_available >= line quantity→ship,ship_quantity = line quantity. - If
0 < requested_effective_available < line quantity→ship_quantity = requested_effective_available, check other warehouses for the remainder. - If
requested_effective_available <= 0→ship_quantity = 0, check other warehouses. - For the uncovered quantity, check each other warehouse's effective available. If any warehouse can fully cover the remainder →
transfer, pick the warehouse with the highest effective available astransfer_from,transfer_quantity = uncovered. If no warehouse can fully cover →backorder,backorder_quantity = uncovered. - Transfer source selection: pick the single warehouse with the most effective available. Do not split transfers across multiple warehouses unless explicitly required.
- Fetch product master to check
primary_reason:nonefor clean lines,insufficient_effective_stockfor backorder lines,inactive_productfor inactive SKU lines, and the appropriate account/risk reason for blocked orders.- For order rollup: if all lines are
ship→ready_to_ship. If any line istransfer→needs_transfer. If any line isbackorder→has_backorder. If any line ismanual_review→manual_review. Mixed cases where there is nomanual_reviewbut a combination of ship/transfer/backorder →mixed_actions. transfer_requestslist: one entry per transfer line.from_warehouseis thetransfer_from,to_warehouseis the requested warehouse,quantityis thetransfer_quantity.
5. Procurement Quality Review
Given an analysis window, a list of target supplier IDs, and a decision policy in the task memo:
Fetch incidents for each target supplier within the analysis window (
open_datebetween start and end inclusive).Fetch each supplier's current
quality_statusfrom the supplier endpoint.Fetch all open and confirmed purchase orders for each target supplier. Only
openandconfirmedPOs count as held.For each supplier, compute:
recent_incident_count: total incidents in the window.recent_rma_count: incidents whereincident_typeisRMA.severe_or_critical_count: incidents whereseverityishighorcritical.open_incident_count: incidents wherestatusisopen.affected_skus: distinct SKUs from incidents, sorted ascending.sample_incident_ids: incident IDs for this supplier, sorted ascending, capped at 5.
Decision logic: the task memo or policy payload defines the exact conditions per supplier. Read it from the task materials before applying decisions. The general hierarchy is:
freeze_new_replenishment: highest risk; typically quality_hold with recent incidents, or high severe/critical counts, or watch status with multiple RMAs. All open/confirmed POs for this supplier are held.buyer_review_required: moderate risk; typically watch status with incidents (but not meeting freeze criteria), or approved supplier with isolated severe/RMA incidents. Open/confirmed POs are held.monitor_only: low risk; no concerning patterns trigger the higher tiers. POs are released.
Evaluate conditions in precedence order and assign the first matching tier. The task payload defines the numeric thresholds.
held_po_ids: all open/confirmed POs for suppliers whose decision is NOTmonitor_only. Deduplicated, sorted ascending.release_supplier_ids: suppliers whose decision ismonitor_only, sorted ascending.
General Process
- Read the task prompt and all payload files in
input/payloads/. The prompt identifies the task type and supplies<TASK_ENV_BASE_URL>. - Identify the answer template (usually
answer_template.jsonin the payloads directory). The output must conform exactly: every required key present, every enum value from the allowed set, every list sorted as specified, and every numeric value rounded correctly. - Query the API in order: fetch reference data first (products, customers, suppliers, warehouses), then task-specific data (orders, inventory, BOMs, incidents, POs). Reuse responses for repeated lookups on the same entity.
- Compute decisions per entity, applying domain rules from the sections above.
- Assemble the output JSON with all records sorted as specified and all summary fields computed from the detail records.
- Return only the JSON object. No narrative explanation, no markdown fences unless the prompt explicitly requests a wrapped format.