Harness Engineering: The System That Makes AI Agents Reliable

Learn how Harness Engineering turns models into reliable agents through tools, state, verification, security, observability, and feedback loops.

Built With: json

A language model can write a function, explain an error, or suggest a command. None of that makes it a reliable software agent.

Reliability begins when the model is placed inside a system that gives it the right context, exposes useful tools, limits dangerous actions, preserves state, checks its work, and knows what to do when the run goes wrong. That surrounding system is the subject of Harness Engineering.

The phrase became widely visible through OpenAI’s account of using Codex in an agent-first development workflow. The company described an internal product built with no manually written code, while also making clear that the hard engineering work moved into repository structure, tools, documentation, feedback loops, validation, and maintenance.

That is the important distinction: Harness Engineering is not a longer prompt and not a magic wrapper around a model. It is the design of the environment in which model decisions become real actions.

This article develops a practical, provider-neutral framework for understanding and building that environment. It combines the system-level view from Martin Fowler’s analysis of feedforward guides and feedback sensors, the component model described by LangChain and Databricks, the long-running patterns documented by Anthropic, and the security boundaries recommended by NVIDIA’s AI Red Team.

It also incorporates the less comfortable lessons from practitioner discussions: agents can follow the wrong pattern with confidence, optimize a score instead of the real objective, and become more expensive and less predictable as autonomy increases.

Key takeaways
  • A model generates decisions; a harness turns those decisions into controlled, observable work.
  • The minimum useful harness needs context, tools, an execution boundary, state, verification, and a stop or escalation policy.
  • Instructions guide behavior, but schemas, permissions, tests, and runtime policies determine what can actually happen.
  • Long-running agents need externalized state and incremental progress—not only a larger context window.
  • The safest improvement loop is: observe a real failure, identify the missing control, add the smallest durable fix, then measure again.
How to read the evidenceThis article separates first-party case studies, independent research, security guidance, practitioner reports, and editorial synthesis. Vendor-reported figures are attributed to the vendor; preprint results are scoped to their published setup; Reddit and YouTube observations are treated as experience signals rather than controlled benchmarks. No claim here should be read as proof that a particular harness, model, sandbox, or workflow is universally best or secure.
Free Engineering Asset
Get the Harness Engineering Starter Kit (.zip)
Includes ready-to-use JSON schemas (Task Contracts, Tool Specs, Feature Ledgers) & test templates.

What Is Harness Engineering?

Harness Engineering is the practice of designing and maintaining the system around an AI model so an agent can act, observe, verify, recover, and improve under real constraints. The system may contain prompts, tools, skills, memory, filesystems, sandboxes, orchestration logic, middleware, evaluators, approval gates, logs, and policy enforcement.

Harness Engineering for AI Systems
Harness Engineering for AI Systems

There is no single formal standard that fixes the boundary of the term. LangChain’s practical definition treats everything that is not the model as part of the harness: system prompts, tools, skills, MCP servers, infrastructure, orchestration, and middleware. Databricks uses a similar model-and-harness split, emphasizing tools, memory, workspace, guardrails, and observability in production systems. Fowler narrows the discussion to the controls that guide and sense a coding agent’s behavior.

Those definitions overlap, but they are not identical. The useful question is not whether memory belongs to “context engineering” or “harness engineering.” The useful question is whether the system can provide the right information, execute the right action, constrain the action, inspect the result, and learn from failure.

Working definition: A harness is the control surface between model intent and real-world effect.

That definition also explains why the discipline matters. A model can propose rm -rf, call the wrong API, misunderstand a repository boundary, stop after a partial fix, or declare success because a unit test passed while the user-facing flow remains broken. The harness determines what happens next.

Why a Model or Prompt Is Not Enough

A model call does not provide durable project state, an execution interface, a permission boundary, or independent proof of completion. Without a harness, the model may not see yesterday’s decisions, cannot safely run the code it describes, has no reliable basis for deciding which actions are allowed, and can declare a partial task complete.

AI agent execution system design
AI agent execution system design

That is why Anthropic’s long-running-agent work treats context compaction as only one part of a larger design. Its documented pattern adds an initializer, an explicit feature list, progress artifacts, Git history, incremental sessions, and clean-state checks.

A stronger model may plan and recover better, but it remains one variable in a system shaped by context selection, tool design, execution state, permissions, feedback quality, and resource limits.

Prompt Engineering, Context Engineering, Agent Engineering, and Harness Engineering

These terms are often used as if they describe competing disciplines. A better model is to treat them as overlapping layers.

