source · ingested Jul 7, 2026 · updated Jul 19, 2026

Harness Engineering for Self-Improvement

Lilian Weng #recursive-self-improvement#harness#context-engineering#evolutionary-search#agent-engineering
Original article: lilianweng.github.io/posts/2026-07-04-harness · Ingested copy: raw/2026-07-07-harness-engineering-self-improvement.md

A comprehensive survey by lilian-weng (Jul 2026) organizing recent research on how harness engineering contributes to recursive self-improvement (RSI). The central claim: the near-term path to RSI runs through optimizing the harness — the system surrounding a base model — rather than the model rewriting its own weights directly.

Source file: raw/2026-07-07-harness-engineering-self-improvement.md.

Summary

The post defines a harness as the system surrounding a base model that orchestrates how the model thinks and plans, calls tools and acts, perceives and manages context, stores artifacts, and evaluates results. Compared with Weng’s earlier 2023 agent anatomy (“agent = LLM + memory + tools + planning”), harness engineering additionally includes workflow design, evaluation, permission controls, and persistent state management — closer to runtime and OS design than prompt templates.

The progression of what gets optimized in the harness:

prompts → structured context → workflow → harness code → optimizer code

As the model becomes more intelligent, we move toward more complex optimization targets and more generic methods.

Harness Design Patterns

Three recurring patterns across successful harness systems:

  1. Workflow Automation — Goal-oriented loop: plan → execute → observe/test → improve → repeat until goal achieved. The coding agent loop (Observe repo → Plan → Search/read files → Edit/write patches → Run tests → Inspect errors → Repeat) is the canonical instance.
  2. File System as Persistent Memory — Don’t carry entire workflow and logs in context; keep durable state in files. Artifacts (experiment logs, code diffs, error traces, past trajectories) grow beyond context windows; file I/O is a foundation skill that benefits from improvements in core model capability.
  3. Sub-agent and Backend Jobs — Spawn parallel subagents, monitor backend jobs, merge results. Key design choice: make parallelism explicit and inspectable — store outputs as files/logs/status records, not transient chat context.

Context Engineering

Three escalating approaches to context optimization:

ACE (Agentic Context Engineering) — Zhang et al. 2025

Treats context as an evolving playbook of bullet points (identifier + description). Three components:

  • Generator: produces task trajectories referencing bullets.
  • Reflector: distills insights from successful/failed trajectories.
  • Curator: updates structured context with incremental, itemized entries (not full rewrites — prevents context collapse and brevity bias).

MCE (Meta Context Engineering) — Ye et al. 2026

Separates mechanism (how to manage context) from artifact content (what is in context). Bi-level optimization:

  • Inner loop: optimize context function cs given a skill s.
  • Outer loop: evolve the skill itself via agentic crossover over a skill database k1.

A skill defines a context function cs=(ρs,Fs) with static components (prompts, knowledge bases, code libraries) and dynamic operators (search, selection, filtering, formatting). Implementation uses standard coding-agent tools: {Read, Write, Edit, Bash, Glob, Grep, TodoWrite}.

Meta-Harness — Lee et al. 2026

Moves deeper: the optimized object is the code that determines what information should be stored, retrieved, and presented to the model. The proposer is itself a coding agent; output is a collection of harness candidates on the Pareto frontier. Execution history accessible via filesystem — the coding agent uses grep/cat to read through it rather than shoveling everything into a single prompt.

Workflow Design

Expert-designed workflows

  • AI Scientist (Lu et al. 2026, Nature) — pipeline for idea generation → experimentation → paper writing → review.
  • ScientistOne (Meng et al. 2026) — verifiability as central constraint; Chain-of-Evidence checks for every claim.
  • Autodata (Kulikov et al. 2026) — challenger/solver/verifier roles; synthesizes data at “just right” difficulty (strong solver succeeds, weak solver fails). Limitation: weak solver improves via fine-tuning but strong solver doesn’t — more like indirect distillation than full RSI.

Workflow as search problem

  • ADAS (Hu et al. 2025) — meta-agent search: initialize archive of simple agents (CoT, self-refine); meta-agent programs new workflows in code; self-refine for novelty; evaluate and archive.
  • AFlow (Zhang et al. 2025) — workflow as graph (nodes = LLM actions, edges = code logic); MCTS-based optimization. Showed improvement over both manual workflows and ADAS on QA, code, and math tasks.

Self-Improving Harness

STOP (Self-Taught Optimizer) — Zelikman et al. 2023

Recursively improves the improver function I itself: It=It1(u^,It1;M). Discovered strategies include genetic algorithms, simulated annealing, beam/tree search, multi-armed bandits.

Cautionary result: improved mean performance with GPT-4 but degraded with GPT-3.5 and Mixtral. The base model must be capable enough to improve the mechanism — intelligence remains core.

Self-Harness — Zhang et al. 2026

Propose-evaluate-accept loop with three stages:

  1. Weakness mining — cluster failures into verifier-grounded failure patterns (distinguish surface verifier outcome from causal mechanism).
  2. Harness proposal — bounded edits based on failure patterns; proposals must be distinct and diverse.
  3. Proposal validation — regression tests on held-in Din (weakness resolved?) and held-out Dout (no new regressions?); accepted edits merged, rejected logged.

Tested on MiniMax M2.5, Qwen3.5-35B-A3B, GLM-5 on TerminalBench-2; learns model-specific harness instructions.

Darwin Gödel Machine (DGM) — Zhang et al. 2025

Evolutionary harness code evolution under a fixed model:

  1. Start with one coding agent in the pool.
  2. Select parent proportional to performance, inversely to offspring count.
  3. Parent examines its own evaluation logs, proposes improvements to its own harness codebase.
  4. New agents evaluated; high-performers added back.

With Claude 3.5 Sonnet: SWE-bench Verified 20% → 50%, Polyglot 14.2% → 30.7%.

Follow-up: Hyperagents (Zhang et al. 2026) — meta-agent controls how to modify task agents.

  • AlphaEvolve (Novikov et al. 2025) — coding-agent evolutionary search; stores pool of candidate programs; LLMs generate diffs for improvement. Code regions marked with # EVOLVE-BLOCK-START/END. Meta-prompt co-evolves with instructions.
  • Promptbreeder (Fernando et al. 2023) — evolves task prompts + mutation prompts themselves.
  • GEPA (Agrawal et al. 2025) — reflection-based prompting + evolutionary search.
  • ThetaEvolve (Wang et al. 2025) — combines evolutionary search with RL and in-context learning.
  • ShinkaEvolve (Lange et al. 2025) — improves sampling efficiency: balanced parent sampling, code-novelty rejection, meta-scratchpad for good patterns.

This family works well when evaluation is fast and fitness quantifiable (matrix multiplication, GPU kernels, algorithm contests). Struggles with slow/ambiguous evaluation domains.

Joint Optimization with Model Weights

SIA (Hebbar et al. 2026) — combines harness improvement and model-parameter updates:

  • Meta-Agent: proposes initial harness.
  • Task-Specific Agent: executes tasks.
  • Feedback-Agent: decides whether to update harness or model weights.

Author notes confounding choices in experiments (task agent much weaker than meta/feedback agents: gpt-oss-120b vs Claude Sonnet 4.6). Direction interesting, evidence provisional.

Weng’s Prediction on Near-Term RSI

  1. Harness engineering evolves toward meta-methodology — improving the machinery for getting better answers, not just the answer itself. Fewer heuristic rules, more general mechanisms.
  2. Mature harnesses enable auto-research for model self-improvement loops; smarter models prevent overengineering and keep systems sustainable.

Eventually many harness improvements will be internalized into core model behavior (as happened with prompt engineering → instruction tuning), but the interface with external context and tools should remain.

Seven Future Challenges

  1. Weak and fuzzy evaluators — many real-world tasks lack fast, precise verifiers.
  2. Context and memory lifecycle — memory grows with autonomy; context engineering should become part of intelligence, not just the software layer.
  3. Negative results — literature biased toward success; models bad at abandoning hypotheses.
  4. Diversity collapse — evolutionary/RL loops exploit known high-reward patterns.
  5. Reward hacking — optimizes whatever signal given; evaluator and permission control should sit outside the optimization loop.
  6. Long-term success — current optimization goals too short-term (task completion vs. repo health, maintainability, backwards compatibility).
  7. The role of humans — humans should move up the stack, not be removed; provide oversight at the right time, at the right abstraction level.

Failure Modes of Auto-Research (Trehan & Chopra 2026)

Six recurring failures when LLMs attempt full research pipelines:

  • Bias toward training-data defaults (old libraries, stale commands).
  • Implementation drift under execution pressure (simplifies to common solutions).
  • Memory and context degradation in long-horizon projects.
  • Over-optimism (declares success despite noisy/failed experiments).
  • Insufficient domain intelligence (lacks tacit craft knowledge).
  • Weak scientific taste (executable but doesn’t answer the right question).

Key Benchmarks Surveyed

PaperBench, CORE-Bench, ScienceAgentBench, RE-Bench, MLE-bench, KernelBench — all measuring various aspects of AI research/engineering capability. Best agents still underperform human experts at longer time horizons (RE-Bench: agents 4× better than humans at 2h, but humans exceed agents at 8h+).

Notable Quotes

“Code is a universal language for defining programs and systems. A harness is code that programs how prompts, tool calls, subagents, control flow, memory, and workflow logic work together.”

“The evaluator and permission control should likely sit outside the loop that evolves harness, with held-out tests, trace audits, and human review at decision points that matter.”

Open Questions

  • How much of the RSI loop can run without human oversight before quality degrades?
  • Can MCE/Meta-Harness-style optimization remain stable across many iterations, or does it hit diminishing returns / reward hacking?
  • What’s the minimum base-model capability threshold for productive self-improvement (STOP’s cautionary result)?
  • How to build evaluators for “scientific taste” and long-term repo health?

Referenced by 17

2026-04-27-the-second-half-of-ai 2026-06-04-llm-powered-autonomous-agents harness-why-it-matters-now agent-evaluation agent-loop agentic-context-engineering context-engineering eval-grader-reward evolutionary-search-llm harness llm-agent meta-context-engineering meta-harness recursive-self-improvement reward-hacking self-improving-harness lilian-weng
esc