What Is Harness Engineering? (2027)

  • Published:
  • 14 min read

Imagine this nightmare scenario: Your coding agent runs overnight, and by morning, it’s opened a pull request that deletes a config file. It wasn’t specifically directed to delete this file. In fact, the model followed its prompt. What was missing was a permission check before the file deletion, a test that fails when a required config file goes missing, and a trace you can read to understand what actually happened. Harness engineering is building those pieces: the permissions, checks, and traces that make it safer to delegate work to an AI agent.

Teams that don’t want to build all of this themselves are looking for providers that simplify standing up the runtime, sandboxes, and permissions around their agents. DigitalOcean Managed Agents, in Public Preview, pairs Harness Runtime with Action Gateway, which can be set to require human approval before an agent uses a specific tool. Let’s explore how harness engineering works, how it differs from prompt and context engineering, and how to run your own agent harness on DigitalOcean.

Key takeaways:

  • Harness engineering is the practice of designing the tools, context, constraints, and feedback loops around an AI model so agents can run multi-step work reliably.

  • Done well, it makes agent runs finish more reliably, makes failures traceable, limits what an agent can touch, and cuts spend on runaway loops.

  • Start with one agent and one repeatable task, define a check for “good,” add a guide or sensor for each failure, and scale up only when runs hold steady.

  • DigitalOcean Managed Agents, in Public Preview, runs the harnesses you already use on Harness Runtime and Action Gateway, so you keep control of the engineering while it handles the runtime.

What is harness engineering?

Harness engineering in AI is the discipline of designing the tools, context, constraints, feedback loops, and runtime around an AI model so it can execute multi-step work reliably. The harness encompasses everything in an agent except the model, or as LangChain’s Vivek Trivedy puts it, Agent = Model + Harness.

“Harness engineering” took shape in early 2026, as teams building with coding agents began treating the environment around the model as something to engineer. A common starting point is a simple rule: whenever an agent makes a mistake, engineer a fix so it never makes that mistake again.

Harness engineering vs. an agent harness

An agent harness is the working system you build around the model, made up of its prompts, tools, and runtime; harness engineering is the practice of designing and improving it.

You’re probably already familiar with options like Claude Code, Codex CLI, and OpenCode. The practice covers how you design, test, and improve those pieces day to day. For component-level detail, read our guide: What is an agent harness?.

Harness engineering vs. prompt and context engineering

Prompt engineering shapes what you ask the model, context engineering shapes what the model can see, and harness engineering shapes the environment the agent works in.

Discipline What you design Scope Typical failure it addresses
Prompt engineering The instructions and examples you give the model A single request or exchange Vague or off-target answers to one request
Context engineering The information the model sees, such as retrieved documents, history, and tool results What the model reads at each step Wrong or stale information, and quality that drops as histories grow
Harness engineering The tools, context, constraints, feedback loops, and runtime around the model The whole agent across many steps, from tool access to observability Repeated mistakes, unsafe actions, and runs that stop early or declare success too soon

There isn’t complete agreement as to how these concepts nest. Some treat prompt and context engineering as parts of harness engineering, while others describe engineering a harness as a specific form of context engineering. Context engineering is also a discipline in its own right, so treat it as a neighbor, not a stepping stone. A well-built context pipeline still needs sandboxes, permissions, and traces around it.

Why harness engineering matters

Here’s why teams now treat the layer around the model as engineering work:

  • The first is the Gap between a demo and production. OpenAI’s team reported that early progress was slower than it expected, and it traced the cause to an underspecified environment instead of a weak model. Anthropic saw the same on long tasks: an agent given only a high-level prompt tried to do too much at once or declared the job finished early, and a feature list, a progress file, and end-to-end tests fixed it.

  • The second is governance at scale. Once many agents run with different tools and permissions, nobody can say what each one may touch. Databricks calls this agent sprawl and argues for shared harness infrastructure with central permissions, evaluation, and observability. Gartner added a forecast in June 2025 that over 40% of agentic AI projects will be canceled by the end of 2027, citing escalating costs, unclear business value, or inadequate risk controls.

  • The third is cost. A retry deep into a long session re-sends all the accumulated context, so an agent without checks pays again for every repeat of the same mistake. Port describes the harness as an upfront investment that lowers the cost of every run after it, and DigitalOcean estimates that infrastructure makes up roughly 3 to 8% of a typical agent run’s cost, with tokens covering the rest.

