1. Batch-triage stock exceptions (map-reduce, 2 agents)
Every shift the WMS spits out a long list of exceptions — low-stock alerts, cycle-count variances, negative-on-hand, mis-slots. A supervisor reads them one by one, decides which need an inventory adjustment, and most sit untouched until they become a pick failure.
Trigger: Webhook (WMS exception export — end of shift / scheduled)
How the workflow runs
- Trigger
Exception batch is ready. A scheduled Webhook trigger fires with the batch reference from the WMS (or the workflow pulls the open-exception list). The WMS/OMS has no first-party connector — it arrives via Webhook and is read back via a Tool (MCP) node.
- Loop
Map: iterate every exception. A Loop node fans a cheap mapper agent across each exception — one focused pass per record, isolated context, so a 900-line export is handled the same way as a 9-line one.
- Agent
Mapper classifies + proposes. The mapper returns strict JSON per exception (type, SKU, location, severity, proposed action: RECOUNT / ADJUST / RESLOT / IGNORE) grounded in the count/variance rules — it proposes, it never posts an adjustment.
- Agent
Reduce: reducer rolls it up. After the map completes, a reducer agent aggregates the validated items into a shift summary: top variance drivers, the SKUs needing an adjustment, and the recount worklist.
- Approval
Ops approves the adjustments. An Approval node holds every proposed inventory adjustment (and any chargeable recount/rework) for a supervisor — nothing changes on-hand or bills the client without a click.
- Output
Apply approved + post the report. A Tool (MCP) node posts only the approved adjustments back to the WMS and files the shift summary; unapproved items stay a worklist.
Channels & connectors
- Webhook
- Tool (MCP → WMS/OMS)
- Approval / HITL
Outcome
The whole exception queue is triaged and rolled into a decision-ready shift summary each run, with a human owning every on-hand change.
Why it helps
Map-reduce turns an unbounded manual read-through into cheap per-item passes plus one synthesis — the supervisor spends their time approving adjustments, not sorting a raw export.
Build spec
2 agents — 1 mapper (runs once per exception via the Loop node) + 1 reducer (runs once). Loop/Approval are workflow nodes. · Pattern: Map-reduce: Loop (map) → reducer (reduce) → human approves adjustments
System prompt (paste-ready)
(Mapper) Triage ONE warehouse exception. Return strict JSON {type (LOW_STOCK|CYCLE_COUNT_VAR|NEG_ON_HAND|MIS_SLOT), sku, location, severity (LOW|MED|HIGH), proposed_action (RECOUNT|ADJUST|RESLOT|IGNORE), reason}. Judge only from the record's own fields and the counting rules in Knowledge — never invent a quantity, and NEVER treat a proposed ADJUST as done; you only recommend. If the record is malformed, set proposed_action=RECOUNT with reason='needs verification'.Agent roles & model tiers
Mapper (per exception) — Economy tier — fast, cheap; runs N times so its model choice dominates total cost
Classify ONE exception into strict schema-valid JSON with a proposed action; null for missing fields; zero invented quantities; ADJUST is only ever a recommendation.
Reducer (once) — Standard tier — reasoning
Aggregate the validated per-exception results into a shift summary: top variance drivers, the ADJUST worklist with SKUs/locations, and a recount list. Use only the provided items; cite real counts, never estimate.
MCP connectors
- WMS / OMS (exception export + adjustment post) — via Tool (MCP)
- Client 3PL portal / email — for the shift summary
Built-in tools
- knowledge_search (cycle-count + variance-tolerance SOP)
- http_request (fetch exceptions + post approved adjustments)
Guardrails
- The agents only propose — every on-hand adjustment and any chargeable recount/rework passes the Approval node before the WMS is touched
- Schema validation on each mapper output — a malformed exception is dropped from the reduce and queued for recount, never silently adjusted
- Idempotent per exception id, so a re-run of the batch never double-posts an adjustment
Cost strategy
Cost is linear and predictable: N × (economy-tier, hard-capped mapper) + ONE standard-tier reduce. Because the mapper runs across the whole exception batch, it MUST sit on the economy tier — that single choice is the dominant cost lever; the reducer's one call is where the reasoning budget goes. Run the map in Parallel batches for wall-clock speed without changing per-item cost.
Output & delivery
Loop maps the cheap agent over every exception → reducer synthesizes the shift summary once → supervisor Approval gates the adjustments → a Tool (MCP) node posts only the approved changes back to the WMS and files the report; unapproved items remain a worklist, never auto-applied.