Skip to content

Standing Orders Flow

sequenceDiagram participant Agent participant MCP rect rgb(40, 60, 80) Note over Agent,MCP: Create Standing Order (folded into confirm_trip) Agent->>MCP: verify_member Agent->>MCP: set_booking_details (trip_type=standing_order, RRULE) Agent->>MCP: review_trip Agent->>MCP: confirm_trip MCP-->>Agent: standing_order_id + days_of_week + start/end_date end rect rgb(60, 40, 40) Note over Agent,MCP: Cancel Standing Order (single-tool two-step) Agent->>MCP: get_standing_orders MCP-->>Agent: orders[] Agent->>MCP: cancel_standing_order(order_id) [no reason] MCP-->>Agent: available_reasons[] Agent->>MCP: cancel_standing_order(order_id, reason) MCP-->>Agent: status=cancelled end
verify_member
--> set_booking_details (trip_type="standing_order" + RRULE)
--> review_trip
--> confirm_trip

v2.0 change: the standalone create_standing_order tool was removed. confirm_trip now handles BOTH single trips AND recurring standing orders — it dispatches based on the draft’s trip_type (standing_order → standing-order creator; otherwise → trip creator). Agents have a single confirmation surface for both flows.

  1. verify_member — Establish session
  2. set_booking_details — Set trip_type = "standing_order" along with pickup, dropoff, appointment time, and the recurrence rule (RRULE)
  3. review_trip — Review the standing order summary (the formatter shows the schedule when trip_type=standing_order)
  4. confirm_trip — Routes to nemt-standing-order service when the draft is recurring. Returns standing_order_id, days_of_week, start_date, end_date, so_appointment_time, recurring=true.

The RRULE defines the recurrence pattern (e.g., every Mon/Wed/Fri) and date range. The standing-order service generates individual trip instances from the rule.

After successful creation, the session is updated with IsStandingOrder=true, StandingOrderID, and StandingOrderMeta — send_confirmation reads these to render the schedule email + PDF attachments.

verify_member --> get_standing_orders

Returns all standing orders for the member with order_id, status, treatment_type, schedule, start_date, and end_date.

verify_member
--> get_standing_orders
--> cancel_standing_order(order_id) # Step 1: returns reasons
--> cancel_standing_order(order_id, reason) # Step 2: cancels

Same two-step pattern as cancel_trip — see the Cancellation Flow.

Cancelling a standing order stops future trip generation. Already-created trips from the order are not automatically cancelled.

Error Recovery
MISSING_PREREQUISITE (no review) Call review_trip before confirm_trip
MISSING_PREREQUISITE (recurrence rule) Re-call set_booking_details with trip_type=standing_order and the RRULE
Order not found Re-fetch with get_standing_orders