Everything K-culture — comebacks to K-beauty, straight to your inboxGet it in your inbox

METAL MEDIA

The Optimizer Is the Agent: Reasoning-Driven Search across Prompts, Programs, and ML Workflows

arXiv:2608.067142026-08-10

An LLM agent alone, with no outside search algorithm, out-optimizes specialized tools for prompts, code, and ML training

Existing systems for optimizing prompts, programs, and ML workflows rely on external controllers such as evolutionary search, bandits, or textual-gradient methods that decide what to try next, leaving the LLM to just propose local edits. ReASearch removes that outer controller and gives a single tool-using agent full control over what to evaluate, how to diagnose failures, and when to revert. Across 14 tasks it beats specialized optimization systems by 2% to 40%, and on Circle Packing it finds solutions that surpass the prior best-known human results.

METAL MEDIA explanatory visual

Removing the outer controller: letting the agent internalize the whole search policy

Evidence statusMeasured results reported

  1. Prior approachAn external controller (evolutionary search, bandits, textual-gradient methods) decides which candidate to branch from and how to allocate budget; the LLM only supplies local edits.
  2. ReASearch agent loopThe same code agent, equipped with file I/O, Python/Bash execution, and a persistent memory file (lessons.md), decides at every turn which tool to invoke next.
  3. Domain-specific toolsPrompt optimization uses get_next_minibatch, call_student_model_batch, validate_candidate; program evolution uses edit_code and evaluate; ML workflow uses edit_train_file and run_experiment.
  4. Emergent search behaviorsDouble-verification, reuse of past failures, reverting from unproductive branches, and adaptive exploration all appear without being hard-coded into any controller.
  5. Head-to-head comparisonsAgainst GEPA, AdaEvolve, and Claude Code under matched budgets, ReASearch gains 2% to 40%, and in some tasks surpasses prior human best-known results.
An explanatory diagram made by METAL MEDIA, not a figure supplied by the paper's authors.

What they did

  1. Prompt optimization, program evolution, and ML workflow optimization are handled with the exact same agent loop and shared machinery (evaluation tools, code editing, Python execution, persistent memory), only the domain-specific tools and system prompt change.
  2. Instead of an external search algorithm, the agent itself decides when to evaluate, which edits to make, whether to verify, and when to revert to an earlier candidate, guided only by a system prompt and a toolset.
  3. A python_exec tool lets the agent run scripts to statistically analyze evaluation logs and find failure patterns on its own, while a persistent lessons.md file accumulates what worked and what failed across long optimization runs.
  4. The framework was tested on 14 tasks: AIME, HotpotQA, GSM8K, and Terminal-Bench 2.0 for prompts; Circle Packing, Heilbronn triangles, transaction scheduling, EPLB, and ARC-AGI-2 for program evolution; NanoGPT, IMG-100, Atari, MuJoCo, and a Kaggle crypto prediction task for ML workflows.
  5. Comparisons were made under matched budgets against strong existing baselines in each domain: GEPA for prompts, AdaEvolve for program evolution, and Claude Code's official AutoResearch setup for ML workflows.
