AI Agent Harness: Why Code Quality Validation Belongs in the Loop (2026)

In this article:
Subscribe to our blog:

When an AI coding agent ships something broken, most engineering leaders still ask the same question: would a different model have done better? It's a natural instinct, and it used to be the right one.

Today, frontier models perform at nearly the same level on coding benchmarks, so the model is rarely what separates an agent that works from one that doesn't. The harness – the system that decides what the agent sees, what it can do, and how its output gets checked – does.

This article looks at what that harness does, why code quality deserves the same enforcement inside it that security already gets, and what a deterministic check like Codacy adds to the loop.

TL;DR

In most team setups, security findings block merges, while code quality remains advisory. Duplication and rising complexity don't fail a build, and agent-generated code adds more redundancy per change than human-written code. Codacy plugs into your existing harness as a deterministic check, returning the exact file and line of each issue so the agent fixes it before a human reviews the pull request.

What is a harness, in plain terms?

A harness is the execution system around an AI model that handles everything the model itself cannot:

  • Retrieving context
  • Calling tools
  • Managing permissions
  • Checking output
  • Carrying state across a task

The model does the reasoning, deciding what a piece of code should do and how to write it. The harness governs the operating conditions the model works within, deciding which files it can access, which commands it can run, whether a human must approve a given action, and what happens after the model produces an answer.

Thoughtworks' Birgitta Böckeler formalized the concept of harness engineering in an April 2026 article, treating harness design as a distinct engineering problem in its own right.

Böckeler's framework introduces a useful split between two kinds of controls.

  • Feedforward guides steer the agent before it acts: think of system prompts, architectural constraints baked into the codebase, or linter rules the agent can see in advance.
  • Feedback sensors observe after the agent acts and trigger a correction: think of a failing type check or a static analysis result the agent has to respond to.

A working harness needs both layers running together, steering the agent up front and catching what slips through afterward.

Why the harness matters more than model choice right now

The harness has become the primary variable separating agents that work reliably in production from agents that don't, because frontier models have converged on similar benchmark performance.

When LangChain rebuilt only the harness around its deepagents-cli coding agent and left the underlying model untouched, the agent's score on Terminal Bench 2.0 climbed from 52.8% to 66.5%, moving it to the top 5 on the leaderboard.

Separate benchmarking work has found the same pattern holding across other harnesses: identical models score very differently depending on the harness they're running inside. That's because the model and the harness are two different levers:

  1. A model upgrade changes how well the system reasons about a problem.
  2. A harness change alters what the system is allowed to do, what it knows about the environment it operates in, and what checks its output must pass before anything downstream trusts it.

This reframes the decision a leader is actually in a position to make. Model selection is something you can watch on a public leaderboard but can't meaningfully act on, since every vendor is racing toward the same ceiling and today's gap closes within a release cycle.

What verifies your agents' output is a question you own outright, and you can change the answer this week without waiting on anyone else's roadmap. That distinction matters more now than it did a year ago, because code volume from AI-assisted development keeps rising while the depth of human review per change keeps thinning.

The harness is where consistent enforcement either happens automatically on every change or quietly fails to do so.

What job is the harness actually doing?

The job that matters most here is applying independent quality gates to the model's output, catching noise, hallucinated logic, and quiet regressions before they reach a human reviewer or a production branch.

As agents take on more of the coding work and developers shift toward orchestration, the limit becomes clearer: a coding agent doesn't experience the discomfort a senior engineer feels when looking at a 300-line function. It has no memory of we don't do it that way here and no organizational history to draw on.

Left alone, the AI agent will keep generating code regardless of whether the output holds up, because nothing within the model checks for that.

Böckeler's framework draws a useful line between two kinds of checks here:

  • Computational controls are deterministic: a linter, a type checker, a test suite, something that runs the same way every time and produces a factual answer about the code.
  • Inferential controls rely on model judgment: another AI that reads the code and offers an opinion on whether it looks right.

Both have a place, but the deterministic layer is what the agent can't argue with, because a model judging another model's output can share the same blind spots. A cyclomatic complexity score (a count of the separate paths through a piece of code, where higher means harder to test and maintain) doesn't care how confident the explanation attached to it sounds.

The practical goal is straightforward: a well-built outer harness (the checks and rules your team adds around whatever agent you use) should increase the odds that the agent gets a task right on the first attempt, and it should provide a feedback loop that lets the agent self-correct before a human ever has to look at the change.

That second half is the part most teams skip, because it requires the harness to actually hand structured findings back to the agent rather than just logging them somewhere a person might eventually check.

Lack of quality validation in the harness conversation

In most team setups, security checks block merges, while quality checks remain advisory and are treated as a secondary concern rather than as something that belongs in the same conversation.