DisciplineMain questionTypical artifactWhat it does not solve alone
Prompt EngineeringHow should the model be instructed?System prompt, task prompt, examplesExecution, permissions, durable state, independent verification
Context EngineeringWhat information should the model see now?Retrieval, memory, summaries, file selectionWhether the chosen action is allowed or correct
Agent EngineeringHow should the model use tools to pursue a goal?Tool loop, planner, router, subagentsSafe runtime isolation, durable operations, organization-wide governance
Harness EngineeringHow do we make the whole system steerable, observable, verifiable, and recoverable?Tools, state, runtime policies, tests, traces, gates, lifecycle controlsIt does not remove model uncertainty or eliminate the need for human judgment

The boundaries are practical rather than canonical. Retrieval may be discussed as context engineering or as a harness component. A tool loop may be called agent engineering or runtime orchestration.

The distinction becomes useful when debugging: if the agent lacks the information, inspect context; if it cannot act, inspect tools; if it acts unsafely, inspect policy and isolation; if it acts plausibly but incorrectly, inspect verification and task design.

The Harness as a Control System

Most explanations list components. A more useful approach is to connect each component to a control problem.

AI agent control surfaces
AI agent control surfaces

The model receives an objective and context. It selects an action. The harness executes that action within a runtime boundary. The environment produces an observation. The system verifies the observation against an explicit contract. It then chooses one of four outcomes: continue, repair, stop, or escalate.

I call this the Control Surface Map:

  1. Intent: What does success mean, and what is explicitly out of scope?
  2. Context: Which facts, files, memories, and tool results are available at this step?
  3. Action: Which tools can the agent call, with what schemas and argument constraints?
  4. State: Where are plans, progress, artifacts, and checkpoints stored?
  5. Verification: What independent evidence can confirm or reject the agent’s claim?
  6. Policy: Which actions are allowed automatically, blocked, or sent to a human?

A failure becomes easier to diagnose when it is mapped to a surface. “The model was bad” is not a diagnosis. “The agent chose the right tool but received an unbounded 50,000-line output” points to context and tool-output design. “The patch passed unit tests but broke the browser flow” points to verification coverage. “A repository instruction caused an unsafe command” points to trust boundaries and runtime policy.

Reason → Act → Observe → Verify

The familiar ReAct pattern is often described as reason, act, observe, repeat. A production harness needs one more explicit step: verify.

  • Reason: The model interprets the task and available evidence.
  • Act: The harness validates the tool call, applies policy, and executes it.
  • Observe: The harness captures output, status, files, logs, metrics, and side effects.
  • Verify: Deterministic checks, independent evaluators, or humans test whether the result meets the contract.

Without verification, the loop can become a persuasive conversation with the model. Without observation, verification has no reliable evidence. Without policy, action becomes an uncontrolled bridge between untrusted text and real systems.

Design rule: “done” is an evidence state, not a sentence.A harness should not mark a task complete because the model says it is complete. Completion should require the checks defined by the task contract, plus a clean enough environment for the next run or human reviewer.

Feedforward and Feedback: Two Halves of a Useful Harness

Martin Fowler’s framework separates controls into feedforward and feedback.

Feedforward controls act before the model makes a decision. They include concise repository maps, tool descriptions, schemas, examples, architectural rules, task contracts, and instructions about what to inspect first. Their purpose is to make good action more likely.

Feedforward and feedback control
Feedforward and feedback control

Feedback controls act after an action.

They include type checks, linters, structural tests, browser tests, log queries, policy decisions, evaluation traces, and human review. Their purpose is to detect what actually happened and create a correction signal.

A system with only feedforward controls becomes a rulebook that cannot detect its own failures. A system with only feedback controls becomes a machine that repeatedly makes the same mistake and waits to be corrected. The reliable pattern is a loop: guide the action, observe the result, detect the failure, and promote the durable lesson into a better guide or sensor.

There is another useful distinction: computational controls versus inferential controls. A type checker or schema validator is deterministic and cheap. An LLM reviewer can assess semantic coherence, but it is slower, probabilistic, and itself needs evaluation. Use deterministic checks for boundaries you can define precisely; reserve model-based judgment for questions that genuinely require semantic interpretation.

What Belongs in an AI Agent Harness?

A production harness is not required to contain every component below. It should contain the smallest set that addresses the task’s real failure modes.

