Search and Evolution

The previous three chapters established who changes what and which execution results guide the change. The next problem is deciding which candidates to try first and what to try next after observing their results. Small edits to prompts, workflows, and code can change behavior sharply, while evaluation is costly and noisy. This chapter organizes search methods by the order in which they evaluate candidates, the history they retain, and how they allocate the budget.

Best-of-\(N\) as the Baseline

The simplest optimizer independently generates \(N\) candidates and selects the one with the highest development score.

This baseline is important. Even if a complex search algorithm wins, it may simply have used more candidates or tokens. Comparisons should match the following quantities.

  • Number of candidates
  • Proposal tokens per candidate
  • Number of cases used to run each candidate
  • Target model and optimizer model
  • Number of validation queries
  • Wall time with parallel execution

When scores are noisy, simply increasing \(N\) makes it more likely that a candidate with an accidentally high score will be selected. Improvements from Best-of-\(N\) include both artifact quality and selection noise.

Search with History in the Prompt

APE generates instruction candidates from task examples, scores them on a subset, and reselects them (Zhou et al. 2023). OPRO lists past candidates and scores in a meta-prompt and asks an optimizer large language model (LLM) to generate the next candidate (Yang et al. 2024). Rather than using numerical gradients, the LLM reads patterns in the history.

In this approach, the meta-prompt is the search state. Including every past candidate expands the context, while retaining only the top candidates discards the exploration history. Moreover, OPRO’s reported tables include an analysis that presents the instruction with the highest test accuracy under each setting. The method’s search mechanism must be distinguished from its effect size under clean held-out selection.

An LLM that merely generates candidates is not necessarily itself the optimizer. The outer loop that records, evaluates, selects, and stops candidates is the optimizer.

Reducing Evaluation with Predictors

When every candidate cannot be evaluated with a full rollout, a surrogate can predict performance from a small number of evaluations.

MIPRO selects combinations of multi-stage LM programs with Bayesian optimization, while AgentSquare narrows workflow candidates using an in-context performance predictor (Opsahl-Ong et al. 2024; Shang et al. 2025). Selecting solely from predicted values biases search toward the surrogate’s blind spots. Evaluate finalists and high-uncertainty candidates with actual rollouts, and report prediction error as well.

Evolving Candidate Populations

Evolutionary search maintains multiple candidates as a population and repeatedly applies selection, mutation, and crossover.

EvoPrompt uses an LLM as the operator in a genetic algorithm or differential evolution to evolve natural-language instructions (Guo et al. 2024). Promptbreeder coevolves not only task prompts but also the mutation prompts that mutate them (Fernando et al. 2024). This is not general “self-improvement,” but a specific form of prompt evolution based on fixed-task fitness.

The advantage of a population is that exploration is not tied to a single incumbent. On the other hand, repeatedly measuring fitness on the same development set adapts the entire population to that set. Population diversity does not guarantee held-out generalization.

Preserving Multiple Strengths in the History

A single average score can prematurely discard candidates that perform well on specific instances. GEPA retains the union of candidates that perform best on individual validation instances in a Pareto archive and creates reflective mutations from those candidates (Agrawal et al. 2026).

A Pareto archive is not the same as multi-objective acceptance. GEPA’s archive primarily preserves strengths on different instance-level scores. Promoting a candidate that jointly satisfies quality, cost, and safety requires separate evaluation records and an acceptance rule.

Measuring Selection Bias

When many candidates are compared using development scores, the maximum is biased upward because a candidate with an accidentally favorable noise term is increasingly likely to be selected. Selection bias from repeatedly reusing the same data for model selection has long been recognized (Cawley and Talbot 2010).

The remedy is not simply to use more seeds.

  • Create proposals on development data
  • Select the promotion candidate on validation data and record the number of queries
  • Finalize the finalists before evaluating the sealed test once
  • Reevaluate the incumbent with the same seeds and case runs
  • Compare against a Best-of-\(N\) baseline under the same budget
  • Report the distribution of candidate scores, not only the average

If a public leaderboard is used repeatedly as validation, its score is search feedback. It cannot be called the final test.

