Manuscript Offprint

arXiv:2610.09215

AGAR: a reinforcement learning substrate for LLM program evolution

Haoran Li, Zengle Ge, Xiaomin Yuan, Yui Lo, Haoxin Li, Songlin Zhou, Qianhui Liu, Jiahua Ying, Yuanhang Liu, Mingju Chen, Annan Li, Jianmin Wu, Dawei Yin, Dou Shen

ABSTRACT

Given a task and an evaluator, a language model can rewrite a candidate program while a search loop decides which rewrites survive — a practical route to algorithm discovery. But that loop is governed by five constants set by hand — which parent to select, how hard to mutate, how to keep diversity, what to remember, and a scalar score that never says which part of the program earned it — and reinforcement learning already has an estimator for each. The obstacle is that program evolution is not usually written down as a decision process. We formalize it as a Markov decision process whose action is the modular prefix the model is conditioned on, not the program it emits, so that credit assignment, value estimation, adaptive exploration and experience memory each attach to a distinct component. AGAR (Algorithm Generation As RL) provides the substrate this licenses: any estimator can be replaced or switched off without touching the controller, making the transfer auditable one mechanism at a time, with no gradient training of the backend model. Across 19 tasks, two backends and three seeds under one harness, AGAR improves on the stronger of two published baselines on most tasks, with the gains concentrated on the competitive-programming family. The formalization also yields a checkable reading of prior work: these systems are implicitly zero-discount, not by choice but because fitness is exogenous to an individual rather than a return over successors, leaving a discount factor nothing to act on.

1 INTRODUCTION

A long-horizon algorithm optimization task — find a program that scores well on a task-specific evaluator, given a budget of iterations and no gradient of the score with respect to the program text — is a sequential decision problem. It is usually not written down as one. It is written down as an evolutionary loop: maintain a population of programs, ask a language model to mutate or recombine them, evaluate the offspring, keep what scores well, repeat (Romera-Paredes et al., 2024; Novikov et al., 2025; Lange et al., 2025; Sharma, 2025). The results are real: improved bounds on open combinatorial problems, faster kernels, better heuristics.

The thesis. We take the position that such a task can be modelled as an RL problem, and that doing so is not a re-labelling exercise: the modelling choices determine which machinery is applicable, and the machinery then determines the system. Concretely, we formalize the loop as an MDP whose action is the modular prefix the model is conditioned on — not the program it emits — and we show that under that choice each load-bearing idea of modern RL (Sutton & Barto, 2018) attaches to a distinct component of the loop. M1M_{1} (credit assignment), M2M_{2} (value estimation), M3M_{3} (adaptive exploration) and M4M_{4} (experience memory) are the places the modelling says the estimators go. We are deliberate about the strength of that claim: the formalization forces which kinds of estimator the objective requires and whether each is an action factor or retrieved context, but it does not force that there are four of them, and the boundaries we draw between M1M_{1}, M2M_{2} and M3M_{3} are a factorization we chose rather than one the mathematics uniquely picks out. What we contribute is a general evolutionary substrate that carries this decomposition: an interface in which any one of the estimators can be replaced or switched off without touching the controller, so that the transfer is auditable one mechanism at a time.

The gap and the obstacle. What the LLM contributes today is the mutation operator. Everything that decides where to mutate, how hard, and what to remember is a hand-set constant: five decisions, each with an estimator RL already has. The obstacle is not reward density — RL routinely operates under terminal-only reward, and LLM-driven program evolution does receive intermediate signal which the mutation operator consumes. The real difference is structural. In RL the value of a state is defined recursively over its successors, so terminal credit is propagable in principle. In evolution, fitness is an exogenous property of an individual; no Bellman equation relates a parent's fitness to its children's, so there is no recursion to propagate along at all. We make this precise in §2.1. The formalization below makes the recursion definable over the search without claiming to make the backup empirical: the value it recurses on is estimated in text space rather than learned from observed returns, and that boundary stays exactly where it is.

A checkable reading of prior work. Because the action is a prefix conditioning a frozen black-box model, the objective is J(π)=E[∑tγtrt]+λH(π)J(\pi) = \mathbb{E}[\sum_t \gamma^t r_t] + \lambda H(\pi). Setting γ=0\gamma=0 recovers the selection rule every system in this literature uses (Observation 1): immediate fitness plus a population entropy term. This is not a metaphor but a degeneracy — and not a criticism, since without a recursion a discount factor has nothing to act on. Making the recursion definable is what turns γ\gamma into a tunable knob.