Don’t pay for the minutes an agent spends waiting on a model or a person. The agent-first cloud: why we built Managed Agents explains how Harness Runtime bills CPU per second of actual use.

What harness engineering involves

Harness engineering involves the controls that keep an agent on track, what it can see and remember, what it can access, and how you find out what it did.

For more on each component, see our guide to what is an agent harness?

Guides and sensors

Guides and sensors are the two controls that keep an agent on track:

  • Guides are feedforward controls that steer the agent before it acts, such as rules in an instructions file or a project template.

  • Sensors are feedback controls that check the result afterward, such as tests, linters, or a review pass by another model, and a failure goes back to the agent to fix.

Neither is enough alone: a guide can be ignored, and a sensor only fires after the mistake.

To see how checks like these fit together, Dru Knox, Tessl’s head of product and AI research, walks through the inner, outer, and meta loops of harness engineering:

Context, memory, and durable state

An agent only works with what is in front of it, so context and memory decide what it can see and what it keeps between sessions. With durable state, a session survives idle time and resumes where it stopped. One large instructions file can crowd out the task and go stale, so a short file that points to deeper documents holds up better. For long tasks, give each new session a progress file and a git history to read first.

On Managed Agents, a paused session resumes with its files, processes, and context intact.

Sandboxes, permissions, and tool access

Sandboxes, permissions, and tool access define what an agent can run, which hosts it can reach, and which credentials it can use. Every tool you give an agent can be misused, so each one gets scoped.

In Harness Runtime, a sandbox reaches any host by default, so naming one allowed host turns on an allowlist that denies everything else. That lets a document-review agent run deny-by-default with a narrow allowlist.

Observability, evaluation, and human review

Observability, evaluation, and human review tell you what an agent did, whether the run succeeded, and when a human should step in. In practice, that means logging every tool call and model decision as a trace, recording who approved sensitive actions, and scoring outputs against your definition of “good.” It also means reading a sample of traces by hand, including runs that passed, because some failures look like successes.

Some failures look like successes. A tool call can return a 200 and still query the wrong region, so nothing errors and the run looks fine. Signals, DigitalOcean’s tool for this, groups turns into sessions and flags the ones worth a closer look. A cluster of wrong-region queries can then become a targeted eval without any manual test-data prep.

The steering loop: improving the harness over time

The steering loop is the practice that ties the four areas together: observe a failure, add a guide or a sensor, re-run, and keep what works.

The rule is simple: when an issue happens more than once, improve the controls so it’s less likely to recur. On DigitalOcean, Signals (Public Preview) flags sessions that failed. You export them to Evaluations, and Simulations tests the fix in an isolated sandbox before you ship it.

Benefits of harness engineering

Harness engineering pays off once an agent moves from a demo to a system that people depend on. The gains show up in how reliably runs finish, how quickly you can explain a failure, and how much risk you take on:

  • More reliable multi-step runs: Guides and sensors catch a wrong turn before it compounds across later steps. You spend less time rerunning tasks that failed at step nine.

  • Failures you can trace: Logging every tool call and decision gives you a record to debug from.

  • Safer tool access: Scoped permissions and approval gates limit what an agent does on its own. You decide which actions run automatically and which wait for a person, such as human approval in Action Gateway.

  • Less wasted spend on runaway loops: Step limits and checks prevent an agent from retrying the same failing call. You pay for work that moves the task forward, not for repeats.

  • An agent harness that carries over when you swap models: The tools, checks, and state you’ve built stay in place when a new model arrives. Run your existing checks against the new model to see what changed, instead of rebuilding around it.

Who grades the runs when there are thousands of them? Our guide to LLM-as-a-judge covers how to write rubrics for judge models and common pitfalls in running AI evals.

Common harness engineering mistakes

Most harness failures come from a few predictable shortcuts:

  • Treating one AGENTS.md file as the whole harness: A single rules file decays as the system changes. Keep the file short, point it at deeper documents, and update it whenever a failure teaches you something.

  • Assuming better models require less harness engineering: The broader the scope you give an agent, the more structure it needs. Regardless of how models improve, harness engineering remains important. Re-test your constraints when you swap models, and remove them only after the failures they guard against no longer consistently appear.

  • Confusing guardrails with the harness: Guardrails are protective checks on what goes into and comes out of a model, such as input filters, output moderation, and human review. The harness also gives the agent the right information in advance, so many potential errors do not actually occur.

  • Handing the agent every tool and credential up front: Tool overload and missing guardrails are among the most common failure modes. A key stored in the agent’s environment is one bad prompt away from exposure. In Managed Agents, Action Gateway helps close that gap by brokering credentials at execution time, so keys never reach the model, the prompt, or the sandbox. Read our guide to managing credentials for autonomous agents for the full approach.

  • Accepting the agent’s word that it’s done: Agents can mark features complete without end-to-end testing, or declare a whole project finished early. Check the artifact, such as passing tests or a feature list, instead of the transcript.