ComponentJobCommon failure when missing or weak
System and task instructionsSet scope, behavior, constraints, and ambiguity rulesThe agent explains instead of acting, or solves the wrong problem
Context and retrievalExpose relevant code, data, decisions, and current stateThe agent guesses paths, APIs, or requirements
Tool contractsDefine names, schemas, preconditions, outputs, and refusal behaviorThe agent chooses the wrong tool or sends malformed arguments
Filesystem and durable artifactsStore plans, progress, results, and intermediate workEach session starts by rediscovering the project
Execution environmentRun code and inspect real effectsThe agent cannot validate, or runs directly on a dangerous host
OrchestrationManage loops, retries, routing, subagents, and budgetsWork stops early, loops forever, or grows unnecessarily complex
VerificationCheck outputs and important intermediate statesThe agent declares success after a superficial check
Policy and approvalsLimit irreversible, privileged, or external actionsA plausible instruction becomes an unsafe action
ObservabilityRecord tool calls, state transitions, errors, and costTeams cannot explain failure or compare harness changes
Lifecycle managementCreate, reset, expire, and clean execution stateOld secrets, code, caches, and broken state accumulate

Databricks’ production overview groups similar primitives into system prompts, tools, sandboxes, filesystem, memory, feedback loops, guardrails, and observability. LangChain’s anatomy adds a useful behavior-first lens: start from what you want the agent to do, then choose the harness capability that makes that behavior possible.

A comparable implementation-oriented curriculum from Vercel Academy covers tool loops, safety, sandboxing, context, subagents, lifecycle, human approval, and verification.

Build a Minimum Viable Harness Before Adding More Autonomy

The fastest way to overbuild an agent is to start with subagents, vector databases, complex routing, and self-improvement before proving that one constrained loop can finish one real task.

A Minimum Viable Harness should establish a narrow, testable path.

If you want to skip the manual setup and grab a working reference layout with pre-configured schemas and test harnesses, you can use our open Harness Engineering Starter Kit (no signup required).

1. Define one task contract

Write the goal, boundaries, acceptance criteria, test requirements, and stop conditions. Avoid asking an agent to “improve the application” when the real task is “add a CSV export endpoint without changing JSON behavior.”

Creating structured task contract
Creating structured task contract

Red Hat’s structured workflow example uses a repository impact map before implementation, followed by a task template with real files, symbols, acceptance criteria, and tests.

The human checkpoint occurs before code changes, when a wrong assumption is still cheap to fix.

Here is a compact, provider-neutral task contract. It is illustrative JSON, not a universal schema: adapt the file paths, commands, test framework, budget, and policy to the repository and runtime you actually use.

JSON: 

{
  "task_id": "feat-export-csv-042",
  "intent": "Add a CSV export endpoint for transactions without altering JSON behavior",
  "in_scope": [
    "src/api/routes/export.py",
    "tests/test_export.py"
  ],
  "out_of_scope": [
    "src/api/routes/json_serializer.py",
    "database/migrations/"
  ],
  "acceptance_criteria": [
    "GET /api/v1/export/csv returns HTTP 200 with a text/csv content type",
    "Existing JSON export tests continue to pass"
  ],
  "verification_commands": [
    "pytest tests/test_export.py -v",
    "mypy src/api/routes/export.py"
  ],
  "max_tool_calls": 12,
  "budget_limit_usd": 0.50
}

The contract makes scope, verification, and resource limits visible before the agent starts. The commands are examples, not guaranteed cross-project instructions; a real harness should validate that they exist, run them inside the intended environment, and treat a command failure as evidence rather than silently editing the contract.

2. Give the agent a map, not an encyclopedia

A long instruction file is not automatically better context. OpenAI reports that its team moved away from a giant AGENTS.md toward a short map pointing to structured repository documents. The reason is practical: an enormous file crowds out the task, becomes hard to verify, and rots as the system changes.

Optimizing AI coding context
Optimizing AI coding context

For a hands-on treatment of skills, context rot, project planning, and agent-governance patterns, see Vertex Frontier’s guide to AI coding skills.

Use progressive disclosure. Put the stable index in a short entry point, then expose architecture, conventions, plans, quality rules, and operational references when the task requires them. If those references come from documents or knowledge bases, our production RAG preprocessing guide expands the related concerns around parsing, provenance, metadata, freshness, authorization metadata, and evaluation.

3. Start with a small tool set

A first harness may need only file inspection, search, a controlled execution tool, and a verification command. Each tool should have a clear schema and a bounded output. “Bash” is powerful, but it should not be treated as permission to act without policy.

JSON schema tool contract design
JSON schema tool contract design

For example, a tool contract can describe a workspace-only file reader like this:

JSON:

{
  "name": "read_workspace_file",
  "description": "Read a UTF-8 text file inside the active workspace. Reject absolute paths, path traversal, and files larger than max_bytes.",
  "input_schema": {
    "type": "object",
    "properties": {
      "path": {
        "type": "string",
        "description": "Relative path under the active workspace"
      },
      "max_bytes": {
        "type": "integer",
        "minimum": 1,
        "maximum": 200000,
        "default": 50000
      }
    },
    "required": ["path"],
    "additionalProperties": false
  },
  "failure_contract": {
    "path_outside_workspace": "reject",
    "file_too_large": "return a bounded error",
    "binary_file": "return an unsupported-file error"
  }
}

This is a provider-neutral illustrative contract. JSON Schema can validate the shape of an input, but it does not create a secure filesystem boundary by itself. The runtime still has to resolve the path safely, enforce the workspace root, cap bytes, handle encoding errors, log the decision, and prevent a tool implementation from bypassing the declared policy.

Tool descriptions should explain when to use the tool, when not to use it, required inputs, expected outputs, failure modes, and examples. Practitioner discussions on model portability repeatedly return to this point: a tool description behaves more like an API contract than like decorative prompt text. If multiple models matter, test tool selection, argument shape, refusals, and recovery, not only the final answer.

4. Put execution behind a boundary

The agent should work in a workspace designed for the task, not inherit unrestricted access to a developer’s machine. The boundary may be a container, microVM, remote sandbox, or another isolation design, but the security properties must be verified for the actual environment.

Secure AI Agent Workspace Isolation
Secure AI Agent Workspace Isolation

When the workspace also brokers retrieval over private documents, our enterprise RAG security guide provides a useful companion model for identity-aware retrieval, document-level access controls, and authorization-source decisions.

Do not equate the word “sandbox” with complete security. NVIDIA’s guidance on agentic execution risk highlights indirect prompt injection through repositories, Git history, instruction files, hooks, skills, and MCP responses. For the broader identity, least-privilege, and enterprise-risk model, see Vertex Frontier’s Agentic AI Security guide. It recommends controls such as network egress restrictions, blocking writes outside the workspace, protecting agent configuration files, limiting reads, scoping secrets, and managing sandbox lifecycle.

These are security recommendations that must be adapted to the threat model; they are not a universal safety guarantee.

5. Add independent verification

Define at least one check that the model cannot satisfy merely by claiming success. For code, that might be a type check, a focused test, an integration test, a structural rule, or a browser-level flow. For data work, it might be a reconciliation, schema check, or invariant. For operational work, it might be a dry run plus an external state query.

Defining verification checks
Defining verification checks

Verification should match the risk. A formatting check is not evidence that a payment workflow is correct. A green unit test is not evidence that a browser flow works. A model-based reviewer is not a substitute for runtime policy.

6. Record state and stop safely

Write progress, outputs, and decisions to durable artifacts. Cap retries, tool calls, time, and spend. Decide in advance what causes a stop, a rollback, or a human escalation.

Designing autonomous execution
Designing autonomous execution

If the harness cannot answer “what happened, what changed, what remains, and what evidence supports completion?” then it is not ready for long-running autonomy.

Minimum viable ruleDo not add an autonomous component until you can name the demonstrated failure it addresses, the permission it needs, the evidence that will evaluate it, and the rollback path if it makes the system worse.

Long-Running Agents: State Beats Memory Alone

A long-running agent is not simply a short-running agent with more tokens. It is a sequence of sessions that must hand a trustworthy project state from one context window to the next.

Managing long running agent state
Managing long running agent state

Anthropic’s documented approach uses an initializer agent to create the environment, a structured feature list, a progress file, Git history, and a coding agent that makes incremental progress. The next session first gets its bearings, checks the project, reads recent progress, selects one unfinished feature, and verifies that existing functionality still works. This is a practical response to two common failure modes: attempting too much at once and declaring the whole project finished after partial progress.

A durable long-running harness usually needs these artifacts:

Here is a small feature_list.json example. The status field is intentionally explicit: the agent may update progress, but it should not quietly delete unfinished requirements to make the project appear complete.

JSON:

[
  {
    "id": "chat-new-conversation",
    "category": "functional",
    "description": "A user can create a new conversation from the main interface",
    "verification": [
      "Open the application",
      "Select New Chat",
      "Confirm the empty conversation state appears",
      "Confirm the conversation is listed in the sidebar"
    ],
    "passes": false
  },
  {
    "id": "chat-error-recovery",
    "category": "reliability",
    "description": "A failed model request shows a recoverable error without losing the draft",
    "verification": [
      "Simulate a failed request",
      "Confirm the draft remains available",
      "Retry the request",
      "Confirm the error state is cleared after success"
    ],
    "passes": false
  }
]

The list is an illustrative project artifact, not an Anthropic-required format. In a real system, protect its schema and define who or what is allowed to change passes.

ArtifactPurposeFailure it prevents
Feature or task ledgerDefines what “complete” meansPremature victory and scope drift
Progress logExplains what changed and what remainsRepeated discovery work and confused handoff
Git or versioned checkpointsProvides rollback and historyIrrecoverable edits and unclear causality
Environment bootstrapMakes the project runnableTime wasted reconstructing setup
Clean-state contractDefines what a session must leave behindOne session poisoning the next
Independent end-to-end checkTests actual behaviorGreen local checks with broken user flow

Context compaction is still useful. It reduces the amount of old conversation that remains active. But compaction does not decide which project state is trustworthy, whether a half-written feature should be continued, or whether the next agent should repair before building. Those decisions belong in explicit artifacts and checks.

Security: Treat the Harness as a Privilege Boundary

An agent harness converts text into actions. That makes the boundary between “information the model reads” and “authority the system grants” one of the most important design surfaces.

Securing AI agent execution systems
Securing AI agent execution systems

The security problem is not limited to a malicious user prompt. A repository can contain a poisoned instruction file. A pull request can contain hostile text. A Git history can include injected directions. A tool response can return content that attempts to redirect the agent. If the agent can execute commands, write files, reach the network, or access inherited credentials, those instructions may become operationally significant.

A reasonable security design separates four decisions:

  1. What may the model propose? The model can suggest many actions.
  2. What may the runtime execute? Policy, schemas, permissions, and isolation decide this.
  3. What must be approved? Humans should review material-risk actions, not every routine action by habit.
  4. What evidence is retained? Logs and traces should show the request, tool call, policy decision, result, and actor or authority involved.

NVIDIA specifically warns that repeated approval prompts can create habituation: users may click through dangerous requests without inspecting them. That does not make human approval useless. It means approval should sit inside a least-privilege policy, with enterprise-level denials for especially sensitive actions and fresh approval for actions that genuinely require it.

Protecting secrets requires more than hiding them in the prompt. The safer pattern is to provision only the credentials needed for the task, avoid inheriting the full host environment, prefer short-lived or brokered access where possible, and assume that anything exposed to the agent may be used by the agent or by an attacker influencing its context.

Evaluation: Measure the Harness, Not Just the Model

A coding agent is deployed as a system. A recent engineering monograph on reliable coding agents argues that reliability depends on execution state, retrieval, memory, permissions, review interfaces, and resource allocation as well as model capability.

That changes the evaluation question. Measure the outcome, the path, the cost, the safety boundary, and the state left behind. A model’s “done” message is only an assertion; the harness needs evidence that can disagree with it.

Metric familyExample measureWhat it reveals
OutcomeTask success and acceptance-criteria pass rateWhether the user goal was met
TrajectoryTool choice, argument validity, retries, recoveryHow the result was reached
ResourceTokens, tool calls, time, sandbox minutesEconomic and operational cost
SafetyPolicy violations, blocked actions, secret exposureWhether autonomy stayed inside its boundary
State qualityCheckpoint validity, rollback, reproducibility, handoffWhether long-running work remains trustworthy

Preserve the model version, task set, tool definitions, permissions, retry policy, and environment for each evaluation run. Otherwise a result may be impossible to reproduce or attribute. The Agentic Harness Engineering preprint illustrates this direction by exposing harness components as editable artifacts, distilling trajectory evidence, and recording predictions for changes. Its benchmark gains belong to that setup and should not be generalized to every agent.

How to Evaluate a Harness Before Scaling It

Disciplined model evaluation protocol
Disciplined model evaluation protocol

If you do not have a benchmark suite, you can still run a disciplined evaluation. Treat this as a test protocol, not as a claim about expected performance.

  1. Freeze the configuration: Record the model identifier, system instructions, tool schemas, permissions, workspace image, retrieval settings, retry limits, and temperature or equivalent sampling controls.
  2. Choose representative tasks: Include ordinary tasks, ambiguous tasks, known failure cases, and at least one task that should be refused or escalated. Do not evaluate only demonstrations selected because they already work.
  3. Define evidence before running: Write the acceptance criteria, required tool behavior, safety boundaries, maximum budget, and rollback condition in advance.
  4. Capture the trajectory: Store tool calls, arguments, policy decisions, outputs, state transitions, errors, retries, and final artifacts. A final answer without its path is difficult to diagnose.
  5. Score multiple dimensions: Report task outcome, trajectory quality, resource use, safety events, and state cleanliness separately. A pass-rate increase that comes with uncontrolled permissions or unacceptable cost is not an uncomplicated improvement.
  6. Run regression tasks: Re-test tasks that did not motivate the change. A harness change can fix one failure while damaging portability, latency, or unrelated workflows.
  7. Keep, revert, or narrow: Keep a change only when the intended improvement is visible and the regression budget is acceptable. Otherwise revert it or narrow its scope.