A substrate, not a system. The substrate ( §5§5) carries the transfer: interchangeable modules, interchangeable execution backends, native asynchrony. Its engineering problems are those of asynchronous RL post-training stacks (Luo et al., 2025; Zhu et al., 2025; miles Contributors, 2025; Hou et al., 2026); the optimand differs (text, not weights) and there is no gradient.

References (38)

  • Finite-time analysis of the multiarmed bandit problem
  • On upper-confidence bound policies for switching bandit problems
  • Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor
  • Single-rollout asynchronous optimization for agentic reinforcement learning (opens arXiv in a new tab)
  • SMCEvolve: Principled scientific discovery via sequential Monte Carlo evolution (opens arXiv in a new tab)
  • ShinkaEvolve: Towards open-ended and sample-efficient program evolution (opens arXiv in a new tab)
  • EvoX: Meta-evolution for automated discovery (opens arXiv in a new tab)
  • Agent Lightning: Train ANY AI agents with reinforcement learning (opens arXiv in a new tab)
  • Nature, 518:529–533, 2015
  • AlphaEvolve: A coding agent for scientific and algorithmic discovery
  • Mathematical discoveries from program search with large language models
  • Prioritized experience replay
  • DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models
  • Reinforcement Learning: An Introduction
  • differentiation (opens arXiv in a new tab)
  • slime: An LLM post-training framework for RL scaling
  • The authors used an LLM-based assistant for implementation and analysis support: refactoring module code, writing the experiment submission and result-aggregation scripts, computing the summary statistics reported in §6.3 from the raw run artifacts, and revising LaTeX prose
  • Table 1 reports the normalised mean across all 19 tasks per condition (each task score divided by the per-task maximum, then averaged); per-task raw scores and the full two-backend detail are in Appendix D.10
  • The saturation criterion — all four conditions within 1% — was applied before ranks were inspected, and the tasks it excludes are marked in Table 1
  • Baseline numbers are obtained by us running OpenEvolve and ShinkaEvolve under our own evaluation protocol, with task specifications ported by us, rather than copied from the cited papers
  • Every generated program is executed in a sandboxed evaluation environment and none is deployed
  • a read-only context (the experiment-level world — population snapshot, configuration, accessors) and a writable result (the per-rollout trajectory)
  • a component's identity is which field of $a_{t}$ it writes
  • First, $M_3$ is the only module that writes result.selection: it is the sole Actor, while $M_2$ writes a ranking and never a decision
  • $M_3$ depends on $M_2$'s ranking; $M_1$ and $M_2$ are mutually independent and could in principle run concurrently, but the implementation does not do this and we do not claim it
  • Median per-rollout wall-clock time ranges from 269 s (eplb) to 1007 s (ahc016), a $3.7\times$ spread; this is the straggler profile that motivates streaming dispatch (§5.2)
  • The criterion is that all four conditions fall within $1\%$, and it was applied before ranks were inspected
  • The last column is the fraction of rollouts that exceed the naive bound $W - 1$
  • Against a median rollout time of several hundred seconds this biases the measured distribution negligibly, but it is a measurement convention rather than an exact observable and we state it as such
  • $\tau$ is written to the run log but is not threaded into $M_2$'s statistics, so the per-rollout correspondence between the two quantities is not available
  • One update cycle is
  • \tag {4} $$
  • the loss node is the evaluator's score, the intermediate nodes are the module outputs that conditioned the candidate, and the leaf being optimized is $\theta_i$
  • It is not trained against realized descendant fitness, so the $\gamma V_{M_2}$ term carries whatever bias the text-space heuristic has, with no mechanism to correct it over the run
  • orthogonality
  • >Policy improvement</td><td>Hand-tuned hyperparameters</td><td>Meta: TextGrad</td><td>Text-space improvement operator (§4)</td></tr><tr><td colspan=
  • The arms are EXPLOIT and EXPLORE; on each update every arm's discounted pull count and reward sum decay by a factor $g$ before the played arm is credited, and the decision is $\arg \max_a s_a / n_a + c\sqrt{\log(N+1)/n_a}$
  • That deletion is the part we would point to: the claim of §5.1 is not that new mechanisms are cheap to add, but that adding a principled one can remove a hand-tuned constant, which is the same claim the paper makes about the transfer as a whole