What is an AI coding agent harness?
An agent harness is everything around the model: the loop, tools, context, permissions, and state. What a coding agent harness does and how to improve yours.
Two teams use the same model. One says its coding agent loses track of long tasks, declares features done that don't work, and redoes work from yesterday. The other runs multi-day projects with few problems. The model is identical. The difference is everything around it.
That surrounding software is the harness. This guide explains what a harness does and how to improve yours, drawing on Anthropic's Effective harnesses for long-running agents, checked on 16 November 2026.
Agent = model + harness
A language model takes text in and produces text out. On its own it can't read a file, run a test, or remember yesterday. The harness makes it an agent:
| Harness part | What it does |
|---|---|
| The loop | Sends the prompt, runs the tools the model asks for, returns results, repeats |
| Tools | File reads and edits, shell commands, search, MCP servers |
| Context management | Decides what loads up front, what's fetched on demand, when to compact |
| Instructions | System prompt, plus project files such as CLAUDE.md or AGENTS.md |
| Permissions | Which actions run freely, which need approval, which are blocked |
| State | Session transcripts, progress files, memory, git history |
| Verification | Tests, browser automation, checks the agent can run on its own work |
Claude Code, Codex CLI, and Antigravity are harnesses. Anthropic calls the Claude Agent SDK, which packages Claude Code's internals as a library, a general-purpose agent harness. Anthropic's Managed Agents is a harness Anthropic hosts.
Why the harness matters
Anthropic's post describes running a frontier model on the Agent SDK, in a loop, with compaction, and asking it to build a production-quality web app from a high-level prompt. It fell short. The failures were harness failures:
- Doing too much at once. The agent tried to build everything in one go, ran out of context mid-feature, and left the next session guessing.
- Declaring victory early. A later session saw progress and decided the job was done.
- Not testing end to end. It marked features complete after unit tests or curl calls, without checking them as a user would.
The fixes were harness changes, not model changes.
What a good coding harness adds
Anthropic's solution split the work into two kinds of session:
- An initializer session that sets up the environment: an
init.shscript, a progress file logging what agents have done, a feature list with every feature marked failing, and a first git commit. - Coding sessions that each work on one feature, commit with a clear message, update the progress file, and leave the code in a state fit to merge.
Details that mattered:
- The feature list was JSON, because the model was less likely to wrongly rewrite JSON than markdown. Agents could only flip a
passesfield. - Git was the recovery mechanism. Bad changes could be reverted to a known working state.
- Browser automation for testing let the agent find bugs that weren't visible in the code.
Each new session starts by reading the progress file and git log, so it knows where things stand without guessing.
How to improve your harness without writing one
You don't need to build a harness to tune one. In Claude Code, most parts are configuration:
| Harness part | In Claude Code |
|---|---|
| Instructions | CLAUDE.md, kept short |
| Procedures | Skills that load on demand |
| Guardrails | Hooks and permission rules |
| Tools | MCP servers |
| Verification | Test commands in CLAUDE.md, browser tools via MCP |
| State | A progress file, git commits, auto memory |
| Parallel work | Subagents and workflows |
A good first step is Anthropic's pattern: a progress file the agent reads at the start and updates at the end of every session, and one task at a time.
Harness engineering vs context engineering
Some people call this work harness engineering. It overlaps heavily with context engineering: much of what a harness does is decide what the model sees each turn. The harness view adds the parts outside the context window: tools, permissions, verification, and recovery.
The state a harness can't create
A progress file tells the next session what the last one did. It doesn't tell any session what the team decided in a meeting the agent never saw, such as which API stays frozen or why a library was rejected. That state lives with people, and a harness can only load it if someone puts it somewhere the harness reads.
Where Lockstep fits
Lockstep adds that layer to Claude Code's harness. It captures decisions from PRDs, Slack, and pull requests, routes each to its owner for approval, and uses Claude Code hooks to brief each session on the approved decisions that apply to the work. Any MCP client can also query them.
See how it works.
Sources checked 16 November 2026
- https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents
- https://code.claude.com/docs/en/agent-sdk/overview
Related reading
For building on the SDK harness, see Claude Agent SDK vs Claude Code. For agent memory options, see how to give an AI agent memory. For the terms themselves, see agentic AI vs AI agents vs generative AI.
Frequently asked questions
- What is an agent harness?
- The software that runs a model as an agent: it sends prompts, executes the tools the model calls, feeds results back, manages what's in the context window, enforces permissions, and keeps state between sessions. Anthropic describes the Claude Agent SDK as a general-purpose agent harness.
- What is the difference between an AI coding agent and a harness?
- The agent is the whole system you use. The harness is everything in it except the model. Claude Code is a harness running Claude models; Codex is a harness running OpenAI models. Swapping the model in a harness, or the harness around a model, changes how the agent behaves.
- Why does the harness matter so much?
- The model only sees what the harness puts in its context and can only do what its tools allow. Anthropic found that even a frontier model running in a loop with compaction failed at long projects until the harness added a feature list, a progress file, git commits, and end-to-end testing tools.
- Can I improve my coding agent's harness without writing one?
- Yes. Instruction files, skills, hooks, MCP servers, permission rules, and progress files are all harness configuration. Most of the gains Anthropic describes for long-running agents come from setup like this, not custom code.
- What is harness engineering?
- A name some people use for designing and tuning the harness around a model: tools, context loading, verification, and state handling. It overlaps heavily with context engineering, which focuses on what goes into the context window each turn.
Keep reading