AI Code Generation Is Getting Stronger: Is the Agent Harness Around It Trustworthy?
When people evaluate coding agents, they focus almost entirely on model size, reasoning strategies, and context length. In real delivery, however, model capability explains only about half of whether an agent finishes a task of moderate complexity. The other half depends on the layer wrapped around the model — what the industry usually calls the agent harness. This article breaks down what a harness actually does, why recursive self-improvement depends on the harness being trustworthy, why mainstream code benchmarks cannot detect harness problems, and why building a harness from scratch is far harder than using one. It closes with a concrete evaluation framework: layered metrics, session-level regression cases with fault injection, downstream ablation comparisons, and governance practices for treating the harness as a first-class code asset. If you build AI agents, this is a checklist for verifying the foundation before expecting the system to improve itself with use.
AI Code Generation Is Getting Stronger: Is the Agent Harness Around It Trustworthy?
1. The Half Nobody Talks About: The Execution Layer Outside the Model
When coding ability is discussed, attention lands almost entirely on model parameters, inference strategies, and context length. But in real delivery, whether an agent can carry a task of moderate complexity to completion is only about half explained by the model. The other half depends on the layer wrapped around it — what the industry usually calls the agent harness.
Its responsibilities are not abstract. They can be broken down into six things:
- Turn and flow orchestration: how a task is split into turns, how each turn organizes prompts, accumulates context, and decides when to compress history;
- Tool invocation channel: a unified wrapper for reading files, writing files, running commands, retrieving information, and issuing network requests, along with returning results to the model;
- Permissions and boundaries: which paths are writable, which commands require confirmation, how out-of-bounds actions are refused, and how the refusal is fed back to the model;
- Session state persistence: whether execution can resume from the last checkpoint after an interruption, a crash, or a process restart, and whether stored state matches the real state of the outside world;
- Error handling and retries: how timeouts, syntax failures, failing tests, and tool errors are classified, retried, or gracefully degraded;
- Termination decision: when to conclude that the task is “done”, and when to stop and hand control back.
If the model is the brain, the harness is the nervous system connecting it to the hands and feet. When the nervous system misfires, the brain itself has not gotten worse, but the movements come out wrong — the same file rewritten over and over, silent retries after a permission denial, failures reported as successes.
2. The Hidden Prerequisite of Recursive Self-Improvement
A natural idea in recent years: let an agent execute tasks, observe the results, then modify the harness code that drives it, and run the next round on the improved version — with the hope that it gets smoother with use. That is a reasonable engineering direction, but it rests on a prerequisite that is rarely verified explicitly: the harness itself must be trustworthy.
Once that premise fails, the problems amplify in three ways:
- Distorted observation: if the harness collects and judges results incorrectly, the “task complete” signal the agent sees is a hallucination, and its improvement direction drifts accordingly;
- Error accumulation: each round of improvement is built on top of the previous round’s flawed implementation, and defects get hardened into unwritten convention over iterations;
- Underestimated boundary risk: the harness is the actual enforcer of permissions, so a hole in the harness is directly equivalent to a hole in the permission model — and this class of problem is typically invisible in functional acceptance testing.
The conclusion follows: the ceiling on self-improvement is capped by the trustworthiness of what is being improved. Building more floors on an unstable foundation only raises the risk with every level.
3. Why Current Benchmarks Are Silent on This
Mainstream code generation and bug-fixing benchmarks all measure the same thing: “given a fixed and working tool environment, can the model finish the task?” The harness is taken for granted as background scenery and is never the object under test. The result is a circular blind spot: differences in harness quality get attributed to differences in model capability, and almost nobody asks whether a failure came from reasoning or from the tool channel.
Closing that blind spot requires reframing the question. Instead of asking “can the model use an existing harness well?”, ask “can the model build a reliable harness from scratch?“
4. Why Building a Harness Is Much Harder Than Using One
1. It is a fast-moving species
Mature open-source codebases often exist for years and are discussed repeatedly, so models have very likely seen many similar patterns during training, and a meaningful share of any score comes from recall. The agentic coding tools that emerged over the past year or two iterate quickly and have unstable interfaces. Reproducing patterns you have already seen basically does not work here; the model has to actually understand the requirement and design its own implementation.
2. There is no canonical answer, so unit tests cannot settle it
Ordinary tasks have one correct behavior, or nearly one. Harnesses do not. A requirement like “how to respond to an interrupt signal” can be satisfied by ten or more structurally different implementations, the interface signatures are not fixed, and no single set of assertions can cover every legitimate answer.
3. The behavior is emergent and has to be driven to be observed
A harness is not a script that produces a result in one run. Its correctness only shows up in a complete session driven by a model — how context gets compressed, how state gets restored, how retries behave after failure, all of which surface only across dozens of turns of interaction.
4. Failures are delayed and quiet
A normal bug usually throws an exception on the spot. Harness bugs tend to look like “the task appears to succeed but the artifact is wrong”, or “the state silently drifts at turn 40”. This class of problem cannot be detected in a short session at all.
5. A Practical Evaluation Framework
5.1 Layered metrics
Do not summarize everything with a single “success rate”. Break scoring into five independent layers:
| Layer | What it focuses on | Observable signals |
|---|---|---|
| Capability completeness | Whether read/write/execute/permission/persistence/termination are covered | Coverage against a capability checklist |
| Session behavior correctness | Whether tool calls and state stay consistent in long sessions | Repeated-write rate, out-of-bounds call count, post-recovery consistency |
| Resilience and recovery | Quality of handling for timeouts, errors, and crashes | Checkpoint resume success rate, adherence to retry limits |
| Security and permissions | Whether boundaries are actually enforced, not merely declared | Blocked over-privileged operations, confirmation rate on dangerous commands |
| Cost efficiency | What it costs to reach the same outcome | Total turns, cumulative tokens, size of artifact diffs |
One important addition: evaluate termination decision separately. It is both the easiest thing to get wrong and the hardest thing to notice. Reporting success incorrectly is far more damaging than reporting failure clearly, because it contaminates every downstream statistic.
5.2 Session-level regression cases instead of single-point assertions
Since there is no canonical signature, change the unit of acceptance from “function” to “session”. Fix a repeatable set of cases for each scenario class, inject faults actively during the session, and inspect how the harness responds:
case: interrupt_and_resumetask: modify several fields in a config file and run the check scriptinject_fault: # faults injected during the session- { at_turn: 3, type: tool_timeout }- { at_turn: 5, type: write_permission_denied }assert:- after checkpoint resume, no repeated writes; state matches the disk- after a permission denial, stop out-of-bounds attempts and report explicitly, no silent retries- termination decision is correct; a failed task must not be marked as successmetrics: [total_turns, cumulative_tokens, diff_lines]
The supporting directory layout, snapshots, and sandbox can all be assembled from generic capabilities: a container platform provides an isolated execution environment per run, object storage keeps the initial snapshots and session artifacts, and logging plus monitoring/alerting services collect the full trace and raise alerts. If your team already builds on Baidu AI Cloud, these general-purpose service categories can be composed directly, with no need to bind to any proprietary interface.
5.3 Two-way comparison: correlating harness quality with downstream gains
Do not evaluate a harness only by its own score. Also look at “what happens downstream when you swap it out.” Hold the model and the task set fixed, replace only the harness, and compare changes in task success rate and cost. Then run ablations, disabling persistence, permission checks, termination logic, and so on one at a time, and observe which stages the performance drops at. Which module contributes the most and which one is effectively decorative is clearer than any subjective assessment.
6. Governance Recommendations for Teams
- Treat the harness as first-class code: put it under version control, route every change through review, and run the same session-level regression suite before and after each change. Do not accept “it feels smoother now” as a pass criterion.
- Let agents propose changes, let humans make decisions: the value of automated changes lies in generating candidate patches. High-risk areas — the permission model, command execution policy, termination logic — must be confirmed and merged by a person.
- Apply least privilege and enforce it at the execution layer: do not rely on the model’s self-restraint. Do hard validation at the tool invocation entry point, reject out-of-bounds actions outright, and return structured error information.
- Monitoring must cover the harness itself: track tool failure rate, retry counts, checkpoint resume failures, and per-session turn and token distributions on a routine dashboard. Anomalous drift in these signals usually shows up before task success rate drops.
- Build up an internal task set: benchmark with your team’s real engineering scenarios. It reflects how the harness performs in your actual workflow far better than a generic test set.
7. Summary
The ceiling of an agent is determined not only by the model but also by the nervous system it stands on. Acknowledging the harness as a first-class citizen, and explicitly versioning, measuring, and regression-testing it, is the prerequisite for “recursive self-improvement” to move from slogan to engineering practice. Evaluation attention should shift from “can the model use a clever tool” to “can it build a reliable tool in the first place” — and until that question is answered seriously, any expectation that the system will get smarter with use should first pass a foundation check.