Stopping Rules

When search ends “once improvement stops,” the relevant question is which set defines improvement. Repeatedly checking a validation plateau adapts the stopping point itself to validation.

Fix one of the following in advance.

  • Number of candidate evaluations
  • Number of case runs
  • Target / optimizer token budget
  • Wall-clock budget
  • Number of validation queries
  • Improvement threshold and patience
  • Reaching a safety or cost limit

If no significant candidate emerges before the budget is exhausted, retain the incumbent. “Always adopt the best candidate” is not a stopping rule.

Key Points

Search methods differ not in whether they use an LLM, but in their search state, proposal operator, evaluation budget, selection, and archive. Compare Best-of-\(N\), local/beam, tree, surrogate, population, Pareto, and code-archive methods under the same budget and held-out protocol. Populations and archives preserve diversity during search, but do not automatically guarantee generalization or regression-free promotion.

References

Agrawal, Lakshya A., Shangyin Tan, Dilara Soylu, et al. 2026. GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning.” International Conference on Learning Representations. https://arxiv.org/abs/2507.19457.
Cawley, Gavin C., and Nicola L. C. Talbot. 2010. “On over-Fitting in Model Selection and Subsequent Selection Bias in Performance Evaluation.” Journal of Machine Learning Research 11: 2079–107. https://jmlr.org/papers/v11/cawley10a.html.
Fernando, Chrisantha, Dylan Sunil Banarse, Henryk Michalewski, Simon Osindero, and Tim Rocktäschel. 2024. “Promptbreeder: Self-Referential Self-Improvement via Prompt Evolution.” Proceedings of the 41st International Conference on Machine Learning, 13481–544. https://proceedings.mlr.press/v235/fernando24a.html.
Guo, Qingyan, Rui Wang, Junliang Guo, et al. 2024. EvoPrompt: Connecting LLMs with Evolutionary Algorithms Yields Powerful Prompt Optimizers.” International Conference on Learning Representations. https://arxiv.org/abs/2309.08532.
Hu, Shengran, Cong Lu, and Jeff Clune. 2025. “Automated Design of Agentic Systems.” International Conference on Learning Representations. https://arxiv.org/abs/2408.08435.
Opsahl-Ong, Krista, Michael J. Ryan, Josh Purtell, et al. 2024. “Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programs.” Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing. https://aclanthology.org/2024.emnlp-main.525/.
Pryzant, Reid, Dan Iter, Jerry Li, Yin Lee, Chenguang Zhu, and Michael Zeng. 2023. “Automatic Prompt Optimization with ‘Gradient Descent’ and Beam Search.” Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, 7957–68. https://doi.org/10.18653/v1/2023.emnlp-main.494.
Shang, Yu, Yu Li, Keyu Zhao, et al. 2025. AgentSquare: Automatic LLM Agent Search in Modular Design Space.” International Conference on Learning Representations. https://arxiv.org/abs/2410.06153.
Yang, Chengrun, Xuezhi Wang, Yifeng Lu, et al. 2024. “Large Language Models as Optimizers.” International Conference on Learning Representations. https://arxiv.org/abs/2309.03409.
Yuksekgonul, Mert, Federico Bianchi, Joseph Boen, et al. 2025. “Optimizing Generative AI by Backpropagating Language Model Feedback.” Nature 639: 609–16. https://doi.org/10.1038/s41586-025-08661-4.
Zhang, Jenny, Shengran Hu, Cong Lu, Robert Lange, and Jeff Clune. 2026. “Darwin Gödel Machine: Open-Ended Evolution of Self-Improving Agents.” International Conference on Learning Representations. https://arxiv.org/abs/2505.22954.
Zhang, Jiayi, Jinyu Xiang, Zhaoyang Yu, et al. 2025. AFlow: Automating Agentic Workflow Generation.” International Conference on Learning Representations. https://arxiv.org/abs/2410.10762.
Zhou, Yongchao, Andrei Ioan Muresanu, Ziwen Han, et al. 2023. “Large Language Models Are Human-Level Prompt Engineers.” International Conference on Learning Representations. https://arxiv.org/abs/2211.01910.