All articles

Harness engineering for AI agents: the design framework your deployment is missing

AI agent deployment best practices start with harness design. Learn the guides and sensors framework for building reliable agents in production.

Paweł Bazyluk
Paweł Bazyluk Founder Athru IT & partner at Spyrosoft Innovo S.A.

Hire someone exceptional - strong track record, sharp instincts, exactly the skills the role demands. Then give them no onboarding, no documented standards, no access to the tools they need, no way to know whether their output lands. Six weeks in, you wonder why they are underperforming. The answer is obvious: you built nothing around them.

The same failure mode runs through most AI agent deployments. Teams select a capable model, wire up a basic prompt, and then diagnose every failure as a model capability problem. It almost never is. The model is the new hire. What surrounds the model - the structured context, the constraints, the feedback loops, the verification checks - that is the engineering problem. Call it the agent harness. Building and iterating that harness deliberately is harness engineering.

The inversion matters: the agent is not the hard part. The harness is.

LangChain's work on agent infrastructure illustrates the stakes: the same model moved from 52.8% to 66.5% on Terminal Bench 2.0 after harness improvements, with no model change. The only variable was harness design.

What follows is a practitioner framework for harness engineering - not a component catalog, but a design principle: two control types, each with a distinct function in the agent's operational loop, with the logic that makes the trade-offs visible.

What a harness actually is

Agent = Model + Harness. The harness is everything the deploying team builds around the model: structured prompts, tool access, context pipelines, validation checks, feedback loops, permission boundaries. The model supplies the reasoning capability. The harness determines what that capability acts on, and whether the results are worth anything.

Sculley et al. made this point about production ML systems in their 2015 NIPS paper on hidden technical debt: model code is a small fraction of the total engineering surface. The surrounding infrastructure - data pipelines, serving systems, monitoring, feature engineering - is where the real complexity lives. Agents sharpen this pattern. As systems move from prototype to production, the model stabilizes; the harness grows.

Think of physical horse tack. The harness does not make the horse faster or stronger. It channels and directs what the horse already has - determines where the power goes, at what pace, with what steering. A better horse still needs tack. A horse with no tack produces chaos, not output. A well-designed harness running a modest model will regularly outperform a capable model running loose.

Two layers matter here. The inner harness is built by the model provider: native orchestration loops, built-in tool interfaces, default guardrails, context management primitives. This layer is commoditizing as model capabilities expand - the providers are absorbing it. The outer harness is built by the deploying team: custom constraints, domain-specific context injection, verification gates, feedback mechanisms. That is the engineering surface this article addresses. Everything that follows is about the outer harness.

Guides and sensors: the design framework

Every harness component belongs to one of two categories. Not as a taxonomic convenience - as a design principle that makes trade-offs visible and failure modes diagnosable.

Guides are feedforward controls. They act before the agent does. Role definitions, constrained tool sets, structured prompts, reference documents, task templates, schema requirements - all of these are guides. The agent reasons against what the guides give it. Good guides narrow the solution space before the model touches the problem, which means they eliminate whole categories of bad output structurally rather than correcting them after the fact. A guide for a document processing agent might define the expected output schema and inject the relevant regulatory reference before the agent reads the document. A guide for a code agent might inject directory structure and project conventions before any file is touched. The agent never has to guess at what it should encounter, because the guide determined that in advance.

Sensors are feedback controls. They act after the agent does. Schema validators, assertion checks, a separate LLM that scores output quality, escalation logic that routes ambiguous outputs to a human queue - these are all sensors. Sensors do not fix failures. They catch them, characterize them, and feed the information back into the harness so the next run is better. The value of a sensor is not correction; it is signal.

Within each category, two implementation types:

  • Computational implementations are deterministic: fast (milliseconds), cheap, auditable, pass/fail. Schema checks, format validators, static reference injection. No inference required - the check either passes or it doesn't.
  • Inferential implementations use LLM reasoning: slower, more expensive, non-deterministic, but capable of evaluating semantic appropriateness, relevance, and edge cases that no schema can specify. An LLM-as-judge scorer is an inferential sensor; a retrieval step that dynamically surfaces the most relevant context is an inferential guide.

The computational vs. inferential distinction is not a preference - it is a cost, trust, and auditability decision that compounds across every component in the harness. Computational checks are fast and auditable but cannot evaluate meaning. Inferential checks evaluate meaning but carry known failure modes - position bias, verbosity bias, self-enhancement - and produce non-deterministic results. The architecture requires both; the choice is where each fires, not which to omit.