Figure 1: Positioning ReASearch relative to existing methods.
Figure 1: Positioning ReASearch relative to existing methods.
Table 1: Performance on test sets before and after system prompt optimization.
AIME ↑GSM8K ↑HotpotQA ↑Terminal-Bench 2.0 ↑
Baseline46.00 ± 1.3381.20 ± 0.3863.00 ± 1.5035.56 ± 1.48
GEPA50.67 ± 1.1582.11 ± 0.4565.80 ± 0.8042.22 ± 1.28
ReASearch52.00 ± 0.6783.40 ± 0.3067.60 ± 0.5053.33 ± 1.96
Figure 2: Prior methods use LLMs primarily as mutators, with candidate selection and optimization goals determined by external heuristic algorithms. In contrast, ReASearch exposes the entire optimization process through tools, giving the agent full control over the search procedure and enabling it to solve a wide range of tasks.
Figure 2: Prior methods use LLMs primarily as mutators, with candidate selection and optimization goals determined by external heuristic algorithms. In contrast, ReASearch exposes the entire optimization process through tools, giving the agent full control over the search procedure and enabling it to solve a wide range of tasks.
Table 2: Circle Packing Results
AlgorithmModeln=23 ↑n=24 ↑n=25 ↑n=26 ↑n=27 ↑n=28 ↑n=29 ↑n=30 ↑n=31 ↑n=32 ↑
Best known (human)2.4782.5302.5872.6352.6852.7372.7902.8422.8892.939
AdaEvolveGPT-52.4062.5282.5692.6102.6542.6412.6592.7502.7812.707
Sonnet 4.62.4782.4332.5872.6302.5762.6232.7862.8432.8872.810
ReASearchGPT-52.4712.5282.5722.6232.6832.6872.7792.7802.6832.938
Sonnet 4.62.4782.5302.5872.6362.6842.7352.7902.8432.8902.940
Figure 3: We visualize an example agent trajectory for prompt optimization, highlighting automatic verification and final prompt selection. None of this process is hardcoded; it emerges from the guiding instruction, with agents freely deciding each next step.
Figure 3: We visualize an example agent trajectory for prompt optimization, highlighting automatic verification and final prompt selection. None of this process is hardcoded; it emerges from the guiding instruction, with agents freely deciding each next step.
Table 3: Heilbronn Triangle Results
AlgorithmModeln=11 ↑n=12 ↑n=13 ↑n=14 ↑n=15 ↑
Best known (human)0.037040.032600.027020.024300.02111
AdaEvolveGPT-50.029230.031000.022290.016060.01770
Sonnet 4.60.026290.025520.021420.002990.00984
ReASearchGPT-50.035390.031420.024660.022600.01903
Sonnet 4.60.035520.032600.027000.024290.02034
Figure 4: Program evolution and ML workflow optimization exhibit similar patterns: the agent actively uses Python for reasoning and small-scale experiments before running expensive evaluations, while delegating targeted code edits to a separate agent to keep the main agent’s context clean.
Figure 4: Program evolution and ML workflow optimization exhibit similar patterns: the agent actively uses Python for reasoning and small-scale experiments before running expensive evaluations, while delegating targeted code edits to a separate agent to keep the main agent’s context clean.
Table 4: Systems Programming Results (TXN and EPLB)
AlgorithmModelTXN ↑EPLB ↑
GEPAGPT-539840.1445
ShinkaGPT-543290.1272
AdaEvolveGPT-536360.1976
Sonnet 4.642920.1441
ReASearchGPT-542370.2305
Sonnet 4.640320.1471
Figure 5: Tool call frequency statistics for each category.
Figure 5: Tool call frequency statistics for each category.
Table 6: Model training tasks.
MethodNanoGPT ↓IMG-100 ↑Atari (Q*bert) ↑MuJoCo ↑Crypto ↑
Baseline0.998 ± 0.00663.51 ± 0.85475 ± 901537 ± 2200.0953 ± 0.0021 (rank 36)
Claude Code0.974 ± 0.01078.59 ± 1.401250 ± 1803986 ± 4100.0999 ± 0.0028 (rank 29)
ReASearch0.976 ± 0.00883.99 ± 1.104500 ± 3205267 ± 4800.1110 ± 0.0024 (rank 6)
Figure 6: Comparison with GEPA on Terminal-Bench validation accuracy.
Figure 6: Comparison with GEPA on Terminal-Bench validation accuracy.
Table 7: Component ablation on prompt optimization.
MethodAIME ↑Terminal-Bench 2.0 ↑
Baseline46.0035.56
GEPA50.6742.22
ReASearch52.0053.33
ReASearch w/o memory49.3348.15
ReASearch w/o Python tools51.3351.11
Figure 7: Performance and token usage across experiments. For Claude Code, token usage is only available at the end of the optimization run, so we plot it as a linear trajectory.
Figure 7: Performance and token usage across experiments. For Claude Code, token usage is only available at the end of the optimization run, so we plot it as a linear trajectory.
Table 8: Component ablation on ARC-AGI-2 program evolution.
MethodTrain acc ↑Test acc ↑
AdaEvolve21.9%12.5%
ReASearch85.0%50.0%
ReASearch w/o memory60.0%39.2%
ReASearch w/o Python tools51.67%32.5%
Table 9: Open-source backbones on prompt optimization. The AIME and HotpotQA rows for the baseline and ReASearch w/ Claude Sonnet 4.6 match Table 1; the Terminal-Bench 2.0 column here uses GPT-OSS-120B as the student model (rather than GPT-5), so its values differ from Table 1 and are not directly comparable. GLM-5 and Kimi-2.5 are added.
MethodAIME ↑HotpotQA ↑Terminal-Bench 2.0 ↑
Baseline46.00 ± 1.3363.00 ± 1.503.00 ± 0.74
GEPA50.67 ± 1.1565.80 ± 0.80
ReASearch w/ Claude Sonnet 4.652.00 ± 0.6767.60 ± 0.5023.00 ± 2.27
ReASearch w/ GLM-551.33 ± 1.1567.20 ± 0.9014.81 ± 4.07
ReASearch w/ Kimi-2.550.67 ± 0.9466.80 ± 1.008.15 ± 3.39
Table 10: Open-source backbones on ML workflow optimization. The baseline and ReASearch w/ Claude rows match Table 6; GLM-5 and Kimi-2.5 are added.
MethodNanoGPT ↓IMG-100 ↑Atari (Q*bert) ↑MuJoCo ↑Crypto ↑
Baseline0.998 ± 0.00663.51 ± 0.85475 ± 901537 ± 2200.0953 ± 0.0021
ReASearch w/ Claude0.976 ± 0.00883.99 ± 1.104500 ± 3205267 ± 4800.1110 ± 0.0024
ReASearch w/ GLM-50.979 ± 0.00982.80 ± 1.254100 ± 3804920 ± 5100.1085 ± 0.0030
ReASearch w/ Kimi-2.50.981 ± 0.01082.10 ± 1.353900 ± 4204740 ± 5400.1076 ± 0.0033
Table 11: Component ablation on Heilbronn triangle program evolution. The objective is the minimum triangle area; higher is better.
Methodn=11 ↑n=12 ↑n=13 ↑n=14 ↑n=15 ↑
Best known (human)0.037040.032600.027020.024300.02111
AdaEvolve0.026290.025520.021420.002990.00984
ReASearch0.035520.032600.027000.024290.02034
ReASearch w/o memory0.032410.029380.023710.020640.01617
ReASearch w/o Python tools0.033870.028620.024970.018920.01753

Findings

  • On four prompt optimization tasks (AIME, HotpotQA, GSM8K, Terminal-Bench 2.0), ReASearch consistently beat GEPA on test-set performance under the same number of student-model calls.
  • On program evolution tasks (Circle Packing, Heilbronn triangles, transaction scheduling, EPLB, ARC-AGI-2), ReASearch outperformed AdaEvolve on nearly all tasks under matched evaluation budgets, in some cases exceeding prior human best-known results.
  • On EPLB, the agent broke a 120-turn plateau stuck at score ~0.21 by diagnosing an overly restrictive donor constraint, raising the score to 0.23; AdaEvolve (Sonnet) plateaued 61% lower over 272 consecutive iterations.
  • On Heilbronn n=12, the agent formalized an observed 8-fold symmetry into a mathematical constraint solved to 50-digit precision; AdaEvolve achieved only 78% (n=12) and 12% (n=14) of that quality.
  • In ML workflow optimization, ReASearch was statistically indistinguishable from Claude Code on NanoGPT (0.976 ± 0.008 vs. 0.974 ± 0.010) but outperformed it with far fewer tokens on IMG-100, Atari, MuJoCo, and crypto prediction, improving the crypto Kaggle leaderboard rank from 36th to 6th within 15 experiments.

Where it can be used

  • Automating iterative system-prompt engineering without building a separate outer search algorithm.
  • Tackling single hard combinatorial or scheduling problems that require repeated trial-and-error and accumulated lessons, such as geometric packing or systems-programming optimization.
  • Tuning ML training pipelines (hyperparameters, architecture, loss design) under a limited experiment budget where reasoning about training curves matters.

Limits and open work

  • The 14 evaluated tasks are limited to specific domains (math reasoning, QA, terminal tasks, geometric optimization, systems programming, puzzle induction, and a handful of ML training settings), so generalization to other task types is untested.
  • Each domain still requires a custom toolset (e.g., get_next_minibatch, edit_code, run_experiment), so the system is not fully domain-agnostic despite sharing an agent loop.
  • Efforts were made to match budgets against GEPA, AdaEvolve, and Claude Code, but differences in backbone models and API costs are not perfectly controlled.
  • Some results are averages over only 3 independent runs per setting, reported without formal statistical significance testing.

Why it matters

It suggests that the complex outer-loop search logic hand-built into today's prompt/code/ML optimization tools can instead be internalized by an LLM agent's own reasoning, given the right tools and memory. That reframes how future optimization tools might be built: less hand-coded control flow, more capable agent scaffolding.

Terms in this paper

  • outer-loop controller · An external search algorithm (evolutionary search, bandits, textual-gradient methods) that decides what to try and when to stop, sitting outside the LLM
  • python_exec · A tool that lets the agent run Python code directly to analyze evaluation results or compute statistics
  • lessons.md · A persistent memory file the agent writes to itself, recording lessons about what worked and what failed during a run
  • AdaEvolve · A prior program-evolution baseline that samples discrete strategy labels, generates code for each, and picks the best; used as a comparison system

Original abstract (English)

Recent systems for optimizing prompts, programs, and ML workflows typically rely on explicit outer-loop controllers such as evolutionary search, bandits, or textual-gradient methods. We ask a fundamentally different question: how much of this search policy can be internalized by a single tool-using agent? We present ReASearch, a unified framework for reasoning-driven optimization in which the agent autonomously decides what to evaluate, how to diagnose failures, which edits to make, and when to verify or restart. Rather than serving only as a proposal generator guided by hand-designed heuristics, the agent actively analyzes outcomes, allocates budget, and refines its strategy over long horizons through persistent memory. With a shared agent loop and domain-specific tools, ReASearch instantiates the exact same scaffold to optimize prompts, programs, and ML workflows. Across 14 diverse tasks, it is competitive with and mostly better than specialized optimization systems, achieving gains of 2% to 40% over strong domain-specific baselines, and in some cases discovering solutions that improve on prior human best-known results. Crucially, we observe that complex search behaviors, which are typically implemented by explicit controllers, emerge naturally from the agent's reasoning process.

Authors · Junbo Li, Boyi Liu, Canwen Xu, Yite Wang, Yuxiong He, Zhangyang Wang, Qiang Liu, Zhewei Yao

Read on arXiv

Latest papers

All papers →

Latest from METAL MEDIA

Figures: Junbo Li et al., arXiv:2608.06714, CC BY 4.0