Skip to content

Checking your reading list…

Retry

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Self-Harness: AI Agents That Self-Optimize Their Own Harnesses

The Self-Harness framework enables LLM agents to autonomously discover weaknesses in their operating harnesses, propose targeted modifications, and validate improvements through a three-stage iterative loop without human engineers or stronger external models, achieving up to 138% relative pass-rate gains on Terminal-Bench-2.0 across three model families.

1. Why Self-Harness Is Needed

1.1 What Is a Harness?

An LLM agent's performance is determined by two components: the Base Model (e.g., Claude, Qwen, GLM) and the Harness — the surrounding system that wraps the model, including system prompts, tool definitions, runtime mechanisms, verification rules, orchestration logic, and failure-recovery flows. The same model can behave dramatically differently under different harnesses.

1.2 Bottlenecks of Manual Harness Design

Current harnesses (ReAct, Claude Code, Codex, OpenHands) are almost entirely hand-crafted. This "manual tuning" faces three core problems:

Model specificity : Different models have vastly different behavioral habits (e.g., some loop on tool calls, some forget to generate output files, some give up on errors). A harness tuned for model A may backfire on model B.

Rapid model iteration : LLMs are replaced every few months; harness adaptation cannot keep pace.

Human bandwidth : Engineers cannot manually tune a dedicated harness for every model.

1.3 Shortcomings of Existing Approaches

Self-improvement methods (Reflexion, STOP) adjust memory, context, or response strategies — not the harness itself .

External optimization (Meta-Harness) uses a stronger model to optimize a weaker model's harness — but stronger models are costly, and for frontier models no stronger external model exists.

2. Self-Harness Core Idea: A Three-Stage Iterative Loop

Core insight : Instead of relying on humans or stronger models, let the agent itself improve its harness — run under current harness → discover failure patterns → propose modifications → validate and adopt only those that pass.

Self-Harness three-stage loop diagram
Self-Harness three-stage loop diagram

2.1 Stage 1: Weakness Mining

Goal : Extract structured failure evidence from execution traces, not vague "something went wrong".

Process :

Run current harness on a held-in dataset.

Collect all failed execution traces.

Cluster failures by verifier-level failure signatures : c = terminal verifier reason (e.g., "missing required artifact") q = causal link between agent behavior and failure (e.g., "agent declared completion without creating file") m = abstract mechanism exposed by trace (e.g., "tool-use loop stuck")

Key design : Output is an Evidence Bundle describing what failed and why , without prescribing how to fix it . This separates diagnosis from prescription.

2.2 Stage 2: Harness Proposal

Goal : Generate diverse candidate modifications grounded in the failure evidence.

Design points :

Parallel generation of K proposals , each independently exploring a different modification direction.

Diversity across proposals : different failure mechanisms → different harness modification surfaces → different hypotheses.

Minimality within a proposal : change only what is necessary, leave unrelated parts untouched, avoid large-scale rewrites.

Each proposal outputs a bounded edit Δ plus an audit record a.

2.3 Stage 3: Proposal Validation

Goal : Adopt only modifications that genuinely improve generalization.

Validation uses a conservative promotion criterion — a candidate harness must not regress on either held-in or held-out splits , and must improve on at least one :

Δ_held-in ≥ 0 AND Δ_held-out ≥ 0 AND max(Δ_held-in, Δ_held-out) > 0

This means:

Overfitting to held-in (training set) but failing held-out → rejected .

No change on held-in but improvement on held-out → accepted .

Improvement on both → accepted .

Multiple compatible candidate edits can be merged into the next harness version.

3. Experimental Results

3.1 Experimental Setup

Benchmark : Terminal-Bench-2.0: 89 containerized terminal tasks, fixed 64-case evaluation

Models : MiniMax M2.5, Qwen3.5-35B-A3B, GLM-5

Initial Harness : Minimal DeepAgent Harness (short system prompt + default file/shell tools)

Metric : Pass (%) — proportion of tasks passing the verifier

3.2 Main Results

Held-out results:

MiniMax M2.5 : Initial Pass 40.5% → Self-Harness Pass 61.9% (+21.4pp absolute, +53% relative)

Qwen3.5-35B-A3B : Initial Pass 23.8% → Self-Harness Pass 38.1% (+14.3pp absolute, +60% relative)

GLM-5 : Initial Pass 42.9% → Self-Harness Pass 57.1% (+14.2pp absolute, +33% relative)

Held-in results:

MiniMax M2.5 : Initial Pass 43.0% → Self-Harness Pass 50.0% (+7.0pp absolute, +16% relative)

Qwen3.5-35B-A3B : Initial Pass 15.1% → Self-Harness Pass 36.0% (+20.9pp absolute, +138% relative)

GLM-5 : Initial Pass 47.7% → Self-Harness Pass 57.0% (+9.3pp absolute, +20% relative)

Pass rate comparison chart
Pass rate comparison chart

Key findings :

All three models from different families achieved significant held-out gains .

Maximum absolute gain: 21.4pp; maximum relative gain: 138%.

No adopted harness caused regression on any split .

3.3 Different Models, Different "Prescriptions"