Guides without sensors leave the harness blind to what actually happened. Sensors without guides face a failure space too wide to cover systematically. Neither leg is optional.

Four practices that separate functioning AI agent harnesses from failing ones

Constraint design

Constraint design is the most counterintuitive practice to get right. The instinct is to give the agent more options - more tools, broader context, wider latitude. The better instinct is to eliminate. Vercel ran a case study removing 13 of 15 tools from an agent's available set, reducing the toolkit from 15 to 2. Success rate on benchmark moved from 80% (4 of 5 queries) to 100% (5 of 5 queries); execution time dropped from 274.8 seconds to 77.4 seconds. The root cause was that the agent had been solving problems structurally that the harness should have resolved in advance. This result holds in environments with pre-existing good documentation - Vercel's benchmark was five queries deep. In undocumented environments, the agent has to discover structure rather than work within it, and the gains shrink accordingly. The principle holds regardless: fewer, tighter options shrink the solution space the model must work through, and a smaller solution space produces fewer bad paths.

Structured context

Structured context addresses a different failure mode - the agent guessing at things it could have been told. Anything the agent cannot access in-context while running effectively does not exist from its perspective. Knowledge living in chat threads, people's heads, or a Google Doc that wasn't injected is not accessible. LangChain's harness work operationalized this via LocalContextMiddleware: directory mapping, time budget, embedded testing standards - all injected before the agent reasoned. The agent that looks things up produces better output than the agent that approximates.

The steering loop

The steering loop is what separates a harness that learns from one that accumulates patches. When a failure occurs, the discipline is to encode it back into the harness - new constraints, updated guides, revised sensors - so the class of failure is addressed structurally the next time. A prompt manually patched after each incident never improves the system; it adds friction to the same failure mode on the next cycle. The harness should accumulate institutional knowledge, not workarounds.

Verification gates

Verification gates formalize the principle that the agent producing output is not qualified to check it. LangChain's PreCompletionChecklistMiddleware revealed the pattern directly: the most common failure was agents writing a solution, self-reviewing, deciding it looked fine, and stopping without running any verification. The fix is architectural - the acting agent and the checking agent are distinct. As reported by Artificial Lawyer, Harvey Legal moved from 40.8% to 87.7% success across 12 legal tasks by adding cross-document review playbooks, stop hooks, and structured fact sheets to the verification layer. The check that matters is the one the agent did not run on itself.

What harness-based deployment looks like in practice

The loop is not complicated. A structured task input enters the system - not a free-form request, but a task shaped to the harness's input conventions. Guides fire: the agent receives its context, sees its constrained tool set, works within the output schema it was given. The agent acts. Sensors fire against the output - following the computational vs. inferential sequence: computational checks first, because they are fast and cheap; inferential checks second, if the computational layer passes and semantic evaluation is warranted. Failures do not get discarded. They route back into the harness: logged, characterized, encoded as updated constraints or revised guides and sensors. The next task of the same type runs against an improved harness.

Domain is a configuration variable, not a structural variable. A code agent following this loop injects directory structure and testing standards as guides, writes implementation, then runs linters and assertion suites as computational sensors, followed optionally by an LLM reviewer against coding standards as an inferential sensor. A document processing agent injects the relevant rubric and output schema as guides, extracts and synthesizes, then runs schema validation and a completeness check as sensors. The loop is identical. The instantiation is domain-specific.

The human role in this loop is not to review each output as it comes through. It is to design and refine the loop itself - to decide what the guides should contain, what the sensors should check, what a failure should trigger. That shift is more significant than it sounds.

What you are doing when you ship an agent

Shipping an agent to production is mostly the work of externalizing tacit human expertise into machine-readable form. The senior lawyer's heuristics for evaluating source credibility. The senior engineer's instinct for which code review comments matter. The researcher's sense of when a source is being misread. None of this transfers by telling the agent to "be thorough" or "apply good judgment." It transfers through guides that encode the specific criteria, and sensors that check whether those criteria were met. The harness is the externalization medium.

