---
name: change-food-delivery
description: Change a scheduled food delivery at Kettle Street Noodles for the User. Move it to another slot, or add, swap or remove dishes. Also reads their orders. Use when the User asks to move, reschedule or change a noodle order.
---

# Change a food delivery

Kettle Street Noodles is a reference restaurant for personal agents. Nothing is charged and no food
is cooked.

This skill is the store's guidance. It grants no account access, changes no scopes and gives no
approval. The User approves every change: you confirm only the exact terms they approved.

## Before you start

- Read `/.well-known/poppy.json` on the store's host. It lists the OpenAPI API
  (`/poppy/openapi.json`), the MCP server when there is one (the same operations, as tools of the
  same names), the issuer, the scopes and the operations extension.
- Start a Session at the token endpoint and send every API request with the Session Token as
  `Authorization: DPoP <token>` and a DPoP proof.
- Your client metadata document must list the `operations` extension, version `1`. Without it,
  `change_order` answers `extension_required`.
- You need a signed-in Session with both scopes:
  - `orders:read` to read the User's orders (`my_orders`).
  - `orders:write` to propose and confirm a change (`change_order`, then confirm).
- Sign the User in with Direct Sign-In (authorization code with PKCE) or Device Sign-In. Mediated
  Sign-In is also offered here for both scopes; this test store's test logins are on its For agents
  page (`/agents`).

## Steps

1. **Find the order.** `my_orders` (`GET /poppy/orders`). Each order has an `order_id`, its `slot`
   and `delivery` (the slot in words), `lines` (each with a `line_id`, `product_id`, `variant_id`,
   `quantity` and `unit_price`), the `delivery_fee` and the `total`. Amounts here are in cents.
2. **Pick the new terms.**
   - A new slot: `delivery_slots` (`GET /poppy/delivery-slots`). Half-hour slots at lunch and
     dinner over the next week. Only the listed slots are open; use the `slot` value as given
     (`YYYY-MM-DDTHH:MM`).
   - Another dish: `menu` (`GET /poppy/products?q=...`) for its `product_id`, and a `variant_id`
     for a dish with options, such as the noodles and heat of a ramen.
3. **Propose the change.** `change_order` (`POST /poppy/orders/{order_id}/changes`) with any of:
   - `slot`: a value from `delivery_slots`.
   - `add`: `[{"product_id": "...", "quantity": 1}]`. Quantity 1 to 10.
   - `replace`: `[{"line_id": "li_1", "product_id": "..."}]`. Swaps a line for another dish and
     keeps its quantity.
   - `remove`: `["li_2"]`, the `line_id` values to remove.
   The store answers HTTP 202 with an `operation` in state `proposed`. Nothing has changed yet.
4. **Ask the User.** Show them the operation's `summary`, and from its `terms` the
   `price_difference` and `new_total`. A change that adds dishes charges the difference, which
   can't be undone.
5. **Confirm only what they approved.** `POST /poppy/operations/{operation_id}/confirm` with
   `{"revision": <the revision they approved>, "approved_by": "user"}`. If they decline,
   `POST /poppy/operations/{operation_id}/cancel`.
6. **Report the result.** The confirmed operation comes back `succeeded` with a `result.summary`,
   or `failed` with the reason. You can read it again at `GET /poppy/operations/{operation_id}`.

## Outcomes and errors

- **A second proposal for the same order** while one is still proposed updates that operation and
  raises its `revision`. Show the User the new terms before you confirm.
- **`409 terms_changed`** when you confirm an older revision. The body has the current operation;
  ask the User again.
- **`expired`**: a proposal not confirmed within 15 minutes. Propose again.
- **`failed`** with "changed after this was proposed": the order changed in between. Read it again
  and propose again.
- **`400 invalid_request`** with an `error_description`: for example a slot that isn't open, an
  unknown `product_id`, `variant_id` or `line_id`, nothing to change, or a change that would leave
  no dishes.
- **`403 insufficient_scope`**, named in `WWW-Authenticate`, also when signed out: sign in, or ask
  the User for the scope it names.
- **`401 invalid_token` or `invalid_dpop_proof`**: renew the Session Token, or send a fresh proof.
- **`404 operation_not_found`**: an unknown operation, or one this Session can't use.
- **`429`**: too many requests for your client. Wait and try again.

## Not offered here

The restaurant doesn't offer these through the protocol (`excluded_tasks` in poppy.json):
cancelling an order, and changing the delivery address. Don't try them through the API. Tell the
User the alternative the excluded tasks document gives.