This protocol produces a defensible baseline even when the output is qualitative. It also turns “the agent feels better” into a sequence of observations that another engineer can inspect.

What this article does not claimIt does not claim that Harness Engineering makes every model interchangeable, that a sandbox is fully secure, that more agents always improve quality, or that the cited benchmark and productivity figures transfer to your workload. Those conclusions require a controlled evaluation under your own model, tools, permissions, tasks, and operating conditions.

Workflow or Agent? Choose Agency Deliberately

Not every problem deserves an autonomous agent.

A deterministic workflow is usually easier to test when the path is known: validate an input, call a fixed service, transform the result, and publish it. An agent becomes more useful when the path is ambiguous, the environment must be explored, or the system needs to choose among tools based on what it discovers.

Anthropic’s engineering guidance distinguishes workflows with predefined control flow from agents that dynamically choose their trajectory. Expert talks on effective agents and custom harnesses reach a related design conclusion, particularly around workflow boundaries and ownership of the harness Anthropic’s agent-engineering talk Harrison Chase’s custom-harness talk: agent loops can consume more tokens and add latency because they explore and retry. More agency is a capability trade-off, not an automatic upgrade.

Open the workflow-versus-agent decision guide
QuestionPrefer a workflow when…Consider an agent when…
Is the decision tree known?Yes; branches can be written and testedNo; useful next steps depend on discovery
Is the action irreversible?Yes, unless a strong policy and approval layer existsOnly with least privilege, isolation, and explicit gates
Is exploration valuable?No; exploration adds cost without useful flexibilityYes; the system must inspect and adapt to the environment
Can success be checked?A deterministic assertion or contract existsIndependent evaluation and a stop policy can be built

A hybrid is often the strongest design: use deterministic steps for authentication, permissions, known transformations, and final publishing; give the agent a bounded role in exploration, diagnosis, planning, or selecting among safe tools.

Common Harness Failure Modes

The community research around coding agents adds an important corrective to polished architecture diagrams. Builders in practitioner discussions report that a harness can fail in ways that look like model intelligence failures but are actually system-design failures the r/AI_Agents challenge discussion the long-running harness discussion the local safety-boundary discussion. These are experience signals, not controlled benchmarks.

Common harness failure modes
Common harness failure modes

The giant instruction file

A huge AGENTS.md or equivalent can contain useful knowledge and still reduce performance. It competes with the task, becomes stale, and gives the model no clear way to distinguish a hard invariant from a local preference. Practitioner reports also describe repository-specific rules being ignored or applied superficially the r/AI_Agents challenge discussion the long-running harness discussion. Use a short map, structured documents, ownership, links, and mechanical checks.

Tool overload

Adding tools feels like adding capability. It can also make tool choice harder, enlarge the prompt, and create overlapping contracts. Start with a small set. Add a tool only when a demonstrated task cannot be completed cleanly without it.

Retry without diagnosis

A loop that simply asks the model to “try again” may repeat the same error at greater cost. A useful retry returns new evidence: the failing assertion, the rejected policy, the relevant log line, or a narrowed context. If the same failure recurs, change the harness rather than increasing the retry count.

Self-evaluation as the only judge

A builder agent can review its own work, and that is useful as a cheap first pass. It is not a neutral evaluator. The agent may rationalize its choice, overlook a missing requirement, or optimize a proxy score. Practitioner discussions likewise distinguish evaluation from runtime enforcement the local safety-boundary discussion. For important tasks, combine self-review with deterministic checks, independent evaluation, and actual environment state.

Proxy gaming

A quality score can provide a persistent objective, but agents may optimize the score instead of the underlying goal. The long-running harness discussion on Reddit describes this risk in the context of code-quality improvement the long-running harness discussion. The lesson is broader: combine mechanical checks with real task outcomes, review the rubric itself, and test whether the metric is being improved for the right reason.

Model portability assumptions

A tool suite that works with one model may behave differently with another. Models can have different priors about tool names, schemas, patch formats, planning, and refusal behavior. Portability is valuable, but it has a cost: you need compatibility tests and sometimes model profiles. Specialization can be rational when task performance matters more than interchangeability.

Approval fatigue

Putting a human confirmation in front of every action does not automatically make a system safe. It can create a habit of approving prompts without reading them. Use policy for routine boundaries, deny especially dangerous operations regardless of approval, and reserve human judgment for actions where a person can meaningfully evaluate the risk.

Over-agenting

Planner, builder, reviewer, evaluator, memory service, router, and background janitor may all be useful. They also add latency, cost, failure modes, and maintenance. The correct question is not “Can we add another agent?” It is “Which measured failure requires another agent rather than a better tool, test, contract, or deterministic step?”

Three Real-World Lessons

Real-World Lessons from AI Agents
Real-World Lessons from AI Agents

OpenAI: move engineering effort into the environment

OpenAI’s first-party case study describes a five-month internal experiment in which Codex produced product code, tests, CI, documentation, tooling, and observability definitions. The team reports roughly one million lines of code, about 1,500 merged pull requests, and an estimate that the product was built in around one-tenth the time of manual coding. Those are the company’s own figures for its own internal experiment, not an industry benchmark.

The more transferable lesson is the mechanism. The team made the application, logs, metrics, repository knowledge, architecture rules, and feedback loops legible to agents. It encoded architectural boundaries in linters and structural tests, and used recurring cleanup to control drift. The case study’s strongest idea is not “agents replace engineers.” It is that humans moved upward: they defined goals, exposed missing capabilities, and turned repeated failures into tools, rules, and documentation.

Anthropic: treat each context window like an engineering shift

Anthropic’s long-running-agent article documents a different kind of harness problem. A coding agent trying to build a large application may attempt too much, run out of context, leave half-implemented work, and then cause the next session to guess what happened. Another session may inspect partial progress and declare the project finished.

The documented response is operational rather than rhetorical: initialize the environment, create an explicit feature list, work on one feature at a time, update progress, commit to Git, leave a clean state, and use browser automation for end-to-end checks where appropriate. The broader lesson is that long-running autonomy is a state-management problem. More context helps, but it does not replace checkpoints, task contracts, and independent verification.

AHE preprint: make harness changes falsifiable

The 2026 Agentic Harness Engineering preprint explores automatic evolution of coding-agent harnesses. It reports an experiment in which ten iterations raised pass@1 on Terminal-Bench 2 from 69.7% to 77.0%, with a specific setup, benchmark, model, and harness substrate. The paper also reports transfer experiments and component ablations.

The valuable design principle is stronger than the individual benchmark number: make harness components observable, make trajectory evidence inspectable, and attach a prediction to every change. A harness edit should be a falsifiable hypothesis, not an unexplained accumulation of prompt prose. This is still research, and the paper itself says results depend on workload and configuration. It should inform evaluation design, not be turned into a promise that automatic harness evolution will improve every agent.

How Harnesses Improve Over Time

A healthy harness has a maintenance loop:

  1. Capture a failed or surprising trajectory.
  2. Identify the first missing or misleading control.
  3. Decide whether the fix belongs in context, the tool contract, runtime policy, state management, verification, or orchestration.
  4. Add the smallest change that addresses the failure.
  5. Run a regression set, not only the original task.
  6. Keep the change if it improves the intended outcome without unacceptable regressions.
  7. Remove or simplify controls that no longer earn their complexity.

This last step matters. A harness can become a second codebase full of stale instructions, conflicting policies, and unused tools. Martin Fowler raises the open question of harness coherence and coverage, while the AHE work makes versioned, observable component edits part of the improvement loop. A good harness is not the one with the most rules. It is the one whose rules and sensors still correspond to the system’s real risks.

The engineering testFor every harness feature, answer four questions: Which failure does it address? What authority does it require? What evidence says it works? How will we remove it if it becomes stale or harmful?

A Practical Reference Architecture

A provider-neutral harness can be described as seven layers:

  1. Task contract: Goal, scope, acceptance criteria, risk class, and stop conditions.
  2. Context gateway: Repository map, retrieval, memory, summaries, and progressive disclosure.
  3. Tool registry: Typed tools with schemas, descriptions, bounded outputs, and error semantics.
  4. Execution boundary: Workspace, sandbox, network policy, filesystem policy, and secret provisioning.
  5. Control loop: Reason, act, observe, verify, retry, stop, or escalate.
  6. Evidence plane: Logs, traces, tool history, state snapshots, evaluation results, and cost records.
  7. Evolution loop: Versioned changes to prompts, tools, middleware, skills, policies, and evaluators.

