We raised $8M from Peak XV, Fin Capital and Y Combinator. Read the announcement →
← Blog

How an AI shopping agent finds the best deal: our product search, step by step

We rewrote product search for AI agents. Here’s how it works

We rewrote product search for AI agents. A search result: a Staub 4-quart dutch oven at $149.95, down from $379.95.

For Cyber Monday we rewrote the search behind opencommerce from the ground up. When an agent shops for you, it needs to find the right product at the best price in one try, so search is the part that matters most.

This is the flow every request goes through. We’ll follow one real search we ran on 1 December 2026: “get me a dutch oven, only options that are 50% off”.

1. Understand

A language model reads the request and writes two or three other ways to say it. It also pulls out what the shopper requires and what they’d only like. Here, the product is a dutch oven and the requirement is 50% off or more.

Before the model reads anything, we hide emails, phone numbers, card numbers and street addresses in the message.

2. Gather widely

Every phrasing goes out at once to our own product index and to every source we search, each with its own time limit. That brings back thousands of candidates from hundreds of stores, out of millions of stores in total.

If a source is slow, we stop waiting once the others are in. Its late answer still gets saved, so the next search has it.

3. Unify results

The same product often shows up at several stores. We fold those listings into a single result that shows every store’s price. First we match on the product’s identifier, then a model decides what counts as “the same thing” for that kind of product. Every decision is saved.

4. Judge

A model gives each candidate one of four grades: exact, substitute, accessory or not relevant. It also gives a fit score from 0 to 100 and checks every requirement.

One thing never goes to the model: discounts. “50% off” is checked with arithmetic on the two prices the store shows.

5. Score

Every candidate gets one score, in a strict order: the grade first, then the requirements it meets, then how well it fits. When you ask for a discount, the size of the discount comes next. When you ask for the cheapest, the price does.

It doesn’t matter which source found a product. Every candidate is scored the same way.

6. Variety

Eight versions of the same pot isn’t a useful list. So we pick results one at a time, and each pick is penalised for how similar it is to the ones already chosen. (This is maximal marginal relevance, from Carbonell and Goldstein, 1998.)

Variety only reorders results of the same grade and fit. It can never put a worse match above a better one.

7. Results

From thousands of initial products, the best 40 are returned to the shopper.

In our dutch oven search, every result was at least 50% off. The top two were a Staub 4-quart at $149.95, down from $379.95. There was also a Le Creuset at $285, down from $680.

What we got

As a result we built the best machine to find deals, and as a side effect our product search in general got much better too.

See it working: add opencommerce to Muse at try.opencommerce.sh or ask your Grok Bot to implement it.

Building an agent that shops? The same search is in the opencommerce SDK: get started at opencommerce.sh: npx agent-cards init