Trust builds through that process, not in spite of it. Anthropic's Claude Code telemetry shows auto-approval rates growing from roughly 20% of sessions for new users to over 40% for users with 750 or more sessions. Task duration at the 99.9th percentile nearly doubled over four months - from under 25 minutes to over 45 minutes. Experienced users also interrupt more, not less: 9% of turns versus 5% for newer users. That is not a contradiction. It reflects a calibrated oversight model. Users learn where the harness is reliable and grant autonomy there; they intervene on the edge cases the harness has not yet encoded well. The interruptions are targeted, not anxious.

The practitioner skill this points to is judgment about what to encode and when. Not all tacit knowledge is ready to encode - some is context-dependent in ways the harness cannot yet represent. The skill is knowing where the harness can carry more weight and where human oversight is still the only reliable check.

What harness engineering has not solved in production

These are not caveats. They are the research agenda for the next two to three years. Treating them as known unknowns is a sign of rigor. Any practitioner who has shipped agents past the prototype stage has encountered at least three of them.

Output entropy

Output entropy accumulates differently than human inconsistency. A human worker drifting off-standard has persistent meta-awareness across sessions - they remember yesterday's decisions, notice when they're contradicting earlier work. Agents have no such persistence unless it is explicitly built into the harness. The result is inconsistencies that accumulate in patterns that are harder to detect (no single failure moment) and harder to attribute (the root cause may be ten steps back). Sensors can catch individual instances. No current harness design catches the accumulation pattern reliably.

Verification at scale

Verification at scale is a harder problem than benchmark numbers suggest. Scale AI's Remote Labor Index tested frontier agents on 240 actual Upwork freelance tasks and found a 2.5% success rate - these are models scoring 80–90% on standard benchmarks. The math explains it: 90% per-step accuracy on a 10-step task produces 34.9% end-to-end success. Agents report completion as a matter of course. The harness has no reliable mechanism to independently verify that what completed was actually correct.

Domain portability

Domain portability exposes the limits of pattern generalization. Harness design patterns - guides, sensors, the steering loop - transfer across domains. Domain-specific configurations do not. Moving a harness from legal document review to financial due diligence requires rebuilding tool sets, constraint parameters, grading rubrics, and domain knowledge injection from near-scratch. Beyond rework cost, not all domains are equally legible to an agent. Messy, undocumented environments create harness engineering debt before any guide or sensor is written.

Context rot

Context rot is an architectural problem that better models have not solved. Chroma's research tested 18 frontier models and found accuracy degradation as input length increased across every one of them - and specifically for information positioned mid-context, consistent with Liu et al.'s lost-in-the-middle findings. Larger context windows are an information solution to a structural problem. The actual fix is state externalization, re-anchoring patterns, and explicit context engineering. These are harness practices most teams have not yet systematized.

Legacy environments

Legacy environments may be the most underappreciated constraint. The harness assumes a legible environment: versioned code, structured documentation, defined APIs, clear schemas. Real organizational systems are rarely this clean. Undocumented codebases, tribal knowledge living in chat threads, processes that exist only in people's heads - these create environments where the agent cannot find what it needs, and the harness cannot compensate for what was never written down. Cleanlab's survey found fewer than one in three production teams satisfied with their observability and guardrail solutions. That gap reflects, in part, the friction of deploying harnesses against environments that were never designed to be readable.

The harness as bottleneck

The sixth problem is different in kind. What happens when the agent, correctly, identifies that the harness itself is the bottleneck? An agent confined by guides too narrow for the actual problem, checked by sensors evaluating the wrong criteria, has no reliable way to surface this. The feedback loop runs in one direction. Whether and how to give agents a channel to flag harness limitations - without opening that channel to manipulation or noise - is genuinely open. There is no framework for it yet. The value is in naming it precisely.

From prompt engineering to environment engineering

The field is not maturing from "better prompting" to "better models." It is maturing from prompt engineering to environment engineering. The harness is the medium through which institutional knowledge about a domain gets encoded into a system that can act reliably on it. Every guide is a judgment about what the agent should encounter. Every sensor is a judgment about what constitutes a good outcome. Both require domain expertise to design and operational discipline to maintain.

The domain changes - legal, code review, financial analysis, research synthesis - and the discipline does not. The guides and sensors framework, the steering loop, the verification gate, the externalization of tacit expertise: these are the AI agent deployment best practices that apply wherever agents run in production.

The durable advantage teams build through harness engineering is not the harness itself. It is the accumulated institutional knowledge encoded in it over time. That advantage does not erode when models improve.

Sources9