This architecture is intentionally less specific than a framework tutorial. It does not assume a particular model, SDK, container platform, or MCP implementation. For a practical comparison of retrieval and orchestration boundaries, our LlamaIndex-versus-LangChain production guide is a useful companion. The names may change. The responsibilities do not.

When a system is small, several layers may live in one process. As the workload becomes more sensitive or long-running, separating the layers makes failures easier to locate and policies easier to enforce. The architecture should grow in response to requirements, not because a diagram looks more complete with more boxes.

Conclusion: Engineer the Conditions for Good Work

Harness Engineering is easy to misunderstand because it sits around the visible intelligence of the model. The model writes the answer, selects the tool, or proposes the patch, so it receives most of the attention. But the quality of real work depends on the conditions around that decision.

A reliable harness makes the task legible, the tool contract explicit, the runtime bounded, the state durable, the result testable, the failure visible, and the next improvement measurable. It does not promise perfect autonomy. It makes autonomy more governable.

The best starting point is deliberately modest: one task, one workspace, a few tools, a real verification contract, a clear stop policy, and enough observability to understand what happened.

Then let failures earn the next layer. If a problem is solved by a deterministic check, do not add another agent. If the agent lacks context, improve the context before increasing the model budget. If a rule keeps failing, encode it where the runtime can enforce it. If a score improves while real outcomes worsen, redesign the metric.

That is the central idea: Harness Engineering is not the art of making a model sound more confident. It is the discipline of making the whole system more honest about what it knows, what it can do, what it actually did, and whether the work is complete.

🚀

Download the Harness Engineering Starter Kit

Ready to implement this in code? We’ve bundled the complete reference architecture, JSON schemas (task contracts, tool contracts, feature ledgers), and verification test templates into an open, production-ready starter. Free & open access—no email or signup required.

Download the Open Starter Kit ↓

FAQ

What is Harness Engineering in simple terms?

Harness Engineering is the design of the tools, context, runtime, state, rules, verification, and feedback loops around an AI model so it can complete real tasks more reliably. The model supplies reasoning; the harness controls how that reasoning becomes action.

Is Harness Engineering the same as Prompt Engineering?

No. Prompt Engineering focuses on how instructions are written. Harness Engineering includes prompts, but also covers execution environments, tools, memory, permissions, state, tests, observability, retries, and recovery. Prompt quality is one input to a larger control system.

What is an AI agent harness made of?

Common components include a task contract, context and retrieval, tool interfaces, a filesystem or durable state store, an execution environment, orchestration logic, verification, guardrails, observability, and lifecycle management. A small harness may use only a subset of these.

How do I build an AI agent harness?

Start with one narrow task. Define acceptance criteria, give the agent a concise repository or data map, expose a small set of typed tools, run them inside a constrained workspace, add an independent verification step, persist progress, and cap time, retries, and spend. Add subagents or advanced memory only when a measured failure justifies them.

Are sandboxes enough to secure an AI agent?

No. A sandbox can reduce risk, but the actual protection depends on its isolation boundary, OS or VM design, network rules, filesystem policy, secret handling, spawned processes, hooks, MCP servers, configuration files, and lifecycle. Security guidance should be verified for the specific deployment rather than inferred from the label “sandbox.”

Do long-running agents need larger context windows?

Larger windows can help, but they do not solve state management by themselves. Long-running systems need explicit progress artifacts, incremental tasks, checkpoints, clean handoffs, recovery paths, and verification across sessions.

Should I use a workflow or an agent?

Use a workflow when the decision tree is known and predictability, cost, or auditability matters most. Consider an agent when the task requires exploration or adaptive tool selection. A hybrid often works well: keep high-risk and deterministic steps in code, and give the agent bounded freedom where flexibility is useful.

Can Harness Engineering make any model perform equally well?

No. A harness can expose useful context, tools, feedback, and constraints, but models differ in planning, tool use, refusal behavior, and task capability. Portability requires compatibility testing, while a specialized harness may exploit model-specific strengths. Neither strategy is universally best.

About The Author

A Gadallh

Ahmed Gadallah is the Founder and Editor of Vertex Frontier, where he publishes research-driven articles on AI, data science, cloud computing, cybersecurity, software engineering, and emerging technologies, with a focus on technical accuracy, clarity, and practical insights.

View all articles by A Gadallh →

Was this article helpful?

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

🏠 Home 🔖 Saved 📧 Join Us 📤 Share ⬆️ To Top
Read Next Why Run AI Models Locally? The Privacy, Cost, and Reliability Math Nobody Explains Properly