Apply to my task
arXiv:2610.35160 ★ 90 Oct 26, 2026

AutoEnergyDesign: an optimizer agent with a “propose → run → keep or roll back” loop and memory files

Key result

18–27 runs instead of ~190: an agent built on a large language model (LLM) reached a configuration within 1% of the best one. Among classic methods, only the evolution strategy managed that, and only in half of its runs. The method lets you tune the parameters of a complex system when every simulator run costs minutes or hours, and you get an explanation for every step. The trick: the “keep or roll back” decision is made by a script, not the model. The agent proposes one change, the simulator returns a number, and git rolls back failures on its own. The model can't say “pretty good overall” or retrofit its explanation to the result.

01

TL;DR

AutoEnergyDesign is a setup where an LLM agent hunts for the best configuration of a complex system in a loop. The agent reviews the history of past runs, proposes a single change and fires up the simulator. If the result improves, the change stays. If it gets worse, git rolls it back automatically. The “keep or roll back” call is made by the environment, not the model. The agent can't just decide that things look “pretty good overall.” Everything it remembers lives in files: an instruction file, domain knowledge, an experiment log and a reflection note.

Classic optimizers (random search, Bayesian optimization, evolutionary algorithms) are flying blind: they need hundreds of runs. When a single run costs minutes or hours, that gets expensive. On top of that, they can't explain why a particular configuration won. An LLM agent starts in a sensible region because it knows the domain, and it explains every step. In the paper, the agent got within 1% of the best design in 18–27 runs. Among classic methods, only the evolution strategy pulled that off: in half of its runs and after about 190 runs.

The method boils down to three things. One: split memory into “how to search” (the instruction file), “what's true in this domain” (the knowledge file) and “what we've already tried” (the log). Two: force the agent to write its reasoning before the run and check it against the result afterward. Three: hand the rollback decision to a script, not to the model.

Want this for your own case? Apply this study to your task: AI adapts its method to what you are working on and writes the prompt.

02

Method Blueprint

