elvex Collab is free during beta. Sign up now to lock in preferred pricing. Sign up free →

What Is an Agent Harness? Definition and How It Works

An agent harness is the software wrapped around an AI model that turns it into an agent. The model only predicts text. The harness gives it tools to call, files and memory to work from, rules about what it may touch, and the loop that keeps it working until a job is done. Claude Code, Codex, Cursor and OpenCode are all agent harnesses. The same idea is sometimes called an AI harness or an agent runtime.

Why it matters

Two teams can use the same model and get very different results, because most of what makes an agent useful lives in the harness. It decides what context the model sees, which actions it can take without asking, how it recovers from a failed step and when it stops. When people say one coding agent is “better” than another, they are often comparing harnesses, not models.

The harness is also where control sits. Permissions, audit logs and limits on spending are set there, which is why companies care about it as much as engineers do.

What’s inside an agent harness

Part What it does Examples
The loop Sends the task to the model, runs the tool calls it asks for, feeds the results back and repeats until the work is done or a limit is hit Plan, act, check, repeat
Tools The actions the agent can take Read and edit files, run shell commands, search the web, call other systems over MCP
Context management Chooses what goes into the model’s context window each turn, and trims or summarizes when it fills up Project instructions, open files, earlier tool results
Instructions and memory Standing guidance the agent reads at the start of each session AGENTS.md, CLAUDE.md, skills, saved notes
Permissions What the agent may do alone and what needs a person’s approval Allow npm test, ask before git push, block network access
Sandbox Where commands run, so a mistake can’t reach things it shouldn’t A container, a separate git worktree, a cloud machine
Subagents and handoffs Splitting work across several model calls, each with its own context Subagents, parallel agents
Interfaces Where people start, watch and steer the agent Terminal, IDE, desktop app, web, chat

How an agent harness works

A typical turn in a coding harness looks like this:

  1. Assemble context. The harness combines the system prompt, the project’s instructions, the conversation so far and your request.
  2. Ask the model. The model replies with text, a tool call, or both.
  3. Check permissions. If the tool call is allowed, the harness runs it. If it needs approval, the harness asks you.
  4. Run the tool and return the result. The output of the command, the file contents or the error goes back to the model.
  5. Repeat. The loop continues until the model says it’s done, a check passes, you stop it, or a limit on turns or spending is reached.

Everything except step 2 is the harness. That’s why a harness can make a mid-sized model useful and can waste a strong one.

Agent harness vs model vs framework

  • Model: the AI that reads and writes text, such as Claude, GPT or an open-weight model. You can usually swap the model inside a harness; many harnesses let you pick from several, and some route each task to a different one.
  • Harness: a finished program that runs a model as an agent for a job, ready to use. Claude Code, Codex and Cursor are harnesses for coding.
  • Framework or SDK: a library developers use to build their own harness, with the loop, tools and memory as building blocks.

The harness is the longer-lived choice. Models change every few months, while the way your team works with agents (skills, instruction files, permissions) stays in the harness.

What is harness engineering?

Harness engineering is the work of shaping the harness around a model so the agent does a job reliably, instead of only rewording prompts. It includes:

  • Writing the instructions the agent reads every session, and keeping them short and current.
  • Choosing the tools it gets, and describing them so the model uses them well.
  • Giving it checks it can run itself, such as tests, a type check or a linter, so it can verify its own work.
  • Setting permissions and a sandbox so it can work without asking about safe steps and can’t do damage on risky ones.
  • Managing context so long tasks don’t drown in old tool output (context engineering is a large part of this).
  • Watching where it fails and changing the setup, not just the prompt, so the same failure doesn’t come back.

Prompt engineering tunes what you say to the model. Harness engineering tunes everything around it.

Examples of agent harnesses

  • Coding: Claude Code, OpenAI Codex, Cursor’s agent, GitHub Copilot’s coding agent, OpenCode and Google Antigravity. Side-by-sides: Claude Code vs Codex and Cursor vs Claude Code.
  • General work: desktop and chat agents that work across files, email and business apps.
  • Company-wide: an enterprise AI platform is a harness run for a whole organization, with central permissions, connectors and audit logs.

Choosing a harness for a team

  • Models: one vendor’s, or several, or your own.
  • Where it runs: terminal, IDE, desktop, web, or in the cloud while you’re away.
  • Controls: permissions, sandboxing, audit logs and spending limits that IT can manage.
  • Instruction files: whether it reads AGENTS.md, so one file can serve people on different tools.
  • Connections: MCP support for your other systems.

How elvex relates

elvex Enterprise is a company-wide harness that works with any model, including lower-cost open-weight models, with the controls IT needs. elvex itself doesn’t replace the harness people already use: it connects them, so your Claude Code and a teammate’s Codex can work in the same thread, see each other’s plans and hand off to-dos. See Claude Code multiplayer and what is an enterprise AI harness?.

  • Agentic AI

  • Agentic coding

  • AI agent framework

  • Model Context Protocol (MCP)

  • Context window

  • What is an agent harness?
    The software around an AI model that makes it an agent: the loop that runs it, the tools it can call, the context and instructions it reads, and the permissions that limit what it can do.

  • What is an AI harness?
    Another name for an agent harness: the program that runs a model as an agent, with tools, memory and permissions around it.

  • What is harness engineering?
    Shaping everything around a model, its instructions, tools, checks, permissions and context, so an agent does a job reliably, rather than only rewording prompts.

  • Is Claude Code an agent harness?
    Yes. Claude Code runs Anthropic’s models in a loop with tools to read and edit files and run commands, project instructions in CLAUDE.md, and permissions you set. Codex, Cursor and OpenCode are harnesses too.

  • What’s the difference between an agent harness and an agent framework?
    A harness is a finished program you use to run an agent. A framework is a library developers use to build their own harness.

Bring your agent. Bring your team.