← All publications

OptAgent: Optimizing Query Rewriting for E-Commerce via Multi-Agent Simulation

Divij Handa, David Blincoe, Orson Adams, Yinlin Fu

Preprint 2025 Test-Time

Abstract

Combines multi-agent simulation with an evolutionary algorithm for query rewriting: multiple LLM agents act as simulated shoppers, and their averaged scores form a dynamic reward that iteratively refines the query — improving fitness by ~22%.

+21.98%mean query fitness over the original user query
+3.36%over a strong Best-of-N LLM-rewrite baseline
1,000 queriesreal Etsy searches · 5 categories · multilingual
r = 0.552agent–human correlation ≈ human–human (0.532)

The problem: evaluating the un-verifiable

LLMs shine on tasks with a checkable answer — code that runs, math that resolves. E-commerce query rewriting has no such gold standard: whether a rewrite truly captures what a shopper meant is subjective and latent. A static reward model or a single LLM-judge is brittle here, and a lone unguided rewrite often lands worse than the user's original query. OptAgent's idea: if you can't verify the answer, simulate the customer — many of them — and let their collective behavior become the reward.

user query q₀ LLM rephrase × N GENERATION 1 · POPULATION rewrite v1 rewrite v2 rewrite v3 rewrite v4 rewrite v5 MULTI-AGENT SIM shopper · T = 0.00 shopper · T = 0.50 … K shoppers score + buy → avg = fitness F(q) 0.62 0.74 0.55 0.71 0.60 ▲ select top-2 as parents CROSSOVER + MUTATION parent A · v2 (0.74) parent B · v4 (0.71) offspring rewrite enters generation 2 ✦ mutation × G generations → best rewrite
The genetic loop, start to finish: the user's query is rephrased into an initial population; the multi-agent shopper simulation scores each candidate into a fitness F(q); the top two are selected as parents; crossover and mutation breed the next generation — repeating for G generations and returning the best rewrite.

The fitness signal: a jury of simulated shoppers

Rather than one judge, OptAgent evaluates a rewrite with an ensemble of K = 5 agents. Each agent submits the query to the real search interface, parses the first page of results (dropping sponsored listings), and for every product weighs the title, description, image, price, rating, first reviews and shipping. It then assigns a relevance score in {−1, 0, +1} — Irrelevant / Partially Relevant / Fully Relevant — and makes an actual purchase decision. Averaging semantic scores across agents, plus a normalized purchase value (with diminishing returns), yields a single continuous fitness F(q).

Temperatures, not personas

A natural way to get diverse judges is to give each a persona — but the paper found personas smuggle in bias: a benign trait can tip an agent into discriminatory scoring (documented as a case study). OptAgent instead diversifies by sampling temperature — the K agents run at {0.00, 0.25, 0.50, 0.75, 1.00} — spreading reasoning paths without injecting a predefined identity. The ensemble tracks people well: it correlates with human annotators at Pearson r = 0.552, essentially the same as annotators agree with each other (r = 0.532) — expected, since the task is genuinely subjective.

The optimizer: a genetic search over rewrites

With a fitness function in hand, OptAgent treats rewriting as evolutionary search. The user's query is rephrased into an initial population (N = 5); each generation, candidates are scored, the top ones become parents, and the next generation is bred by crossover (mixing two parents) and mutation (altering one), for G = 4 generations. Guided search explores the space more effectively than one-shot sampling — best fitness climbs each generation with diminishing returns. Run on Gemini-2.5-Flash.

Results

Evaluated on 1,000 real Etsy queries across five categories, scored by mean fitness. OptAgent wins every category; parenthesized numbers are its gain over the strong Best-of-N baseline:

Query typeUser queryLLM-rewriteBest-of-NOptAgent
Head0.6430.5740.7490.766 (+2.2%)
Torso0.5740.5340.7110.738 (+3.8%)
Tail0.4980.4840.6130.641 (+4.5%)
Fandom0.7330.6340.7760.797 (+2.7%)
Multilingual0.7190.6830.8260.855 (+3.5%)
All queries0.6100.5510.7200.744 (+3.4%)

Two findings stand out. A naive LLM-rewrite often underperforms the original query — an unguided rewrite easily misreads intent — which is exactly why generate-many-then-verify matters. And the biggest gains come on Tail queries (+28.7% over the user's original): rare, data-sparse searches where there's no historical pattern to learn from are where evolutionary exploration helps most. Fandom queries gain least (+8.7%) — franchise searches are already precise.

What each piece contributes

Ablating components on the full dataset shows the evolutionary machinery — not just having a good judge — carries the result:

ConfigurationFitnessΔ vs OptAgent
OptAgent (full framework)0.744
− evolutionary ops (= Best-of-N)0.697−6.4%
− crossover0.699−6.1%
− mutation0.742−0.3%

Crossover does the heavy lifting; mutation is a light touch. And a nice sanity check on realism: like real shoppers, the simulated agents disproportionately buy products ranked near the top of the results — a positional bias the framework reproduces rather than launders away.

Why it matters

OptAgent is a recipe for optimizing against subjective, un-verifiable objectives: replace the missing gold label with a simulation of the humans you're trying to satisfy, make that simulation a fitness function, and let evolutionary search do the rest. Query rewriting is the testbed, but the pattern — many diverse simulated users as a dynamic reward — travels to any setting where "is this actually better?" can't be checked with a formula.

Resources

Paper: arXiv:2510.03771 · work done during an internship at Etsy

AgentsLLMs