SETUP: instruction file (how to search) + knowledge file (what's true in the domain)
       + log (what we've tried) + reflection note

LOOP until the run budget is spent:
  STEP 1: Read the instructions, knowledge, best design, history
          (+ the last K rejected candidates)
  STEP 2: Write the hypothesis and expectation to the log → BEFORE the run
  STEP 3: Change the configuration via a restricted set of actions
  STEP 4: Run the simulator → get a number (cost)
  STEP 5: The environment decides: better → commit, worse → revert (git)
  STEP 6: Write to the log what actually happened
  Every Nₐ experiments: write a reflection note
          (what we learned, which patterns are emerging)

This is a single agent loop per session. The “keep or roll back” decision lives outside the model.

03

Example in Practice

The method shines where there's a number a script can compute and several parameters you can tweak. Runs should be expensive enough that blind brute force is off the table. Copywriting and creative work, with their subjective scoring, are a poor fit.

Task: A coffee shop founder in Austin is building a unit-economics model in calc.py. Parameters: number of locations (1–6), average ticket, baristas per shift, Google Ads budget, and rent as a share of revenue. The metric is net profit over 3 years, provided the cash balance never dips below zero. He wants Claude Code to pick the parameters on its own and show why it chose them.

Prompt (goes into program.md, run in Claude Code):

<Role>
You are an optimizer agent for the unit economics of a coffee shop chain in Austin.
Your goal: maximize net profit over 3 years (the output of calc.py),
subject to one constraint: the cash balance never drops below 0.
Budget: 40 runs of calc.py.
</Role>

<Memory>
- program.md — this instruction file (how to run the search). Do not edit.
- insights.md — what's true about our business (edited by a human).
- log.md — experiment log: hypothesis → result → conclusion.
- notes.md — your reflection note (update it every 5 experiments).
</Memory>

<Actions>
You may ONLY:
1. Change values in config.yaml (within the allowed bounds).
2. Run: python calc.py
3. Append to log.md and notes.md.
Do not touch anything else.
</Actions>

<Loop>
Before each experiment:
1. Read insights.md, notes.md, the best config and the last 5 rejected ones.
2. In log.md write: “Experiment k. Changing: ... Because: ...
   Expecting: profit to rise/fall by roughly ...”.
3. Edit config.yaml and run calc.py.
4. The “keep or roll back” decision is made by the decide.sh script
   (beats the best → git commit, otherwise → git revert).
   You do not bypass it or argue with it.
5. Append to log.md: “Actual: ... Conclusion: hypothesis confirmed/not, because ...”.
Change 1–2 parameters at a time so it's clear what caused the effect.
Do not repeat candidates from the rejected list.
</Loop>

<Output>
At the end: the best config, the profit, and a short breakdown — which 3 decisions
mattered most and which hypotheses didn't hold up.
</Output>

Result: The agent works through a series of experiments. Before each one, a hypothesis with an expectation shows up in log.md; after it, the actual outcome and a conclusion. Failed changes roll back automatically, so the best version always sits in the repo. By the end, notes.md fills up with observations like “which parameters matter most.” The final answer is the best config plus a breakdown of what worked and what didn't.

04

Why It Works

The weakness. If you simply ask a model to “find the optimal parameters,” it will give you a plausible answer, not a verified one. It can't predict the output of a complex model, can't reliably judge on its own whether things got better or worse, and tends to “justify” its latest decision. Classic optimizers are honest but blind: they need hundreds of tries just to feel out a direction.

The strength. An LLM is good at proposing meaningful changes based on a description of the domain and the history of attempts: “the battery is pricey, let's try without it.” It juggles many constraints at once and explains its thinking in plain language. So the search starts in a sensible region instead of with blind guessing.

How the method ties it together. The creative part (proposing a step) belongs to the model. The control part (better or worse) belongs to numbers from the simulator and git. A log with the hypothesis “before” and the facts “after” keeps the model from retrofitting explanations to the result. Splitting memory lets a human edit the knowledge in insights.md without touching the instructions.

Control knobs: - Run budget (50 in the paper) → fewer for cheap problems, more for hard ones. - Number of rejected candidates in the history (K) → more means the agent repeats itself less, but the context grows. - Reflection frequency (Nₐ) → more often means the agent draws conclusions faster, but burns more tokens. - Knowledge file → add expert rules (“downtown rent in our city never drops below X”). The search narrows. - Set of allowed actions → the tighter it is, the less chance the agent breaks something it shouldn't. - Model → the stronger the model, the more reliably it lands on the best option (see “How They Tested It”).

05

Prompt Template

The paper describes the method through its memory structure and loop, so the template below is reconstructed from that description. The authors' verbatim system prompt isn't in the available part of the text. The structure is preserved: procedural memory, semantic memory, episodic memory with a decision log, a reflection note and a restricted action set.

<Role>
You are an optimizer agent for this task: {task}.
Goal: {minimize/maximize} {metric}, subject to the constraints: {constraints}.
Budget: {number} runs of {run_command}.
</Role>

<Memory>
- program.md — procedural memory: how to run the search (this instruction file). Do not edit.
- insights.md — semantic memory: what's true about {domain}.
  Read it before every experiment.
- log.md — episodic memory: the decision log. Each entry = hypothesis before the run + facts after.
- notes.md — reflection note: your conclusions about patterns.
  Update it every {Na} experiments.
- Working context: the best valid candidate and the last {K} rejected ones.
</Memory>

<Actions>
You may ONLY:
1. Change {what_to_change} in {config_file} within {bounds}.
2. Run {run_command}.
3. Append to log.md and notes.md.
Everything else is off-limits.
</Actions>

<Loop>
Until the budget is spent:
1. Read insights.md, notes.md, the best candidate, the last {K} rejected ones.
2. Write to log.md BEFORE the run: what you're changing, why, what result you expect.
3. Make the change and run it.
4. The “keep/roll back” decision is made by {rollback_mechanism} based on the metric.
   You do not bypass it or argue with it.
5. Write to log.md AFTER the run: the facts, whether they matched your expectation, the conclusion.
6. Every {Na} experiments, update notes.md.
</Loop>

<Output>
The best candidate, its metric value and a breakdown: which changes mattered most,
which hypotheses didn't hold up.
</Output>

What to fill in: - {task}, {metric} — what you're optimizing and how a script computes it. - {run_command} — the script that outputs a number. - {rollback_mechanism} — a simple script: “better → git commit, otherwise → git revert.” You can have the model write it for you. - {Na}, {K} — for example, 5 and 5.

🚀 Quick start — paste this into a chat (ideally Claude Code or Cursor):

Here's a template for an optimizer agent. Adapt it to my task: [your task].
Ask me questions to fill in the fields.

[paste the template above]

The LLM will ask how the result is measured (which script outputs the number), what can be changed and within what bounds. It will also ask which expert rules to put into insights.md and what the run budget is. Without these, the loop won't work: it needs an honest metric, permitted levers and domain knowledge. It will take the pattern from the template and build the files and the rollback script for your task.

06

Limitations

⚠️ You need an honest metric: the method works when the result comes from a script or a simulator. If the score is subjective (a text you “liked”), the keep/roll-back loop loses its point.

⚠️ Not a replacement for an exact solver: the authors themselves note that if the problem can be written as mixed-integer linear optimization, an exact solver gives an optimality guarantee the agent doesn't have. The agent is for cases where a formulation isn't feasible or the simulator is a “black box.”

⚠️ Reliability depends on the model: a weak model gets close but rarely hits the target exactly. The mid-tier model failed to get near the best option at all in some runs. The strong one succeeded in every run. The costlier a mistake, the stronger the model you need.

⚠️ A single problem: testing covered one case (one building, one dataset). Transfer to other domains is plausible but untested in the paper.

⚠️ Component contributions aren't isolated: the available text has no ablation showing what each memory element contributes on its own. The whole agent was compared against classic methods.

⚠️ Truncated text: in the input, the methodology is cut off and the results and discussion sections aren't visible. The authors' exact instruction wording can't be verified. The conclusions rely on the abstract and introduction.

07

How They Tested It

The team took on the problem of choosing a building's energy system: eight technologies (solar panels, wind turbines, batteries, heat pumps and others), measured load profiles, and a levelized cost calculation over 25 years. One run is a year-long hourly simulation. The agent was run on three Claude models of different strength (Haiku, Sonnet, Opus), with 10 runs each and a budget of 50 simulations.

It was compared with three baselines at 300 evaluations across 10 random seeds: random search, Bayesian optimization (TPE) and a (1+1) evolution strategy with the same acceptance rule as the agent (“better — keep it”). That makes the comparison fair: it shows what the model's smarts contribute, as opposed to the keep/roll-back rule itself.

All three models landed at a cost of about €3.53 million. That's 1.2% better than TPE and 0.23% better than the evolution strategy. Here's where it gets interesting: the agent gets within 1% of the best design in a median of 18 runs (Opus) to 27.5 (Haiku). The evolution strategy manages this in only half of its runs and after 192 runs. The other methods never got there.

The surprise is in reliability. Opus found the best design in all 10 runs. Sonnet did in six, and in two runs it didn't get within 1%. Haiku got within 1% in every run but hit the exact optimum only once. The practical takeaway: a weak model consistently delivers “almost good,” while precision and reliability come from strong models. And the gains aren't necessarily monotonic: the mid-tier model stumbled more often than the weakest one.

08

Adaptations and Extrapolations

🔧 Technique: numeric expectations → agent calibration

In the authors' setup, the agent justifies an experiment before running it and checks it against the outcome afterward. You can tighten that check by requiring a concrete number:

Before the run, write down your forecast for the metric as a number (e.g., “profit +3–5%”).
After the run, add how far the forecast was from the actual result and a correction:
“what I got wrong and what it means for the next hypotheses.”

If the forecasts keep missing, the agent doesn't understand the problem. That's your cue to beef up insights.md.

Extrapolation: a cheap model for scouting, a strong one for the finish. This isn't from the paper; it's an inference from its results: Haiku reliably gets close, Opus hits the target precisely. You can build a two-stage setup. First, the cheap model runs the loop and builds up log.md and notes.md. Then the strong model picks up with that history and polishes the result:

You are continuing the search after a previous agent. Read log.md and notes.md.
Do not repeat candidates that were already tested. Your task: improve the best candidate found
within {number} runs, testing hypotheses the previous agent didn't get to.

The paper didn't test this setup, so validate it on your own problem.

09

Resources

  • Paper: AutoEnergyDesign: An LLM-Driven Agent for Automatic Energy System Design Optimization
  • Authors: Amedeo Buonanno, Salvatore Fabozzi, Maria Valenti — Department of Energy Technologies and Renewable Sources, ENEA, Portici (Italy)
  • References: AutoResearch (Karpathy) — the prototype of the loop with git-based rollback; OPRO (Yang et al.); FunSearch; AlphaEvolve; LLAMBO; OptiMUS; Eureka; ReEvo

Research digest

Key result

18–27 runs instead of ~190: an agent built on a large language model (LLM) reached a configuration within 1% of the best one. Among classic methods, only the evolution strategy managed that, and only in half of its runs. The method lets you tune the parameters of a complex system when every simulator run costs minutes or hours, and you get an explanation for every step. The trick: the “keep or roll back” decision is made by a script, not the model. The agent proposes one change, the simulator returns a number, and git rolls back failures on its own. The model can't say “pretty good overall” or retrofit its explanation to the result.

Principle

It's a six-step pipeline, and each step has its own owner. The model reads memory and writes a hypothesis with an expectation before the run. Then it changes the parameters, and the simulator computes a number. A script compares that number with the best so far: better — keep it, worse — roll it back. Finally, the model records what actually happened. Memory is split across four files: instructions (how to search), knowledge (what's true in the domain), the log (what's been tried) and a reflection note. The model only proposes; the judge and the memory live separately from it. Think of an intern with a mentor: the ideas are theirs, but the checking and the record-keeping aren't.

Why it works

If you just ask a model to “find the optimal parameters,” it gives you a plausible answer, not a verified one. It can't guess the output of a complex model. And it tends to justify its most recent choice. Classic optimizers are honest but blind. They need hundreds of runs to feel out a direction: the evolution strategy took about 190. The agent takes the best of both. Domain knowledge yields sensible moves like “the battery is pricey, let's try without it.” So the search starts in a sensible region instead of with guesswork. Control is handed to numbers and git, so the model's creativity doesn't turn into self-deception. A log with the hypothesis “before” and the facts “after” closes the last loophole for fudging.

When to apply

Optimization → tuning parameters of a system whose result is computed by a script → especially when runs are expensive and blind brute force isn't affordable. Examples: energy systems, financial models, simulation tuning, business economics calculations. Two conditions are required: a number output by a script, and several parameters you can change. NOT suitable for copywriting and creative work: there's no honest number there, and the same model would end up being the judge.

Mini recipe

1. Find the number: a metric output by a script with no model involvement (profit, cost, time). 2. Split memory into files: instructions (how to search), knowledge (what's true in the domain), the log (hypothesis, facts, conclusion), a reflection note. 3. Make it write before the run: the hypothesis and expectation are recorded before launch, the facts and conclusion after. 4. Let the script deliver the verdict: beats the best — save it in git, otherwise — roll it back. The model doesn't touch or dispute this step. 5. Tie its hands: allow only editing the parameter file and running the calculation. Everything else is off-limits. 6. Cap the budget: the paper used 50 runs. Fewer for cheap problems, more for hard ones. 7. Tweak the knobs: feed the last K rejected candidates into the history so the agent doesn't go in circles. Ask for reflection every few experiments; more often costs more tokens. 8. Feed it knowledge: expert rules in the knowledge file narrow the search. Use a stronger model; it lands on the best option more reliably.

Examples

[BAD]: `Find the optimal parameters for a coffee shop chain so that profit is maximized` [GOOD]: `You are an optimizer agent for the profit model of a coffee shop chain in Austin. Goal: maximize net profit over 3 years from calc.py, provided the cash balance never drops below 0. Budget: 40 runs. Memory: program.md (instructions, do not edit), insights.md (what's true about our business), log.md (the log), notes.md (your conclusions, update every 5 experiments). You may only: edit config.yaml, run python calc.py, append to log.md and notes.md. Before each experiment, read insights.md, notes.md, the best config and the last 5 rejected candidates. In log.md write: what you're changing, why, and what profit you expect. Change 1–2 parameters at a time. Then run calc.py. The decide.sh script decides on its own: beats the best — git commit, otherwise git revert. Don't argue with it. Append the facts and your conclusion to log.md. At the end, give the best config and a breakdown: which 3 decisions mattered most and which hypotheses didn't hold up.`

In plain words

Ask a model to optimize a complex system and it'll hand you a convincing hallucination instead of a working solution. Models are pathologically bad at doing physics in their heads, and they love to rationalize their screw-ups, sincerely believing things turned out “pretty good overall.” The AutoEnergyDesign architecture simply strips the LLM of the right to judge results: the agent proposes a hypothesis, runs it through a simulator, and the verdict comes from the outside environment. If the metric gets worse, an automatic git rollback wipes the edits instantly, no excuses heard.

It's like hiring an eager intern and pairing them with a robot supervisor. The intern pitches ideas, turns exactly one knob at a time and runs the test. Efficiency goes up — the change gets committed to the repo; it drops — the robot silently slaps their hand and hits Ctrl+Z. No arguments along the lines of “but it's more conceptual now” — the system only cares about the cold, hard number on the scoreboard, not the model's daydreams.

Under the hood runs a strict loop: step-by-step parameter mutation, an external simulator and context neatly filed away. The agent doesn't keep everything in its head; it reads an experiment log, a knowledge base and its own reflection note that dissects past fails. Blind classic algorithms grind through thousands of random variants, while the LLM uses context to grasp the physics and strike right where it counts.

The approach was tested on energy systems, but the principle is universal. The method beats the competition anywhere test runs are expensive and blind brute force would torch the budget: from database tuning and aerodynamics to server configs. The key requirement is a clear numeric score computed by an impartial script. Creative and humanities work need not apply — pure math rules here.

The moral is simple: never trust a model's self-assessment; make the environment check its every move. Classic optimization is blind trial and error, and a bare LLM is confident fiction. Lock the model into a combo of a deterministic simulator and code versioning, and you get a cheap virtual engineer. Take away its right to pat itself on the back, and it finally starts delivering real value.

AI lab assistant

Apply this study to your task

Describe what you're working on. AI takes the method and the measured results from this paper and adapts them to your case, or writes a ready prompt built on them.

Based on AutoEnergyDesign: an optimizer agent with a “propose → run → keep or roll back” loop and memory files arXiv:2610.35160

Sign in to apply this study New accounts get 50 free credits.