← All articles

Cook tonight, wrapped for your agent

Your user says "can you sort dinner for tonight and the next two nights?". Your agent plans three dinners that share one pantry and AgentMall buys the groceries in one order. Here is the whole flow, ready to paste into your agent.

An API with search and buy lets your agent shop. It doesn't tell your agent what a good grocery job looks like: what to remember, what to ask, how to match a recipe to a shelf, and when to stop. So we wrapped the whole dinner job as instructions your agent follows, ready to slot into your product.

Your agent's memory and connectors bring the context. The instructions tell your agent the flow. AgentMall does the search and the checkout at real stores.

Who does what

  • Your product already knows the user: diet, allergies, dislikes, how many people eat, their budget and their store. It keeps that in its own memory, and AgentMall stores none of it. Your agent asks only for what is missing and saves the answers for next time.
  • The instructions tell your agent the flow: ask for a photo of the fridge or spice rack, plan meals that share ingredients, skip what is already in the kitchen, and match each line to the right product.
  • AgentMall searches the store, fills the cart, signs in, and places the order once the shopper approves, or at once when the total is at or under their budget.

Three dinners, one pantry

The user says: "can you sort dinner for tonight and the next two nights? something korean-ish."

Your agent already knows it is two people, no allergies, Instacart, and a $70 ceiling from last time. So it asks for one thing: "Send me a quick photo of your fridge and spice rack, and I'll skip what you already have." The photo shows salt, oil and sugar.

Grocers sell packs, not portions, so your agent plans three dinners that use each pack up:

Tonight      Gochujang chicken bowls
Tomorrow     Ginger-scallion noodles
Night three  Gochujang egg fried rice

They share gochujang, ginger, garlic, spring onions, cucumber and carrot. Your agent turns them into one list, searches each line on Instacart, and buys the basket in one order: 14 lines for $49.94 before fees, prices as of 4 December 2026.

The instructions carry what we learned matching groceries in live tests: check every title, skip the 6 lb bag of edamame that ranks first, prefer fixed packs to food priced by weight, keep an Instacart basket to one retailer's store brand plus national brands, and retry a failed search once. They are honest about the edges too: one store per order, up to 20 lines, no order above $100, and the store picks the delivery slot, so tonight's dinner depends on when it arrives.

How to add it

1. Get a key. Sign up or sign in at console.getagentmall.com. Setup gives you a sandbox key to build with.

2. Connect AgentMall to your agent. Over MCP, with your key and the user's shopper id. In Claude Code:

claude mcp add --transport http agentmall https://mcp.getagentmall.com \
  --header "Authorization: Bearer YOUR_KEY" \
  --header "X-Shopper-Id: shp_demo"

Other MCP clients, and the REST API for a backend, are in SKILL.md.

3. Paste these instructions into your agent, as a skill, a rules file or part of its system prompt:

---
name: agentmall-cook-tonight
description: Plan dinner tonight and the next two nights, and buy the groceries in one order, with AgentMall. Use when the user asks what to cook, wants a few dinners planned, or wants the ingredients delivered, such as "plan 3 dinners for the two of us and get the stuff". Plans meals that share one pantry so nothing goes to waste, skips what the user already has, builds one basket, searches each line and buys once.
---

# Cook tonight with AgentMall

The user wants dinner sorted: tonight and the next two nights. You plan three dinners that share one pantry so nothing goes to waste, leave out what is already in the kitchen, find each line at one grocery store, and buy the basket as one order.

These instructions cover the meal flow only. Read https://www.getagentmall.com/SKILL.md first for keys, connecting, every question kind and every error.

## 1. What you need

**From your own memory of the user.** AgentMall stores none of this. Your agent keeps it, wherever your product keeps what it knows about the user:

- Diet, such as vegetarian or halal.
- Allergies.
- Dislikes.
- Household size: how many people eat.
- Budget, and whether it is a ceiling ("keep it under $70") or a guide.
- Preferred grocery store.

Ask only for what is missing, in one message, and save the answers back so you don't ask next time.

**From your own connectors: more context.** AgentMall never reads the user's email, messages, notes or anything else. Your agent does, through the integrations your product already has. Useful sources:

- Calendar: which nights they are home, and for how many.
- Notes or chat: recipes they saved, and foods they said they love or can't eat.
- Email: past grocery receipts, for the brands they buy and the store they use.

If a source isn't connected and it would help, ask once: "Your saved recipes in Notes might be a good place to start. Want to connect it?"

**From the user, each time:**

- A quick photo of their fridge, pantry or spice rack, if your agent can see images: "Send me a quick photo of your fridge and spice rack, and I'll skip what you already have." Without images, ask which staples they have, such as rice, oil and soy sauce.
- The delivery address, if it isn't the one on their store account. US only.

**From AgentMall:** `list_merchants`, `search`, `buy`, `get_purchase` and `respond`.

## 2. Limits of one basket

- **One purchase is one order at one store.** Plan the whole basket for one store.
- **Up to 20 lines, each quantity 1 to 12.** If the store's `profile` has `max_quantity`, more of one item than that ends `failed` `quantity_invalid`.
- **No order above $100.** A checkout total above $100 ends `failed` with `total_above_cap`. `max_total` is at most `10000`.
- **The store's minimum.** If the store's `profile` has a `minimum`, keep the subtotal above it. Under a store's minimum the purchase ends `failed` with `order_minimum_not_met`, and `message` says how much to add. Some stores have no `minimum` in the profile and only show one at checkout: `instacart`'s retailers set their own.
- **One open purchase per store for each shopper.** A second `buy` at the store while the first is `running` or `awaiting_input` returns `purchase_in_progress`. Put everything in the one basket.
- **No delivery slot choice.** The store picks the delivery. Read `checkout.fulfillment` for what it chose when the store says, and never promise a time. Tonight's dinner depends on when the delivery comes, so say so.

## 3. The flow

### Plan meals that share ingredients

Grocers sell packs, not portions. A recipe that needs one carrot still buys a bag. So plan meals that use each pack up:

- Pick 2 or 3 sauces or aromatics that run through every meal, such as gochujang, ginger and spring onions.
- Use one protein pack across two meals, and eggs or a pantry staple for the third.
- Use the same vegetables raw in one meal and cooked in another.

Plan around what the photo shows: use up what is already open, and don't buy a second jar of anything on the shelf. Show the plan in one line per night, and ask for a yes before you search.

### Pick a store

```json
// list_merchants
{}
```

Pick one grocery store, such as `instacart`, `walmart`, `albertsons`, `wegmans` or `freshdirect`: the user's preferred store from your memory if `list_merchants` returns it, otherwise ask. Read its `profile` for `currency`, `minimum` and `max_quantity`.

### Write the basket

One line per ingredient, with the amount the meals need. Leave out everything the photo or the user says is already in the kitchen. Then search each line once:

```json
// search
{ "merchant": "instacart", "query": "boneless skinless chicken thighs" }
```

Matching rules, from live tests:

- **Check every title.** Search returns the nearest matches, not exact ones. A query for an ingredient can return a sauce or a snack made with it.
- **Prefer plain produce and national brands.** They match the query and the recipe most often.
- **Pick a realistic pack.** The first result can be a bulk bag: a 6 lb bag ranked first for "frozen shelled edamame". Pick the size the meals need.
- **Prefer fixed packs to food priced by weight.** A per-lb price doesn't say how much ends up in the cart. Pick a pack with a stated size.
- **On `instacart`, keep to one retailer.** Results mix store brands from different retailers, such as Sprouts, Kroger, Kirkwood and Great Value, and a checkout covers one retailer's cart. Use one retailer's store brand plus national brands, never two retailers' store brands.
- **On `walmart`, prefer what the store sells itself.** Search mixes in marketplace listings shipped by other sellers, which don't come same day. Results don't name the seller, so skip listings that look like a reseller's: odd bundles, multipacks of a fresh item, or a price far above the rest.
- **Retry a failed search once.** A search can fail with `merchant_unreachable`. Wait a few seconds and search again. If it fails again, tell the user and try later.

Show the basket with prices and the subtotal before buying. Prices are indicative; the checkout total with fees and tax is what gets charged.

### Buy once