How to get started with harness engineering

You don’t need to build or buy a full platform to start. A small loop is enough, and each step gives the next one something to work with:

  1. Pick one agent and one repeatable task: Choose work you run often, such as triaging tickets or fixing lint errors so that you can compare runs.

  2. Write down what “good” looks like: Turn it into a check you can run, such as tests that pass a rubric, or a score from a judge model.

  3. Run it, capture traces, and record what fails: Make sure you can get a trace of every run, then review them. The failures you find in those traces tell you what to fix first.

  4. Add a guide or a sensor for each failure, then re-run: A guide is a rule that steers the agent away from the mistake, and a sensor is a check that catches it when it happens. Change one guide or sensor at a time so you know what improved the desired result.

  5. Tighten permissions and add approval gates: Narrow tool access to what the task needs before you let the agent run without a person approving each action.

  6. Scale up only when results are consistent from run to run: Add tasks or parallel sessions after every check you defined in step 2 passes on several runs in a row.

Where should the approval gate sit, before the model or after it? Our guide to LLM guardrails covers pre-processing, in-processing, and post-processing checks, including human-in-the-loop review.

Run your harness on DigitalOcean Managed Agents

image alt text

DigitalOcean Managed Agents (Public Preview) is a managed runtime for running agents in production. It connects two parts: Harness Runtime, which runs and persists agent sessions, and Action Gateway, which gives agents governed access to tools. Managed Agents runs the harnesses you already use, including Claude Code, Codex CLI, OpenCode, Hermes, and agents built with LangGraph or CrewAI—plus your own agents as Open Container Initiative (OCI) images.

You still design the harness, guides, and sensors included.

Managed Agents provides the runtime underneath it, and its capabilities map to the rest of what harness engineering involves: context and durable state, sandboxes and permissions, observability, and the steering loop:

What harness engineering involves How to use with DigitalOcean Managed Agents
Context, memory, and durable state Managed Agents persist across devices and teammates. You can pause and resume a session in about 300 milliseconds, or checkpoint it and fork a new one.
Sandboxes, permissions, and tool access Harness Runtime runs each session in its own Firecracker microVM, a lightweight virtual machine, with its own compute and filesystem and per-session access controls. Action Gateway gives agents access to 16,000+ tools through a single managed Model Context Protocol (MCP) endpoint, with credential brokering and per-tool permissions that can be set to require human approval.
Observability, evaluation, and human review Harness Runtime records structured events for tool calls, model requests, and file operations. You can inspect token usage and approval activity. DigitalOcean Insights (Public Preview) offers a unified view of runs across Harness Runtime, Action Gateway, and built-in tools, with metrics, logs, and traces.
The steering loop DigitalOcean Signals (Public Preview, opt-in) flags production sessions where users got frustrated, tools failed, or an agent looped. Simulations in DigitalOcean Evaluations then test a change on multi-turn scenarios built from those sessions before it ships. In the preview, Simulations cover harnesses on Harness Runtime such as Claude Code, Codex, and OpenCode. Agents built with LangChain, Hermes, or CrewAI aren’t supported in the preview.

DigitalOcean Managed Agents key features:

  • Isolated sessions: each session gets its own Firecracker microVM, with dedicated compute and a separate filesystem.

  • Pause, resume, and fork: you can pause and resume a session, or checkpoint it and fork a new one.

  • Action Gateway can require approval for individual tool calls; it brokers credentials on the agent’s behalf.

DigitalOcean Managed Agents pricing:

  • Managed Agents plans: Free Trial with a $5 credit (new DigitalOcean customers only), Pro at $50/month with 15% off usage on the $50 plan credit, and Team at $200/month with 20% off usage on the $200 plan credit.

  • Harness Runtime pricing: billed per second, from $0.044 per vCPU-hour and $0.0095 per GB-hour of memory.

  • Action Gateway pricing: $0.10 per 1,000 standard tool invocations.

