Harness Optimization

You can tune five different things around a model: the prompt, the context, the workflow, the harness code, or the optimizer that writes the harness. Each step up is a bigger object, searched by a more general method.

Pick a rung and watch the object change shape, from a string to a playbook to a graph to a repository. Then we build, rung by rung, the systems that optimize each one, and you run a workflow search yourself in Chapter 8.

You need a little Python, what a probability is, and the idea of a harness from Harness Engineering. We build the rest from zero.

Based on the harness optimization sections of Lilian Weng, Harness Engineering for Self-Improvement (Lil'Log, 2026), and the papers it cites: ACE, MCE, Meta-Harness, the AI Scientist, ScientistOne, Autodata, ADAS and AFlow. Every idea is re-taught here in our own words and devices.

Pick what you optimize

The five rungs and their order come from Weng (2026). The two bars are a picture of her claim that objects get more complex and methods more general as you climb; their heights are illustrative.

Chapter 0

The Ladder of Optimization Targets

Sort every harness method by the one thing it changes, and pick the lowest rung that fixes your failure

Your coding agent fails 30 percent of its tasks. You have one week to improve it. You could sharpen the system prompt. You could change what enters the context window. You could add a review step, rewrite the harness code, or write a program that rewrites the harness for you.

Those five choices are a sequence. Weng names it in her 2026 survey: the object being optimized, the thing that differs between one version of the system and the next, moves from instruction prompts to structured context, then to workflow, harness code and optimizer code.

RungObjectWhat changesMethods here
1 · Prompta stringthe wordsprompt engineering
2 · Contexta playbook, a set of fileswhat enters, merges, leavesACE, MCE (Ch 2, 3)
3 · Workflowthe shape of the runwhich steps, in what order, with which checksby hand: AI Scientist, ScientistOne, Autodata (Ch 5); by search: ADAS, AFlow (Ch 6, 7)
4 · Harness codethe program around the modelits source codeMeta-Harness (Ch 4)
5 · Optimizer codethe loop that improves the harnessthe improver itselfnext lesson

Two things grow as you climb. The object gets bigger: a string, then a document, then a graph, then a repository. The method gets more general: a search over code does not care what the code is for. Weng ties the climb to model strength. Stronger models make bigger objects safe to hand over.

The rungs have soft edges. Meta-Harness optimizes harness code with an optimizer that is itself a harness, so it stands on rungs 4 and 5 at once.

Climb only as high as the failure

A higher rung costs more to build and to evaluate. So read your failures first, then pick the lowest rung that fixes them. This rule of thumb is ours, not Weng's.

Match the failure to a rung

Each chip is a symptom you might see in your logs. Pick one and the ladder lights the rung that owns it.

The symptom-to-rung map and the cost bar are an illustrative rule of thumb made for this page.

The failure, as symptom, measurement and fix. Symptom: you built a search over workflows, and the agent still misreads the same instruction. Measurement: label 50 failed runs by cause and count each rung's share. Fix: spend the week on the rung with the largest share.

The road

  1. Context rot: why appending and summarizing both fail.
  2. ACE: context as a playbook of itemized bullets.
  3. MCE: evolve the mechanism, judged on held-out tasks.
  4. Meta-Harness: search harness code; keep a Pareto frontier.
  5. Handcrafted workflows: research pipelines and the difficulty band.
  6. ADAS: a meta-agent that writes agents in code.
  7. AFlow: tree search with soft mixed selection.
  8. The playground: three searches race on noisy scores.
  9. Field guide: numbers, code, links.
What is the order of the ladder, from the smallest object to the largest?

Chapter 1

Context Rot: Why Appending and Summarizing Both Fail

Count what a growing transcript costs, then watch repeated summaries erase the detail that mattered

Your agent debugs a repository for 100 turns. Each turn adds a tool output and a reply. The plain harness appends both and sends the whole transcript every turn.

Call the tokens one turn adds c and the number of turns n. Turn t sends t times c tokens. Call the total billed over the run B.

Say it aloud

B equals c times n times n plus one, over two.

B
B the input tokens billed over the whole run.
c
c the tokens one turn adds: a tool output plus a reply.
n(n + 1) / 2
n times n plus one, over two the sum 1 + 2 + … + n, where n is the number of turns.
In plain words

Add the cost of every turn, c, 2c, up to n times c. The sum of 1 to n is n(n + 1) / 2, so B grows with n squared.

With numbers

With made-up numbers: c = 2,000 tokens and n = 100 turns. B = 2,000 × 5,050 = 10,100,000 tokens. The final transcript is only c × n = 200,000 tokens, so you pay for it 50.5 times.

Grow the transcript

Warm is the window at the last turn. Yellow is everything billed. Drag the turns.

100

Illustrative: 2,000 tokens a turn, no caching, no trimming.

The obvious fix is to compact: ask the model to rewrite the context as a shorter summary every few turns. Follow one fact through three rewrites:

RewriteWhat the context saysWhat was lost
0"The flaky test fails only when CI runs in UTC+9, because the date assertion runs at local midnight."nothing
1"The flaky test is timezone dependent (UTC+9, midnight)."the cause
2"There are timezone test issues."which zone, which test
3"Timezone issues exist."everything you can act on

The ACE paper names both effects. Context collapse is detail eroding under repeated rewriting. Brevity bias is its direction: a summarizer drops specific insight for short, general statements. Call the share of detail one rewrite keeps r, the number of rewrites n, and the share left at the end F.

Say it aloud

F equals r to the n.

F
F the share of the original detail still in the context, from 0 to 1.
r
r the share of detail one rewrite keeps, from 0 to 1.
n
to the n multiply r by itself once for each of the n rewrites.
In plain words

Each rewrite keeps the share r of its input, and the next rewrite starts from what is left. So multiply r by itself n times.

With numbers

With made-up numbers: r = 0.9 and n = 10. F = 0.910 ≈ 0.35. Two thirds of what the agent learned is gone, and no single rewrite looked bad.

Photocopy the context

Seven insights sit in context. With rewrite all, every rewrite touches all of them; with itemized, only the edited one. Drag the rewrites.

10
0.90

Illustrative toy with made-up insights and keep rate.

The paper saw this for real. On the AppWorld agent benchmark, a fully rewritten context held 18,282 tokens and scored 66.7 at step 60. One step later it collapsed to 122 tokens and scored 57.1, below the 63.7 of an agent that never adapted (Zhang et al., 2025, section 2.2).

The failure, as symptom, measurement and fix. Symptom: the agent re-derives last week's fix. Measurement: after each compaction, count how many key facts survive word for word. Fix: store facts as separate items and never rewrite the untouched ones (Chapter 2).

A context once said "the flaky test fails only under UTC+9 at midnight". After rewrites it says "timezone issues exist". Which name fits the drift toward short, general statements?

Chapter 2

ACE: Context as an Evolving Playbook

Split the work into three roles and let plain code merge small itemized updates, so nothing untouched can decay

A sports team keeps a playbook. Players play, an analyst watches the tape, and an editor updates the binder. Nobody rewrites the whole binder after each game. The editor changes one page.

Agentic Context Engineering (ACE; Zhang et al., 2025, ICLR 2026) builds context the same way. The context is a playbook: a list of bullets, each with an identifier (a stable name such as api-rate-limit) and a description (the insight). Three roles maintain it.

RoleReadsWrites
Generatorthe task and the current playbooka trajectory: one full attempt at the task
Reflectortrajectories, both successes and failurescandidate insights
Curatorthe insightssmall updates, called deltas: (identifier, description) pairs

The key choice: the Curator does not rewrite a full prompt. Ordinary code merges its deltas. A new identifier is appended. A known identifier updates that one entry. Every other bullet passes through as the same bytes. From time to time a refinement pass removes near-duplicates by comparing bullets with semantic embeddings.

pythondef curate(playbook: dict, deltas: list) -> dict:
    # deterministic merge: plain code, no model call
    for d in deltas:                         # d = {"id": str, "desc": str}
        if d["id"] in playbook:
            playbook[d["id"]] = merge(playbook[d["id"]], d["desc"])  # update that one entry
        else:
            playbook[d["id"]] = d["desc"]     # append a new insight
    return playbook                            # every other entry: untouched bytes

def ace_step(playbook, task, llm):
    traj   = generate(task, playbook, llm)    # Generator
    deltas = reflect(traj, llm)              # Reflector: the only creative step
    return curate(playbook, deltas)          # Curator's deltas, merged by code

Run rollouts into the playbook

Green rollouts passed, red failed; both teach something. A repeat insight raises its counter. Switch to rewrite and run again.

Illustrative toy: the insights are made up, and the rewrite mode drops each existing item with a 12% chance per rollout. ACE's real deltas also carry helpful and harmful counters.

Count the work in one step. With made-up numbers: the playbook holds 220 bullets of about 80 tokens, so 17,600 tokens. A delta touches 2 bullets. The merge regenerates nothing else. A full rewrite asks a model to re-emit all 17,600 tokens to apply the same two changes, and each token is a chance to drop detail.

The paper reports gains of 10.6 percent on agent tasks and 8.6 percent on finance tasks over strong baselines, with lower adaptation cost. It learns from execution feedback, so it needs no labels.

The failure, as symptom, measurement and fix. Symptom: two runs write opposite claims under one identifier, such as "cap retries at 3" and "cap retries at 5". Measurement: log each update that reverses a description. Fix: send conflicts to the periodic refinement pass, not to the per-step merge.

ACE's limit sets up the next chapter. The playbook learns, but its rules are fixed by hand: bullets, identifiers, deterministic merges. If a task needs a code library instead of bullets, ACE cannot find that out.

What does ACE's Curator produce, and how does it enter the playbook?

Chapter 3

MCE: Evolve the Mechanism, Judge on Held-Out Tasks

Run two loops: an inner one that tunes the context, and an outer one that picks the recipe on data the inner loop never saw

ACE fixes the recipe and improves the dish. Meta Context Engineering (MCE; Ye et al., 2026) also changes the recipe. It separates the mechanism, the way context gets built, from the artifact, what the context contains.

The mechanism is a skill: static parts (prompts, knowledge bases, code libraries) plus dynamic operators (search, select, filter, format). In MCE a skill is a folder with a SKILL.md file. Both loops run as coding agents with Read, Write, Edit, Bash, Glob, Grep and TodoWrite.

Two scores drive the loops. Call the skill s and a context it can build c. Call the score on training tasks Jtrain and the score on held-out validation tasks Jval.

Say it aloud

c-star-s equals the argmax over c of J-train of c, given s.

c*s
c-star-s the best context that skill s can build.
argmaxc
the argmax over c the context c that makes the score largest.
Jtrain
J-train the agent's score on training tasks, from 0 to 1.
s
given s the skill stays fixed in this loop.
In plain words

Hold the skill s fixed. Let the base agent edit the context files, run training tasks and keep the edits that raise J-train. The context it ends with is c-star-s.

With numbers

With made-up numbers: skill C starts at J-train 0.52. After a few rounds of edits it reaches 0.84, so c-star-C is the context that scored 0.84.

Say it aloud

s-star equals the argmax over s of J-val of c-star-s.

s*
s-star the skill the outer loop keeps.
argmaxs
the argmax over s the skill that makes the score largest.
Jval
J-val the score on validation tasks the inner loop never touched.
c*s
c-star-s each skill's best context from the inner loop.
In plain words

For each skill s, take its finished context c-star-s. Score it on the validation tasks. Keep the skill with the highest J-val.

With numbers

With the made-up skills below: J-val is 0.79 for A, 0.64 for B and 0.82 for C. The argmax is C, so s-star is C, though B had the best J-train.

Skill (made up)JtrainJvalGap
A · full log, keyword search0.810.790.02
B · memorize per-task hints0.880.640.24
C · bullets plus top-k retrieval0.840.820.02

Why Jval outside? The inner loop squeezes the training tasks, so Jtrain flatters. Skill B learned their quirks: meta-overfitting, where the mechanism, not the weights, fits the training set. The 0.24 gap gives it away.

Pick a skill for the outer loop

Four skills with train and measured validation scores. Choose the judge, then shrink the validation set and redraw it.

200

Illustrative toy. Each skill has a hidden score on new tasks; the measured J-val is that score plus binomial sampling noise from the number of validation tasks.

New skills come from agentic crossover. A meta-level agent reads the history of past skills, their contexts and both scores, then writes a new skill that combines their strengths. The paper calls the loop a history-informed (1 + 1) evolution strategy. Across five domains it reports 5.6 to 53.8 percent relative gains over earlier context engineering methods, 16.9 percent on average.

The failure, as symptom, measurement and fix. Symptom: the kept skill wins validation once, then falls on new tasks. Measurement: rescore the top skills on a fresh draw. Fix: more validation tasks, or repeated scoring.

In MCE, what does the outer loop change, and which score picks the winner?

Chapter 4

Meta-Harness: Search the Harness Code Itself

Let a coding agent propose whole harness programs, read the history with grep, and keep every candidate nobody beats on both cost and score

A harness is the code that decides what to store, retrieve and show to the model. Meta-Harness (Lee et al., 2026) searches over that code. It is a harness for optimizing harnesses.

  1. A coding agent, the proposer, reads earlier candidates and writes a new harness program.
  2. The system runs the new harness and records its scores.
  3. Each candidate is saved as a directory: its source code, its scores and its execution traces.
  4. The proposer reads that history with grep and cat, never as one giant prompt.
  5. It keeps the qualified candidates and returns a frontier, not one winner.

Step 4 is the file-system memory pattern from Harness Engineering, one level up: the history is too big for a prompt, so the proposer searches it.

The Pareto frontier

A harness has two scores you care about: accuracy, where higher is better, and token cost, where lower is better. Call one candidate A and another B. A dominates B when it is at least as good on both and strictly better on one.

Say it aloud

A dominates B if the cost of A is at most the cost of B, and the score of A is at least the score of B, with at least one of the two strict.

A ≻ B
A dominates B no budget would ever make B the better choice.
cost(A) ≤ cost(B)
cost of A is at most cost of B tokens per task, lower is better.
score(A) ≥ score(B)
score of A is at least score of B accuracy, higher is better.
one strict
one strict A must win outright on cost or on score, so a tie does not count.
In plain words

Compare candidate A with candidate B on both axes. If A is no worse on cost and on score, and better on one, drop B. The candidates nobody dominates form the Pareto frontier.

With numbers

With made-up numbers (cost in thousands of tokens, score): A (9, 0.74), B (30, 0.73), C (40, 0.82), D (22, 0.78), E (45, 0.80). D dominates B: 22 ≤ 30 and 0.78 > 0.73. C dominates E: 40 ≤ 45 and 0.82 > 0.80. The frontier is A, D, C.

Why a frontier and not one winner? The best harness depends on the budget. Under 25,000 tokens a task, the answer above is D. With no limit it is C. One search answers both questions.

Push the frontier out

Each dot is a harness: cost across, score up. Green dots form the frontier. Propose batches, then set a budget.

25

Illustrative toy: candidates are drawn near the current frontier with random gains. The strong start mirrors the TerminalBench-2 runs, which began from Terminus 2 and Terminus-KIRA.

The results, as reported. On online text classification, the found harnesses beat ACE by 7.7 points while using 4 times fewer context tokens. On TerminalBench-2, search started from two strong hand-built harnesses, Terminus 2 and Terminus-KIRA. With Claude Opus 4.6 the found harness passed 76.4 percent of tasks, against 74.7 for Terminus-KIRA.

The failure, as symptom, measurement and fix. Symptom: a harness tops the benchmark it was searched on and slips on new tasks. Measurement: score the frontier on tasks the search never saw. The TerminalBench-2 search and final score used the same 89 tasks; the authors say so and audit for leaks. Fix: keep a held-out split whenever the benchmark is big enough; the RRSI lesson measures this overfit.

What puts a candidate on the Pareto frontier?

Chapter 5

Handcrafted Workflows: Research Pipelines and the Difficulty Band

See what experts build by hand on rung 3, why receipts matter, and how a data loop keeps problems at the edge of a model's skill

Rung 3 changes the shape of the run. Before anyone searched this space, experts drew workflows by hand. Three systems from Weng's survey show what that buys.

SystemThe workflowIts point
AI Scientist (Lu et al., 2026, Nature)propose ideas, write code, run experiments, analyse, write the paper, peer reviewa fixed six-stage research pipeline
ScientistOne (Meng et al., 2026)literature review, solution search, writing, each step keeping an evidence chainevery claim must trace to its evidence
Autodata (Kulikov et al., 2026)a challenger, a weak solver, a strong solver and a verifiermake training data at the right difficulty

Every arrow in a handcrafted pipeline is a human decision. That buys reliability and costs flexibility: if good research sometimes needs analysis before more coding, a fixed pipeline cannot find that out.

ScientistOne attacks a different failure: a manuscript that reads well but is not true. Its Chain-of-Evidence audit runs four checks on any system's papers: score verification, specification violations, reference verification and method-code alignment. The paper reports zero hallucinated references out of 337, 12 of 12 scores verified and 14 of 15 methods matching their code. Some baselines hallucinated up to 21 percent of their references.

The difficulty band

Autodata keeps a problem only when the strong solver passes it and the weak solver fails it. Easy problems teach the weak model nothing. Problems both fail give no correct answer to learn from. Call the chance the strong solver passes pS, the chance the weak solver passes pW, and the chance a new problem lands in the keep band Pgold.

Say it aloud

P-gold equals p-S times one minus p-W.

Pgold
P-gold the chance a new problem is kept: strong passes and weak fails.
pS
p-S the chance the strong solver passes, at the current difficulty.
1 − pW
one minus p-W the chance the weak solver fails.
In plain words

Take the chance the strong solver passes, p-S. Multiply it by the chance the weak solver fails, one minus p-W. This assumes the two solvers fail for unrelated reasons.

With numbers

With made-up numbers: at this difficulty p-S = 0.9 and p-W = 0.2. P-gold = 0.9 × 0.8 = 0.72, so about 7 problems in 10 are kept.

The solvers' and verifier's feedback updates the challenger's prompt. Too many problems both solve: push harder. Too many both fail: ease off.

Steer into the keep band

Each curve is a solver's pass chance; green is P-gold. Drag the difficulty, then Run with the controller on and off.

0.20

Illustrative toy: both pass curves are made-up logistic curves, and the controller nudges difficulty by the share of both-pass minus both-fail outcomes over the last 20 problems.

Weng adds a caution. The synthesized problems fine-tune weak solvers, not the strong one, so nothing in the data goes beyond what the strong model can already do. She reads it as closer to indirect distillation than to recursive self-improvement. The Autodata paper also trains the data-making agent itself, which is a separate loop.

The failure, as symptom, measurement and fix. Symptom: the kept band fills with problems that look hard but have a shortcut. Measurement: hand-check a sample of kept problems against the verifier's verdicts. Fix: strengthen the verifier first; the loop is only as honest as its judge.

When does Autodata keep a synthesized problem?

Chapter 6

ADAS: A Meta-Agent That Writes Agents in Code

Treat workflow design as search, keep an archive of working agents, and let a meta-agent program the next one

Handcrafted workflows inherit their designers' blind spots. Weng's next move: treat workflow design as a search problem, and let an algorithm find good designs.

ADAS, Automated Design of Agentic Systems (Hu, Lu and Clune, 2025), does this with Meta Agent Search. A meta-agent is an agent whose job is to write other agents.

  1. Fill an archive with simple agents, such as chain-of-thought and self-refine.
  2. The meta-agent reads the archive and describes a new workflow in plain language.
  3. It implements that description as code.
  4. It runs two self-refine passes (Madaan et al., 2023): critique its own draft, then revise it, checking that the design is new.
  5. Evaluate the new agent; successful ones join the archive.
  6. Repeat until the iteration limit.

Why code and not prompt text? Code runs, so every archive entry can be scored again. Code composes, so a new agent can wrap one agent's voting in another's retry loop. And the abstract's own argument: programming languages are Turing complete, so code can express any workflow.

pythonarchive = [Agent("CoT", cot_code), Agent("SelfRefine", sr_code)]   # seeds, with scores
for k in range(MAX_ITERS):
    desc = meta_agent("Archive and scores:\n" + render(archive) + "\nDescribe a new workflow.")
    code = meta_agent("Implement it as code:\n" + desc)
    for _ in range(2):                                   # two self-refine passes
        crit = meta_agent("Is this new and correct?\n" + code)
        code = meta_agent("Revise using the critique:\n" + crit + code)
    score = evaluate(code)                               # the expensive step
    if is_successful(score, archive):
        archive.append(Agent(desc, code, score))

A worked micro-run, with made-up scores. The seeds score 0.62 (CoT) and 0.66 (self-refine). Our toy rule keeps a candidate if it beats the average of its two parents.

IterationParentsCandidateScore vs parent averageVerdict
1CoT, self-refineCoT with voting0.69 > 0.640kept
2self-refine, CoT with votingreflection wrapper0.63 < 0.675dropped
3CoT with voting, self-refine3-sample ensemble0.73 > 0.675kept

Grow the archive

Each step draws two parents from the archive, writes a candidate and scores it. Watch the best score climb in steps, not smoothly.

Illustrative toy: candidate scores are drawn near the better parent, with rare jumps; the keep rule is ours. ADAS evaluates on real benchmarks across coding, science and math.

The failure, as symptom, measurement and fix. Symptom: the archive fills with near-copies of the current best. Measurement: compare each new description with its nearest archive entry. Fix: the novelty check in the self-refine passes. Watch the budget too: every iteration pays for a full benchmark run, which costs far more than writing the code.

In ADAS, what does the archive hold, and what does the meta-agent produce each iteration?

Chapter 7

AFlow: Tree Search over Workflow Graphs

Make a workflow a graph, grow a tree of edited versions, and choose what to edit next with a mix of merit and chance

ADAS searches all programs with loose guidance. AFlow (Zhang et al., ICLR 2025) narrows the space and adds a search algorithm. A workflow is a graph: each node is an LLM call, and each edge is code that decides what flows where.

The search is Monte Carlo tree search (MCTS). The root is a starting workflow. Each child is its parent with one edit. Each node carries a score from real runs.

  1. Start from a template workflow.
  2. Select a node to improve, from the top-k workflows plus the start.
  3. Expand: an LLM edits it, shown the parent's past edits, scores and failure logs.
  4. Evaluate the new workflow on the validation set, 5 times, and record the mean.
  5. Keep it in the tree and pass what it learned back to its parent.
  6. Stop when the top-k average stops improving for some rounds, or the round budget runs out.

Soft mixed selection

Why not always edit the best node? Scores are noisy and the best node may be a dead end. AFlow mixes a fair lottery with a strong preference for high scores. Call the number of candidate workflows n, workflow i's score si, the best score smax, the lottery share λ and the sharpness α.

Say it aloud

P of i equals lambda times one over n, plus one minus lambda times e to the alpha times s-i minus s-max, over the sum over j of e to the alpha times s-j minus s-max.

P(i)
P of i the chance workflow i is picked to edit next.
λ
lambda the lottery share, from 0 to 1. The paper uses 0.2.
1/n
one over n a fair lottery: every candidate equally likely.
eα(si − smax)
e to the alpha times s-i minus s-max workflow i's weight: 1 for the best, smaller the further behind. Alpha (the paper uses 0.4) sets how fast it shrinks.
Σj
the sum over j add the weights of all n candidates, so the merit shares add to 1.
In plain words

Give each workflow a merit weight that falls off fast below the best score. Turn the weights into shares that add to 1. Blend those shares with a fair lottery, lambda of the lottery and one minus lambda of merit.

With numbers

With made-up scores in points, 62, 71, 58 and 74, and the paper's λ = 0.2, α = 0.4: the weights are e−4.8 = 0.008, e−1.2 = 0.301, e−6.4 = 0.002 and 1, summing to 1.311. The best workflow gets 0.05 + 0.8 × 1/1.311 = 0.66. The worst still gets 0.05 + 0.8 × 0.0013 = 0.051.

So the leader gets about two picks in three, and every workflow keeps a floor of λ/n = 0.05, enough to revisit an unlucky 58. The score scale matters: AFlow's released code multiplies scores by 100 before this step.

Tune the selection mix

Grey is the lottery floor; purple is the merit share. Move the knobs, then sample 100 picks.

0.20
0.40

The formula and the defaults λ = 0.2, α = 0.4 are from the AFlow paper (equation 3). The four scores are made up.

On six benchmarks (HumanEval, MBPP, MATH, GSM8K, HotpotQA and DROP), the paper reports workflows 5.7 percent better on average than hand-designed methods and 19.5 percent better than earlier automated ones, ADAS among them. A smaller space, searched with statistics, beat a larger one searched loosely.

The failure, as symptom, measurement and fix. Symptom: set λ = 0 and a large α, and every edit lands on one branch. Measurement: count how many distinct nodes were expanded in the last 10 rounds. Fix: keep the lottery floor.

How does AFlow choose which workflow to edit next?

Chapter 8

The Workflow Search Playground

Race three search strategies on one hidden landscape and see why averaged scores beat single readings when evaluation is noisy

Now run a search yourself. A workflow is a chain of 1 to 4 operators from a library of six: direct, CoT, refine, ens-3 (three samples and a vote), verify and decompose. That gives 6 + 36 + 216 + 1,296 = 1,554 workflows. Each has a hidden true quality.

You never see the true quality. Each evaluation returns it plus noise, as a finite test batch does. Three strategies compete with the same budget of evaluations:

StrategyEach stepIt believes
Randomevaluate a fresh random workflowthe best single reading so far
Greedychange one operator of the champion; switch if the reading is higherthe champion's one reading
Averagingsoft mixed selection over the top workflows; re-evaluate a workflow once, then edit ita mean over repeated readings

Averaging borrows AFlow's two habits: sampled selection, and repeated evaluation. Why repeat? Call the noise of one reading σ, the number of readings averaged m, and the noise left in their mean SE, the standard error.

Say it aloud

S-E equals sigma over the square root of m.

SE
S-E the standard error: the typical size of the error in the averaged score.
σ
sigma the noise in one evaluation, as a standard deviation in score units.
√m
the square root of m where m is how many readings you average.
In plain words

Evaluate the same workflow m times and average. Independent errors partly cancel, so the error of the mean is the error of one reading, sigma, divided by the square root of m.

With numbers

With made-up numbers: σ = 0.12 (high noise) and m = 5, AFlow's repeat count. SE = 0.12 / 2.236 ≈ 0.054, so the mean is 2.2 times sharper than one reading.

Race three searches

The chart plots the true quality of each strategy's current champion, a number no strategy can see. Pick a noise level and a budget, then Run.

100

Illustrative toy landscape made for this page. The lines are one seeded run; the averages in the read-out are over 200 seeds with the same settings.

Three experiments. Low noise, budget 60: greedy does well, because local moves on honest readings work. High noise, budget 100: averaging wins and greedy falls behind random. Budget 15: random wins, because averaging has no time to repeat anything. Structure needs budget to beat luck.

Why greedy breaks: one lucky reading crowns a champion, and that inflated number becomes a bar no honest challenger clears. The read-out shows what greedy believes against the truth.

The hidden landscape

Each operator pulls the workflow's quality half of the way toward its own level: direct 0.45, CoT 0.62, refine 0.60, ens-3 0.66, verify 0.64, decompose 0.58, from a start of 0.35. Three ordered pairs earn a bonus: CoT then refine (+0.07), refine then verify (+0.06), decompose then ens-3 (+0.05). Repeating an operator back to back costs 0.04. The best chains, such as CoT, refine, verify, ens-3, reach 0.756.

Under high evaluation noise, why does averaging search beat greedy search?

Chapter 9

Field Guide

Keep the methods, the numbers and the three questions that sort any new paper onto the ladder

Every method here is defined by the object it changes, who proposes changes, and who judges them.

MethodObject (rung)ProposesJudgesKey number
ACEcontext playbook (2)Reflector, merged by codeexecution feedback+10.6% agents, +8.6% finance
MCEskill and context (2 to 3)meta-agent crossoverJ-train inside, J-val outside5.6 to 53.8% relative, mean 16.9%
Meta-Harnessharness code (4)coding agentseveral objectives, Pareto+7.7 points over ACE, 4x fewer tokens
AI Scientistfixed workflow (3)human expertsa peer review stage6 stages
ScientistOnefixed workflow (3)human expertsChain-of-Evidence audit0 of 337 references hallucinated
Autodatachallenger prompt (1 to 3)challenger agentverifier and two solverskeep: strong passes, weak fails
ADASagent programs (3)meta-agent, in codebenchmark runs2 self-refine passes
AFlowworkflow graph (3)LLM edits in a tree5 validation runs each+5.7% vs manual, +19.5% vs automated

The equations

EquationRead it as
B = c · n(n + 1) / 2appending makes the bill grow with turns squared
F = rnrepeated summaries lose detail by multiplication
c*s = argmaxc Jtrain(c ; s)tune the context on training tasks
s* = argmaxs Jval(c*s)pick the skill on held-out tasks
A ≻ Bno worse on cost and score, better on one
Pgold = pS(1 − pW)the share of problems in the keep band
P(i) = λ/n + (1 − λ) · softmax(αs)ia lottery floor plus a sharp merit share
SE = σ / √maveraging m readings cuts noise by √m

Before you optimize a harness

  1. Label 50 failures by cause; pick the lowest rung that owns most of them.
  2. Store learned facts as separate items; never rewrite what you did not change.
  3. Split your tasks: tune on one set, choose on another, report on a third.
  4. Track cost beside score and keep the frontier.
  5. Evaluate each candidate several times and compare means.
  6. Trust the loop only as far as you trust its judge.
pythonimport numpy as np

def soft_mixed(scores, lam=0.2, alpha=0.4):      # scores in points, AFlow eq. 3
    s = np.asarray(scores, float)
    w = np.exp(alpha * (s - s.max()))                # 1 for the best, smaller below
    return lam / len(s) + (1 - lam) * w / w.sum()

def pareto(cands):                                 # cands: [(cost, score, name)]
    return [a for a in cands if not any(
        b[0] <= a[0] and b[1] >= a[1] and (b[0], b[1]) != (a[0], a[1]) for b in cands)]

print(soft_mixed([62, 71, 58, 74]).round(3))   # [0.055 0.234 0.051 0.66 ]
print(pareto([(9,.74,"A"),(30,.73,"B"),(40,.82,"C"),(22,.78,"D"),(45,.80,"E")]))  # A, C, D

Three questions for any new paper

  1. What object does it change? That is its rung.
  2. Who judges, on what data, and can the optimizer touch that data? That is its overfitting risk.
  3. Does the loop raise its own ceiling, or only the weak model's? That is the Autodata test.

Keep going

The takeaway. Name the object first. Then keep untouched knowledge out of the rewrite, judge on data the optimizer cannot touch, keep the cost frontier, and trust averages over single readings.
Which line matches each method to the object it optimizes?

Now press Present or Teach and explain from memory the five rungs, the two loops of MCE and the soft mixed selection rule. Then go back to the ladder and say, for each rung, which chapter's method changes it.

Credit and sources

This lesson re-teaches the harness optimization sections of Lilian Weng, Harness Engineering for Self-Improvement (2026). Papers: Zhang et al., ACE (2025); Ye et al., MCE (2026); Lee et al., Meta-Harness (2026); Lu et al., The AI Scientist (Nature, 2026); Meng et al., ScientistOne (2026); Kulikov et al., Autodata (2026); Hu, Lu and Clune, ADAS (2025); Zhang et al., AFlow (2025); Madaan et al., Self-Refine (2023). The toy numbers and devices are our own.

Harness Optimization: Context Playbooks to Workflow Search
Weng, Harness Engineering for Self-Improvement · Harness Engineering · Self-Improving Harnesses · Back to Gleams