One `buy` with every line in `items`.

- **The user gave a ceiling:** pass it as `max_total` in cents. At or under it the order is placed with no approval.
- **No ceiling:** leave `max_total` out. The shopper approves the exact total on an `approve` link. Never invent a ceiling.
- **Another address:** put it in `details.ship_to`. Without it, the order goes to the address on the shopper's store account, or the purchase asks `ship_to`.

Then follow the purchase with `get_purchase` every 5 seconds, and answer each question as SKILL.md section 6 says. A line that is out of stock asks `unavailable`: tell the user which meal it hurts, then `drop` it or `cancel`. Dropping can take the basket under the minimum; check first.

When it ends `placed` or `submitted`, send the user the meal plan again with which night uses what.

## 4. Worked example

Prices are a snapshot from `instacart` on 4 December 2026, before fees. Prices and stock change, so search again before you buy.

The user: "can you sort dinner for tonight and the next two nights? something korean-ish."

Your memory has the household (2), no allergies, Instacart, and a $70 ceiling from last time. Nothing is missing, so ask only for the photo. The fridge and spice rack photo shows salt, oil and sugar, and no rice or soy sauce.

$70 is a ceiling: `max_total` is `7000`.

**1. Plan.** Three meals that share gochujang, ginger, garlic, spring onions, cucumber and carrot:

```text
Tonight      Gochujang chicken bowls: chicken thighs, rice, cucumber, carrot, edamame
Tomorrow     Ginger-scallion noodles: chow mein noodles, ginger, spring onions, soy, sesame oil
Night three  Gochujang egg fried rice: leftover rice, eggs, carrot, edamame, spring onions
```

**2. Search each line and pick.** Two Sprouts store-brand lines (chicken thighs, jasmine rice) plus national brands and plain produce, so the basket stays in one retailer's cart:

```text
chicken thighs     Sprouts boneless skinless chicken thighs       1    $8.11
rice               Sprouts organic jasmine rice                   1    $5.49
noodles            Wel-Pac chow mein noodles                      1    $3.79
eggs               Eggland's Best large eggs, 12 ct               1    $4.46
edamame            Seapoint Farms shelled edamame                 1    $2.92
gochujang          CJ mild gochujang                              1    $4.79
soy sauce          Kikkoman soy sauce                             1    $2.99
sesame oil         Kikkoman sesame oil                            1    $4.48
rice vinegar       Marukan rice vinegar                           1    $2.97
ginger             Ginger root                                    1    $1.92
garlic             Garlic                                         1    $0.79
spring onions      Green onions                                   2    $2.58
cucumber           English cucumber                               3    $2.67
carrot             Organic carrot                                 3    $1.98
                                                    14 lines, subtotal $49.94
```

The Seapoint Farms bag is the regular size, not the 6 lb bag that ranked first. Salt, oil and sugar, all in the photo, are left out.

**3. Buy once,** all 14 lines, with the ceiling:

```json
// buy
{
  "merchant": "instacart",
  "items": [
    { "url": "<chicken thighs url from search>", "quantity": 1 },
    { "url": "<jasmine rice url from search>", "quantity": 1 },
    { "url": "<green onions url from search>", "quantity": 2 },
    { "url": "<english cucumber url from search>", "quantity": 3 },
    { "url": "<organic carrot url from search>", "quantity": 3 }
  ],
  "max_total": { "amount": 7000, "currency": "USD" },
  "idempotency_key": "<new uuid>"
}
```

The other 9 lines go in `items` the same way, each with quantity 1.

**4. Follow it.** If the total with fees is at or under $70, it is placed with no approval. Above it, the purchase asks `approve`: "With Instacart's fees it comes to $X, over your $70. Review and place it here: LINK." Poll until `placed`, then send the plan with what each night uses.

## 5. Don't

- Don't buy one meal at a time. One basket, one `buy`.
- Don't buy what the photo or the user says they have.
- Don't ask for what your memory already has.
- Don't pick the first result without reading the title and the pack size.
- Don't call `buy` again for the same basket. A timed-out `buy` is retried with the same `idempotency_key`.

Then ask your agent what's for dinner, and it takes it from there.