The case for treating code quality as a first-class harness concern is simple. Code that passes its tests but is hard to maintain is as much a failure as code with a security hole. Both create costs that someone else absorbs later, and both are the harness's job to catch.

Böckeler's own framework supports this. It names three distinct dimensions a harness can regulate: maintainability, architectural fitness, and behavior. The first category, maintainability, covers duplication, complexity, and test coverage – in other words, code quality.

The problem is real, not theoretical. A duplicated block of logic that an agent copies into three new places doesn't throw an error, and research has found that agent-generated code introduces more redundancy per change than human-written code, multiplying the surface area for the next bug and the next confused reviewer.

Catching quality problems becomes even more important now because change volume is up and review depth per change is down, which is the exact condition under which quality regressions accumulate without ever tripping an alarm.

A test suite failure stops a merge. A creeping complexity score does not, unless something is explicitly watching for it and treating it as a blocking signal rather than a chart nobody opens.

None of this is a call for another dashboard sitting next to the ones teams already ignore. It's a call for the same enforcement-at-the-point-of-change discipline that security checks already get in most harnesses, applied with equal seriousness to quality.

What this looks like concretely: A validation layer the harness calls out to

In practice, the harness shouldn't rely on the agent's own read of its work. It should call out to an external validation layer for an independent answer. Codacy is built to be that layer, working inside whatever harness you already run rather than replacing it.

c8-a8 diagram

The loop runs in a fixed sequence:

  • The agent proposes a change
  • The harness calls Codacy to check it
  • The agent fixes whatever Codacy flags as real
  • Codacy rechecks the result before anything is considered done.

That is the same plan-execute-verify shape teams already use for functional correctness, applied to quality instead.

The Codacy MCP Server works alongside the Codacy Analysis CLI so an agent can run analysis locally and see the exact repository location of each issue it needs to address, rather than relying on its own self-assessment of whether the code looks fine.

The CLI reports on the overall grade, categorized issues (such as error-prone and unused code), duplication, and complexity. More importantly, it points the agent to the exact file and line of each issue, instead of leaving it with a vague instruction to "clean this up," and outputs its findings in machine-readable formats the harness can pass straight back to the agent.

Coverage works slightly differently. The Analysis CLI doesn't compute it because determining which lines tests actually reach requires running those tests. But when coverage is configured on Codacy.com, the Codacy Cloud CLI can tell the agent whether an open pull request is failing its coverage gate, so the agent can see exactly which critical code lacks tests and address it directly.

The property that makes this loop trustworthy is that the signal comes from outside the model doing the work.

Because the underlying code analysis provides an external computational check, the agent isn't relying solely on its own judgment about whether its output is sound, nor is the human who eventually reviews the pull request.

What should a team look for in their own setup?

Five questions, put directly to your team, will show you where your current setup stands:

  • Is anything independent verifying what the agent produces, or does the agent assess its own output? If the only reviewer in the loop is the model itself, there's no real sensor, just the same reasoning that produced the code checking its own homework.
  • Are quality signals treated as ground truth the agent must respond to, or as advisory reports a human skims later? Advisory reports that sit in a dashboard nobody opens don't enforce anything. They just document the decay after the fact.
  • Do the checks cover maintainability and complexity, not only security? A harness that's blind to quality will ship technical debt silently while every security scan comes back green.
  • Are the checks consistent across all repositories and agents, or do they depend on who happened to set up which project? Inconsistent enforcement behaves the same as no enforcement once you're running agents across more than a handful of repositories.
  • Does the feedback reach the agent early enough for it to self-correct before human review? A check that only fires after a human has spent time reading the change has already cost you the thing the harness was supposed to save.

The sharper conversation to raise with your team isn't which model to standardize on. It's a direct question about what's actually checking the output your agents produce, and whether the answer would hold up if said out loud in a review meeting.

The Harness Is the Thing You Can Actually Change

Model choice is largely settled by convergence at this point, and the harness around whatever model you're running is where reliability gets won or lost from here.

Quality validation deserves the same independent, enforced treatment that security checks already receive in most setups, applied at the exact point a change is made rather than discovered weeks later during a cleanup sprint.

Leaders don't need a platform team standing by to start acting on this. What's needed is an honest answer to whether agents are being checked by something other than themselves, and a decision to treat that as a deliberate design choice rather than whatever configuration happened to get inherited.

Give your coding agent a check it can't argue with

Another model's opinion can share your agent's blind spots. Codacy's deterministic analysis returns the same result every run, pointing the agent to the exact file and line to fix before a human reviews the pull request.

Scan your repository for free →

Subscribe to our blog

Stay updated with our monthly newsletter.