Everything K-culture — comebacks to K-beauty, straight to your inboxGet it in your inbox›
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
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.
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.
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.
Emergent search behaviorsDouble-verification, reuse of past failures, reverting from unproductive branches, and adaptive exploration all appear without being hard-coded into any controller.
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
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.
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.
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.
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.
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.
Table 1: Performance on test sets before and after system prompt optimization.
AIME ↑
GSM8K ↑
HotpotQA ↑
Terminal-Bench 2.0 ↑
Baseline
46.00 ± 1.33
81.20 ± 0.38
63.00 ± 1.50
35.56 ± 1.48
GEPA
50.67 ± 1.15
82.11 ± 0.45
65.80 ± 0.80
42.22 ± 1.28
ReASearch
52.00 ± 0.67
83.40 ± 0.30
67.60 ± 0.50
53.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.
Table 2: Circle Packing Results
Algorithm
Model
n=23 ↑
n=24 ↑
n=25 ↑
n=26 ↑
n=27 ↑
n=28 ↑
n=29 ↑
n=30 ↑
n=31 ↑
n=32 ↑
Best known (human)
2.478
2.530
2.587
2.635
2.685
2.737
2.790
2.842
2.889
2.939
AdaEvolve
GPT-5
2.406
2.528
2.569
2.610
2.654
2.641
2.659
2.750
2.781
2.707
Sonnet 4.6
2.478
2.433
2.587
2.630
2.576
2.623
2.786
2.843
2.887
2.810
ReASearch
GPT-5
2.471
2.528
2.572
2.623
2.683
2.687
2.779
2.780
2.683
2.938
Sonnet 4.6
2.478
2.530
2.587
2.636
2.684
2.735
2.790
2.843
2.890
2.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.
Table 3: Heilbronn Triangle Results
Algorithm
Model
n=11 ↑
n=12 ↑
n=13 ↑
n=14 ↑
n=15 ↑
Best known (human)
0.03704
0.03260
0.02702
0.02430
0.02111
AdaEvolve
GPT-5
0.02923
0.03100
0.02229
0.01606
0.01770
Sonnet 4.6
0.02629
0.02552
0.02142
0.00299
0.00984
ReASearch
GPT-5
0.03539
0.03142
0.02466
0.02260
0.01903
Sonnet 4.6
0.03552
0.03260
0.02700
0.02429
0.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.
Table 4: Systems Programming Results (TXN and EPLB)
Algorithm
Model
TXN ↑
EPLB ↑
GEPA
GPT-5
3984
0.1445
Shinka
GPT-5
4329
0.1272
AdaEvolve
GPT-5
3636
0.1976
Sonnet 4.6
4292
0.1441
ReASearch
GPT-5
4237
0.2305
Sonnet 4.6
4032
0.1471
Figure 5: Tool call frequency statistics for each category.
Table 6: Model training tasks.
Method
NanoGPT ↓
IMG-100 ↑
Atari (Q*bert) ↑
MuJoCo ↑
Crypto ↑
Baseline
0.998 ± 0.006
63.51 ± 0.85
475 ± 90
1537 ± 220
0.0953 ± 0.0021 (rank 36)
Claude Code
0.974 ± 0.010
78.59 ± 1.40
1250 ± 180
3986 ± 410
0.0999 ± 0.0028 (rank 29)
ReASearch
0.976 ± 0.008
83.99 ± 1.10
4500 ± 320
5267 ± 480
0.1110 ± 0.0024 (rank 6)
Figure 6: Comparison with GEPA on Terminal-Bench validation accuracy.
Table 7: Component ablation on prompt optimization.
Method
AIME ↑
Terminal-Bench 2.0 ↑
Baseline
46.00
35.56
GEPA
50.67
42.22
ReASearch
52.00
53.33
ReASearch w/o memory
49.33
48.15
ReASearch w/o Python tools
51.33
51.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.
Table 8: Component ablation on ARC-AGI-2 program evolution.
Method
Train acc ↑
Test acc ↑
AdaEvolve
21.9%
12.5%
ReASearch
85.0%
50.0%
ReASearch w/o memory
60.0%
39.2%
ReASearch w/o Python tools
51.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.
Method
AIME ↑
HotpotQA ↑
Terminal-Bench 2.0 ↑
Baseline
46.00 ± 1.33
63.00 ± 1.50
3.00 ± 0.74
GEPA
50.67 ± 1.15
65.80 ± 0.80
—
ReASearch w/ Claude Sonnet 4.6
52.00 ± 0.67
67.60 ± 0.50
23.00 ± 2.27
ReASearch w/ GLM-5
51.33 ± 1.15
67.20 ± 0.90
14.81 ± 4.07
ReASearch w/ Kimi-2.5
50.67 ± 0.94
66.80 ± 1.00
8.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.
Method
NanoGPT ↓
IMG-100 ↑
Atari (Q*bert) ↑
MuJoCo ↑
Crypto ↑
Baseline
0.998 ± 0.006
63.51 ± 0.85
475 ± 90
1537 ± 220
0.0953 ± 0.0021
ReASearch w/ Claude
0.976 ± 0.008
83.99 ± 1.10
4500 ± 320
5267 ± 480
0.1110 ± 0.0024
ReASearch w/ GLM-5
0.979 ± 0.009
82.80 ± 1.25
4100 ± 380
4920 ± 510
0.1085 ± 0.0030
ReASearch w/ Kimi-2.5
0.981 ± 0.010
82.10 ± 1.35
3900 ± 420
4740 ± 540
0.1076 ± 0.0033
Table 11: Component ablation on Heilbronn triangle program evolution. The objective is the minimum triangle area; higher is better.
Method
n=11 ↑
n=12 ↑
n=13 ↑
n=14 ↑
n=15 ↑
Best known (human)
0.03704
0.03260
0.02702
0.02430
0.02111
AdaEvolve
0.02629
0.02552
0.02142
0.00299
0.00984
ReASearch
0.03552
0.03260
0.02700
0.02429
0.02034
ReASearch w/o memory
0.03241
0.02938
0.02371
0.02064
0.01617
ReASearch w/o Python tools
0.03387
0.02862
0.02497
0.01892
0.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.