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

Divij Handa, David Blincoe, Orson Adams, Yinlin Fu · DOI

Abstract

OptAgent is a novel framework designed to enhance e-commerce search by treating query rewriting as an evolutionary optimization problem. By leveraging a multi-agent simulation of diverse shoppers, the system generates a dynamic fitness signal that guides a genetic algorithm to iteratively refine search terms. Our evaluation on real-world e-commerce data demonstrates that OptAgent improves product relevance by nearly 22% compared to original user queries, outperforming standard LLM baselines and showing strong alignment with human judgment.

Introduction

In the realm of e-commerce, search performance is often hindered by the quality of user-provided queries. Shoppers frequently use underspecified, ambiguous, or error-prone terms—such as searching for an author's name when they intend to find specific genres of books. Query Rewriting (QR) serves as a critical bridge, translating these inputs into optimized search terms.

However, optimizing QR is notoriously difficult. Unlike objective tasks like mathematical reasoning, search relevance is highly subjective. Traditional methods like Reinforcement Learning from Human Feedback (RLHF) are prohibitively expensive at scale, while using a single Large Language Model (LLM) as a judge often introduces systematic biases. OptAgent addresses these challenges by simulating a diverse population of "shoppers" to evaluate query effectiveness.

Methods

The OptAgent framework integrates Genetic Algorithms (GAs) with Multi-Agent Simulation to iteratively evolve search queries.

Overview of the OptAgent framework for e-commerce query rewriting.

The process follows a four-stage evolutionary loop:

  1. Initial Population Generation: An LLM generates an initial set of diverse rewrites for the user's query.
  2. Multi-Agent Evaluation: To avoid the biases inherent in fixed "personas," OptAgent employs five LLM agents with varying sampling temperatures (0.0 to 1.0). These agents simulate the shopping process, scoring search results based on relevance and purchase intent.
  3. Genetic Policies:
    • Selection: High-performing queries are retained for the next generation.
  4. Crossover: A specialized agent synthesizes new queries by merging successful elements from two parent queries.
  5. Mutation: Small semantic tweaks are introduced to explore new query variations.
  6. Iterative Update: The cycle repeats, progressively refining the query's fitness.

Experimental Setup

The framework was tested on a dataset of 1,000 real-world queries from Etsy, categorized into Head (popular), Torso/Tail (rare), Fandom, and Multi-Lingual segments. This diversity ensures the model's robustness across different search behaviors and languages, including German, French, and Spanish.

Key Results

OptAgent achieved a significant 21.98% improvement in query fitness over original user inputs. It also outperformed a "Best-of-N" LLM baseline by 3.36%, indicating that the evolutionary process is more effective than simple random sampling.

Average fitness improvement across four generations for various query categories.

As shown in the figure above, fitness scores improved consistently across four generations. Notably, the system excelled at "Tail" queries, showing a 28.67% improvement. This is particularly valuable for e-commerce platforms, as tail queries often lack the historical click data required for traditional optimization.

Discussion and Insights

A key finding of the study is the superiority of temperature-based diversity over persona-based diversity. The authors observed that assigning specific personas to agents (e.g., "tech founder") introduced unintended demographic and geographic biases. In contrast, varying the LLM's temperature provided a "cleaner" diversity of reasoning paths.

Furthermore, ablation studies revealed that the Crossover operation is the primary driver of performance, contributing significantly more than Mutation. This suggests that LLMs are highly effective at recombining successful search strategies. Finally, the agent-derived scores showed a Pearson correlation of 0.552 with human expert judgments, confirming that the simulation effectively mirrors real-world preferences.

Limitations and Future Work

Despite its success, OptAgent faces practical challenges. The computational cost—approximately $8 per query—makes it unsuitable for real-time deployment. Instead, it is best utilized for offline optimization or as a source of high-quality synthetic data for training smaller, more efficient models. Additionally, agents currently struggle with interactive UI elements and may exhibit a "cold start" bias toward products with existing reviews. Future research will focus on distilling these simulation-based insights into real-time production models.

Summary updated

BibTeX
@misc{handa2025optagent,
  author = {Divij Handa and David Blincoe and Orson Adams and Yinlin Fu},
  title = {{OptAgent: Optimizing Query Rewriting for E-commerce via Multi-Agent Simulation}},
  year = {2025},
  eprint = {2510.03771},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.03771},
}
Figure