Pricing and feature information in this article are based on publicly available documentation as of November 10, 2026, and may vary by region and workload. For the most current pricing and availability, please refer to each provider’s official documentation.

Public Preview products are offered without a service level agreement, are not recommended for production workloads, and their features may change or be withdrawn before general availability. See the DigitalOcean preview terms for details.

What does it take to run a swarm of agents on production incidents? Traversal, an AI site reliability engineering (SRE) startup, built its root cause analysis agents on DigitalOcean.

Harness engineering FAQ

How do I run untrusted LLM-generated code in an isolated environment?

Run it in a sandbox that doesn’t share a kernel with your host, allow only the network destinations and credentials the task needs, and pause or tear the sandbox down when the task ends. On DigitalOcean Managed Agents, Harness Runtime gives each session its own Firecracker microVM with its own compute and filesystem.

How do Firecracker microVMs, gVisor, and containers differ for agent sandboxing?

Containers share the host kernel, so a kernel exploit has the ability to reach the host. gVisor places a user-space kernel between the workload and the host and adds overhead on system-call-heavy work, while Firecracker gives each workload its own guest kernel under KVM at the cost of more memory per sandbox. Harness Runtime in DigitalOcean Managed Agents runs each session in its own Firecracker microVM, so isolation is enforced by the hypervisor rather than by container namespaces.

How do I manage secrets and API keys for autonomous agents running in the cloud?

Keep long-lived keys out of the agent’s context and filesystem, because a key in an environment file is one bad prompt or compromised dependency away from exposure. In DigitalOcean Managed Agents, Action Gateway brokers credentials at execution time, so the agent asks for a call and the key never reaches the model, the prompt, or the sandbox. Per-tool permissions then limit what each call can reach.

How do I monitor and trace AI agents running in production?

Log the inputs and outputs of every tool call and model decision, record who approved sensitive actions, and review a sample of runs by hand, including those that passed:

  • DigitalOcean Harness Runtime captures structured events for tool calls, model requests, and file operations.

  • DigitalOcean Insights (Public Preview) shows a run across Harness Runtime, Action Gateway, and built-in tools in one place, including which tools the agent called and where it slowed down.

  • Agent Data Services (Private Preview) assembles agent traces into sessions you can query

  • DigitalOcean Signals can flag where production sessions went wrong, such as failed tools or looping agents.

What does a cloud need to run long-running AI agents that persist for hours or days?

It needs durable state, so a session survives idle time, closed laptops, and context-window limits, plus an isolated sandbox for each session and governed access to tools. With DigitalOcean Managed Agents, sessions persist across devices and teammates, pause and resume, and can be checkpointed and forked.

Ship your agents faster on DigitalOcean Managed Agents

DigitalOcean Managed Agents gives the harness you engineer a managed place to run, with isolated sessions, durable state, and governed access to tools. Bring the agent you already run, and DigitalOcean handles the runtime.

Key features include:

  • Isolated Firecracker microVM sessions with their own compute and filesystem

  • Pause, resume, checkpoint, and fork for long-running work

  • Governed access to 16,000+ tools through Action Gateway, with required human approval for sensitive actions

  • Support for Claude Code, Codex CLI, OpenCode, Hermes, LangGraph, and CrewAI, or your own agent as an OCI image

→ Get started with Managed Agents today

Qencode’s CEO and co-founder, Murad Mordukhay, says Managed Agents has been “a huge force-multiplier for our team. It gets the right ticket to the right person without anyone having to watch every thread themselves.”

Results in customer environments may vary depending on configuration, implementation, and usage. Results and/or savings are not guaranteed.

Any references to third-party companies, trademarks, or logos in this document are for informational purposes only and do not imply any affiliation with, sponsorship by, or endorsement of those third parties.

About the author

Surbhi
Surbhi
Author
See author profile

Surbhi is a Technical Writer at DigitalOcean with over 5 years of expertise in cloud computing, artificial intelligence, and machine learning documentation. She blends her writing skills with technical knowledge to create accessible guides that help emerging technologists master complex concepts.

Related Resources

Articles

9 Nebius Alternatives for AI Workloads in 2027

Articles

What Is llm-d? How Distributed LLM Inference Works (2027)

Articles

4 Easy Ways to Deploy an LLM (and When to Use Each in 2027)

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.