Harness²: Teaching AI Agents to Patch Their Own Execution Scaffolds
As models converge in capability, the execution scaffold around them — the harness — has become the real differentiator. This article explains what a harness is, why manually tuning it hits two walls (offline optimization without adaptability, online adaptation without ground truth), and how Harness² — the harness that improves the harness — can be made reliable through proxy verifiers, A/B comparison, rollback, small structured patches, and signal aggregation. It closes with the engineering practices that turn a harness into a maintainable, versioned asset rather than a matter of guesswork.
It starts with the bare-metal programmer: capability comes from more than the model
Picture a top-tier programmer dropped into a bare-metal environment with no code completion, no documentation, no version control, and no automated tests. Ask that person to hand-write a basic feature and they may struggle even to handle edge cases correctly. Now give them an IDE, version control, automated tests, and a clearly written set of team conventions, and the same person’s productivity changes dramatically.
People work this way. So do AI agents. An increasingly accepted view in the industry is this: the ceiling on a large language model’s capability depends not only on how “smart” the model is, but on the “work manual” built around it. The model is the engine; the manual determines how the engine is ignited, how it is constrained, and how it is reused.
Researchers call this manual the harness. This article uses Harness² — read as “harness squared” — to discuss a more fundamental point: instead of tuning the harness once, let the harness learn to optimize the harness, closing a recursive loop of self-improvement.
What a harness is: the execution scaffold of an agent
A harness does not change the model’s parameters. It determines how the model gets used. A complete harness is typically assembled from the following parts:
- System prompt: defines the role, goals, output format, and behavioral boundaries.
- Guardrails: restrict dangerous operations, sensitive data leakage, and unauthorized calls.
- Long-term memory: accumulates context, preferences, and past decisions across sessions.
- Skill library: reusable atomic capabilities such as retrieval, computation, and code execution.
- Tool manifests: tell the model which tools exist, what parameters they take, and when to use them.
- Scripts and plugins: glue logic, orchestration flows, and integration with external systems.
- Sub-agents: hand complex tasks off to specialized subordinate agents that run in parallel.
The value of all this is that it turns a language model that “only predicts the next token” into an execution entity that can plan, call tools, and correct itself. And the quality of the harness often directly determines how far an agent can go.
From harness to Harness²: recursive self-improvement
Traditional harnesses are written and tuned by engineers by hand. The core claim of Harness² is this: since the harness matters so much to the agent, it should not depend on humans running trial and error over and over. The agent should observe its own performance at runtime and proactively patch the harness.
The key lies in the “squared” metaphor:
- The first layer of harness lets the agent do the task well.
- The second layer (Harness²) lets the agent learn to modify the first-layer harness itself, so it does better on the next task.
This is a recursive structure. What gets modified is not the model parameters but the scaffold that determines how the model is used. Ideally, the harness would evolve like a self-iterating open source project, accumulating patches, banking experience, and fixing defects over time.
The core problem: two old paths and the walls each one hits
To understand what makes Harness² hard, it helps to look first at the two existing approaches to improving a harness, and the wall each of them runs into.
Offline optimization: there are answers, but no improvisation
The first path is offline optimization. You take a batch of training tasks with reference answers, run trial and error repeatedly, search for the harness configuration that performs best, and then freeze it for deployment. Its strength is that it has an explicit validation signal — right and wrong, high and low scores, are all written into the labels, so the optimization objective is clear and gradients are computable.
Its limitation is equally obvious: a training set can only cover so many scenarios. Once the agent meets open-ended tasks in production that it never saw during training, a frozen harness is often a poor fit. Offline optimization tunes “average performance,” not “the task in front of me.”
Online adaptation: it can improvise, but there are no reference answers
The second path is online adaptation: the harness adjusts dynamically in the real runtime environment, adapting as tasks change. The idea is appealing, but it runs into an even harder wall — there are no reference answers.
The new tasks an agent encounters in the field are usually open-ended: write a research report, optimize a business process, troubleshoot a production incident. Nobody tells the agent up front whether it did the job correctly this time, and there is no objective verifier to score it. The agent can only infer quality from the fragments it observes during execution, and that kind of signal is easily skewed by noise.
The result: a harness that looks reasonable but is actually worse. This is not just a theoretical concern. On one open-ended task benchmark, a typical online contrastive method scored about 6.6 percentage points lower on coding tasks than the original harness with no changes at all. That is a clear sign that online self-modification without reliable feedback can do more harm than good — patching a serviceable scaffold into a worse one.
Making patches evidence-based: feedback signals and verifier design
The fundamental difficulty of online adaptation is the trustworthiness of the feedback signal. To keep the harness from drifting when it modifies itself, you need a verifiable basis for judging whether a change is an improvement. In practice, engineering usually starts from a few directions:
Build proxy verifiers. Even without an ultimate answer, you can design cheap, stable proxy metrics — did the task run to completion, does the output satisfy the format constraints, did the unit tests pass, were the guardrails triggered. These signals are imperfect, but far more reliable than “feeling good about it.”
A/B comparison and rollback. Any change to the harness should first be compared against the baseline in a small traffic slice or a shadow environment, and promoted to full rollout only after confirming a real improvement; if metrics regress, it should roll back with a single switch. In effect, this brings “version control plus regression testing” discipline to the harness.
Reduce the size of each change. Rather than letting the agent rewrite the entire harness at once, have it produce small structured patches — appending one skill, revising one prompt rule — with the reasoning attached, so the change is easy to review, locate, and revert.
Suppress noise and aggregate signals. The success or failure of a single trajectory is a matter of chance. Aggregate statistically across multiple runs of multiple similar tasks, dilute the noise with a large enough sample, and only then decide whether to freeze the change in.
A sketch of what such a patch loop looks like:
# Pseudocode: a harness self-modification loop with comparison and rollbackdef self_patch(harness, tasks, verifier, min_samples=5):baseline_score = evaluate(harness, tasks, verifier)proposal = agent.propose_patch(harness) # produce a small structured patchif not is_safe(proposal, harness.guardrails):return harness # safety check failed, discardcandidate = harness.apply(proposal)candidate_score = evaluate(candidate, tasks, verifier,samples=max(min_samples, N))if candidate_score > baseline_score + margin:log_and_archive(proposal, delta=candidate_score - baseline_score)return candidate # real improvement, acceptelse:return harness # regression or flat, roll back to baseline
The core idea: treat self-modification as a code change that needs review, not an improvised on-the-spot decision.
Engineering it: turning the “work manual” into a maintainable asset
For Harness² to run in production, the harness itself has to be managed like a software asset. You can lean on capabilities that are standard across cloud platforms rather than depending on any one proprietary product:
- Version and configuration management: put prompts, skills, and tool manifests under version control, so any change can be diffed, rolled back, and traced to its author and rationale.
- Container platform: package the agent’s runtime, dependencies, and middleware into reproducible images, so the offline evaluation environment matches the online runtime environment and you avoid “works in testing, breaks in production.”
- Logging service: record every step’s inputs, tool calls, intermediate artifacts, and final output, providing raw material for post-hoc analysis and signal extraction.
- Monitoring and alerting: set threshold alerts on key metrics (task success rate, guardrail trigger rate, average number of steps, latency) so harness regressions surface quickly.
- Object storage: archive historical tasks, the experience base, and the patch history, giving cross-session long-term memory and skill reuse something to live in.
- Message queue: decouple and throttle work in multi-agent and sub-agent architectures, making parallel execution more robust.
Stack these common capabilities together and what you get is essentially a “CI/CD plus observability” system for the harness. Once the manual has versions, regression tests, and monitoring, self-modification stops being mystical parameter fiddling and becomes a measurable engineering iteration.
A practical checklist
- Establish feedback before enabling self-modification. Without a trustworthy verifier, do not let the agent freely rewrite the harness; it will most likely make things worse.
- Small patches, plus comparison, plus rollback. Keep each change scoped narrowly and always retain a baseline you can return to.
- Distinguish offline freezing from online adaptation. Offline work is for baking stable best practices into default configuration; online adaptation is only for distribution drift and long-tail tasks.
- Give the harness tests of its own. Write regression cases for critical prompt rules, tool-calling conventions, and guardrail policies, so self-modification cannot silently introduce regressions.
- Set permission boundaries on self-modification. Changes touching guardrails, permissions, or external write operations should go through human review rather than being fully automated.
- Watch cost and latency. A more elaborate harness usually means more tool calls and longer chains, so trade off effectiveness against overhead.
Conclusion
Harness² highlights a fact that is easy to overlook: as model capabilities become more homogeneous, what actually separates agents is the execution scaffold built around them — and whether that scaffold can evolve. The most dangerous trap in “self-evolution” is modifying blindly when no reference answer exists. The fix is not to make the agent more aggressive about changing itself, but to give every change trustworthy feedback, controlled comparison, and a path back — replacing unstable intuition with measurable engineering discipline. Whoever can turn the harness into an asset that iterates sustainably is the one who keeps raising the ceiling on what their agents can do.