Self-Harness does not apply a universal prompt; it tailors fixes to each model's specific weaknesses:

MiniMax M2.5 : Primary weaknesses — missing required artifacts, invalid schema in tool content, tool-use loops stuck. Self-Harness measures — create output artifacts early, handle structured tool content more cautiously, redirect execution after prolonged tool interactions.

Qwen3.5-35B-A3B : Primary weaknesses — missing artifact checks, unable to recover from errors, undisciplined retries. Self-Harness measures — add dependency pre-checks, loop interruption, tool-error-triggered recovery middleware.

GLM-5 : Primary weaknesses — environment changes not persistent, over-exploration without execution. Self-Harness measures — persist installed tools/paths across shell sessions, encourage shift from exploration to implementation and testing.

Common theme : All three models needed improved Artifact Reliability , but the root causes and fixes differed per model.

4. Case Studies: Concrete Harness Changes

Case 1: MiniMax M2.5 — From "Endless Exploration" to "Focused Execution"

Task : count-dataset-tokens (calculate dataset token count)

Initial Harness behavior : Repeatedly explored dataset metadata, exhausted tool-call budget, never generated answer file.

Optimized Harness behavior : Identify required output artifact → locate relevant metadata → compute result → write answer file → read back to verify.

Key changes : Bootstrap instruction changed to "identify required output artifact and create initial version early"; runtime strategy added tool-message total count limit.

Case 2: Qwen3.5 — From "Delete Files and Give Up" to "Error Recovery"

Task : extract-elf (extract ELF information)

Initial Harness behavior : After repeated parsing failures, deleted the required artifact file, ultimately failing verification.

Optimized Harness behavior : Tool error triggers system prompt → recreate extractor → fix parsing logic → retain required artifact file.

Key changes : Added tool-error-triggered recovery mechanism — on tool failure, automatically redirect to recovery flow instead of abandoning.

Case 3: GLM-5 — From "Install and Forget" to "Environment Persistence"

Task : build-pov-ray (build renderer)

Initial Harness behavior : Installed dependencies in one shell command, environment lost in next command; repeated downloads wasted budget; declared completion despite sanity-check failures.

Optimized Harness behavior : Phased bounded operations → verify external archive evidence before proceeding → fix sanity checks before completing.

Key changes : Harness instructions ensure environment changes persist across shell sessions, and encourage transition from exploration to implementation and testing.

5. Core Design Principles Extracted from the Paper

Principle 1: Harness Improvement = Empirical State Transition

A valid harness edit must explicitly declare:

Target behavior : what behavior it aims to change

Modification surface : which part of the harness it changes

Evidence : what failure evidence motivated the change

Evaluation result : what test results prove the change deserves adoption

Principle 2: Separate Diagnosis from Prescription

The weakness-mining stage outputs only "what failed", not "how to fix". This avoids premature convergence to local optima.

Principle 3: Parallel Multi-Proposal + Minimal Edits

Multiple proposals explore in parallel, avoiding "only one fix idea".

Each proposal stays minimal, avoiding "ripple effects".

Principle 4: Regression Testing + Dual-Split Guardrails

Any change must not regress on both training and validation splits.

Prevents "overfitting to the training set" style gaming.

Analogous to CI/CD pipelines in software engineering.

Principle 5: Harness ≠ Prompt Engineering

Harness is a broader concept than prompt — it includes tool definitions, runtime mechanisms, verification rules, orchestration logic, failure-recovery flows, etc. Many agent failures are harness problems, not model problems :

Report success without checking artifacts → missing verification mechanism

Repeatedly retry futile operations → missing loop-interruption mechanism

Environment changes lost → missing persistence mechanism

Give up on error → missing recovery flow

6. Limitations and Future Directions

Limited scope : Validated only in bounded harness-editing scenarios on a fixed benchmark, not open-ended self-improvement.

Benchmark specificity : Adopted edits may reflect benchmark-specific failure patterns; generalization needs further verification.

Verifier dependence : Protocol relies on verifier quality and trace recording quality.

Safety bar : High-stakes scenarios require stricter admission standards than "no pass-rate regression".

Future direction (from paper): Move toward a "recorded, testable, rollback-capable" harness engineering style — self-improvement should be grounded in behavioral evidence , not just proposer's arguments about "plausibility".

7. Takeaways for Agent Engineers

Self-Harness's core lesson: Harness improvement should be treated as an empirical state transition.

For practitioners building agents, this paper offers at least three actionable insights:

Don't stare only at the model — when an agent underperforms, first check whether the harness provides the right behavioral constraints and recovery mechanisms.

Let the data speak — use execution traces for evidence-driven harness iteration, not prompt tweaking by intuition.

Tests guard the baseline — every harness change must have regression-test protection to prevent "fix one bug, introduce three".

Based on the paper "Self-Harness: Harnesses That Improve Themselves" (https://arxiv.org/pdf/2606.09498), written from an engineer's perspective to distill core ideas and practical design principles. Corrections welcome!

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

LLMAI AgentSelf-ImprovementHarness EngineeringTerminal-BenchSelf-HarnessProposal ValidationWeakness Mining

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion