Abstract
LLMs are being increasingly integrated into systems that support queries
over unstructured data~\cite{shankar2025docetl, patel2025semantic, liu2024declarative}.
In these LLM-powered data processing systems, a query is expressed
as a sequence of familiar data processing operators
such as map, reduce, and filter, each described in natural language for an LLM to carry out,
with the system's optimizer determining the plan to execute.
In this paper, we design a new optimizer to extend the rewrite directive approach to multi-objective optimization.
We introduce the Multi-Objective Agentic Rewrites (MOAR) optimizer, which surfaces a Pareto frontier of pipelines that improve accuracy over the user's original while offering a range of costs---all under a limited evaluation budget (dozens of pipelines).
We model the search space of pipelines (i.e., query plans) as a graph where each node is a complete pipeline and each edge applies a rewrite to produce a new one.
Our insight is to apply a multi-armed bandit approach to searching the graph of rewrite sequences: at each iteration, MOAR must decide which pipeline to expand and which rewrite to apply, balancing exploration of new rewrite sequences against exploitation of promising ones.
We evaluate MOAR on six real-world workloads spanning legal, medical, and enterprise domains. Compared to state-of-the-art systems and naive agentic baselines,
MOAR achieves up to 1136.4\% higher output quality and 84\% lower inference cost at equivalent quality levels, while surfacing a richer set of trade-off plans for users.