> ## Documentation Index
> Fetch the complete documentation index at: https://docs.duckie.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Condition Routing and Agents

> Route WISMO cases to the right specialist agent or controlled workflow

Condition routing is the core of the WISMO system. The customer may ask the same question every time, but Duckie should not answer every order-status request the same way.

Use a workflow for the routing layer. Use specialist agents for the exception-specific investigation and response.

## Routing Workflow

```mermaid theme={null}
flowchart TD
  Context["Canonical order context"]
  Guard{"Guardrail triggered?"}
  Normal{"ETA exists and within SLA?"}
  Supplier{"Supplier backorder or allocation issue?"}
  Warehouse{"Warehouse delay or handoff gap?"}
  Split{"Multiple shipment states?"}
  Carrier{"Carrier exception or stalled tracking?"}
  DNR{"Delivered but customer disputes receipt?"}
  Repeat{"Repeated contact?"}

  Context --> Guard
  Guard -->|Yes| Escalate["Priority escalation workflow"]
  Guard -->|No| Normal
  Normal -->|Yes| Standard["Standard status agent"]
  Normal -->|No| Supplier
  Supplier -->|Yes| SupplierAgent["Supplier backorder agent"]
  Supplier -->|No| Warehouse
  Warehouse -->|Yes| WarehouseAgent["Warehouse investigation agent"]
  Warehouse -->|No| Split
  Split -->|Yes| SplitAgent["Split shipment agent"]
  Split -->|No| Carrier
  Carrier -->|Yes| CarrierAgent["Carrier exception agent"]
  Carrier -->|No| DNR
  DNR -->|Yes| DNRAgent["Delivered-not-received agent"]
  DNR -->|No| Repeat
  Repeat -->|Yes| Escalate
  Repeat -->|No| Standard
```

## Condition Matrix

| Condition                       | Trigger examples                                                          | Handler                                               | Expected output                                                                                |
| ------------------------------- | ------------------------------------------------------------------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| Standard in transit             | Carrier ETA exists, latest scan is current, no unresolved contacts        | Standard status agent                                 | Current status, ETA, tracking link, follow-up only if ETA changes.                             |
| Processing within SLA           | OMS processing, WMS not started, still inside fulfillment SLA             | Standard status agent                                 | Expected ship-by date and clear next checkpoint.                                               |
| Supplier backorder              | Supplier ETA moved, allocation shortage, inbound PO delayed               | Supplier backorder agent                              | Customer-safe explanation, wait/cancel/alternate options, next supplier check.                 |
| Allocation conflict             | Inventory exists but is reserved or allocation failed                     | Supplier backorder agent                              | Explanation that availability changed before fulfillment, escalation if exception needed.      |
| Warehouse pick delay            | Pick pending beyond SLA, short pick, SKU quarantine, cycle-count mismatch | Warehouse investigation agent                         | Warehouse status, trace action, next checkpoint, escalation threshold.                         |
| Label created, no pickup        | Label exists but no first physical scan after threshold                   | Carrier exception agent                               | Handoff explanation, trace action, follow-up checkpoint.                                       |
| No tracking movement            | No carrier scan for threshold period                                      | Carrier exception agent                               | Carrier investigation status, expected investigation SLA, replacement/refund review if needed. |
| Delivery failed                 | Address issue, access issue, business closed, recipient unavailable       | Carrier exception agent                               | Carrier reason, reattempt or pickup options, address-verification path.                        |
| Return-to-sender                | Carrier status says return-to-sender or attempts exhausted                | Carrier exception agent plus resolution workflow      | Resolution choices and approval path.                                                          |
| Partial shipment                | Some items shipped or delivered while others are pending                  | Split shipment agent                                  | Itemized shipment map and per-shipment status.                                                 |
| Delivered not received          | Carrier delivered, customer says not received                             | Delivered-not-received agent plus resolution workflow | Delivery proof review, investigation path, approval recommendation.                            |
| Fraud, payment, or address hold | OMS hold status, payment review, address verification                     | Guarded hold workflow plus communications agent       | Approved verification request or internal escalation.                                          |
| Repeated contact                | Same order has 2+ WISMO contacts before resolution                        | Priority escalation workflow plus Slack agent         | Summary of prior updates and human review request.                                             |

## Specialist Agent Contracts

Each specialist agent should return the same output shape:

| Output                  | Description                                                                                           |
| ----------------------- | ----------------------------------------------------------------------------------------------------- |
| `condition_type`        | The specific WISMO condition detected.                                                                |
| `customer_safe_summary` | Facts that can be shared with the customer.                                                           |
| `internal_summary`      | Operational details for CX or operations only.                                                        |
| `recommended_action`    | Answer, monitor, trace, investigate, replacement review, refund review, or escalate.                  |
| `customer_options`      | Wait, cancel, alternate item, address correction, hold for pickup, replacement, or refund if allowed. |
| `follow_up_reason`      | Why Duckie should check again later.                                                                  |
| `next_follow_up_due_at` | The promised or internal follow-up time.                                                              |
| `confidence`            | High, medium, or low. Low confidence should trigger review.                                           |

## Agent Responsibilities

| Agent                         | Scope                                                                                    | Avoid                                                              |
| ----------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| Standard status agent         | Normal processing, in-transit, delivered, and within-SLA states.                         | Inventing ETAs or using generic time windows.                      |
| Supplier backorder agent      | Supplier ETA, allocation, preorder/backorder, and approved substitute paths.             | Blaming suppliers or offering unapproved component alternatives.   |
| Warehouse investigation agent | Pick/pack delay, short pick, SKU quarantine, label-created-no-handoff, and SLA breach.   | Promising warehouse action that the WMS does not support.          |
| Split shipment agent          | Multi-shipment itemization and per-item status explanation.                              | Hiding that only part of the order shipped.                        |
| Carrier exception agent       | No scan, no movement, delivery failure, return-to-sender, investigation status.          | Treating label creation as physical carrier possession.            |
| Delivered-not-received agent  | Delivery proof, address, customer history, and replacement/refund review recommendation. | Approving high-value replacements without the resolution workflow. |
| Customer communications agent | Customer-facing replies and proactive updates.                                           | Exposing internal risk signals or operational blame.               |

## Keep the Workflow Small

Do not create a workflow branch for every carrier scan code, supplier note, warehouse exception, or SKU-specific rule. Keep the routing workflow focused on stable condition families, then update specialist agent instructions, runbooks, knowledge, and guardrails as operations change.

<Tip>
  The routing workflow should decide who handles the case. The specialist agent should decide how to interpret the facts and what customer-safe explanation to draft within its scope.
</Tip>

## Next Pages

After routing and specialist agents:

1. Add [proactive follow-up](/examples/wismo-order-status/proactive-follow-up).
2. Add [escalation and resolution](/examples/wismo-order-status/escalation-and-resolution).
3. Use the [rollout plan](/examples/wismo-order-status/rollout-plan) before expanding live traffic.
