An agent harness is the code around an AI model that runs its loop, gives it tools and decides what it sees. A 2026 arXiv paper puts it as "An agent is a model plus a harness". I ran one model, deepseek-flash, in two harnesses on the same tasks and read the logs. In task 1, Claude Code's first request was about 11,100 tokens with 12 tool entries. DeepSeek Harness's was about 6,100 tokens with 24 tools. Both passed all 33 hidden checks.
The runs come from my 12 run test, where I first compared the two tools on hidden checks and cost.
What is an agent harness?
An agent harness is the program that sits between you, the model and your computer. The model reads text and writes text. The tools, the loop, the permission rules, the sandbox, the logs and the cost count all belong to the harness. The arXiv paper "Harness Engineering: Anatomy, Architecture, and Evolution of Coding Agents" opens with "An agent is a model plus a harness" and describes the harness as "the runtime that couples an LLM to the world through a loop, tools, context management, safety controls" and more.
For the first task, both harnesses had to build a small CSV stats tool and write its tests.
- Context. Each harness sent my task along with its own instructions and a list of tools the model could ask for. DeepSeek Harness listed 24 tools. Claude Code listed 12 entries.
- Tools and the loop. deepseek-flash cannot create a file. In one Claude Code run it asked to write two files, csvstats.py and its test file. Claude Code wrote them, sent back a short "File created successfully" note for each and asked the model again. That went on until the model gave its final answer.
- Permissions. I let both tools edit and run files without asking me. Both also have modes that ask first.
- Sandbox. DeepSeek Harness ran the shell commands under Landlock, a Linux feature that fences what a command can touch. Claude Code has a sandbox too, but it is off by default.
- Logs and cost. Both kept a record of every request. DeepSeek Harness showed a cost estimate that matched my math in the one run I checked. Claude Code's estimate was 42x to 48x too high on DeepSeek.

What my logs show: same model, two harnesses
With the same model and the same task text, the two harnesses sent a very different first request. Claude Code's was about 11,100 tokens. DeepSeek Harness's was about 6,100.
Both ran deepseek-flash at max effort, and each run started in a fresh folder. I used DeepSeek Harness 0.2.2-rc.5 and Claude Code 2.1.310, both headless. The harness records every request header, its tools and its token use in a session log. Claude Code records the request shape and the usage per request in a session transcript. The numbers below are my reading of those logs.
The first request each harness sent to deepseek-flash
| DeepSeek Harness | Claude Code | |
|---|---|---|
| Tokens in the first request, task 1 | 6,138 to 6,142. Run 1 all new, runs 2 and 3: 382 new + 5,760 cache hit | 11,070 to 11,074, all new, no cache hit in any run |
| Tokens in the first request, task 2 | 6,005 to 6,007, mostly cache hit (5,504 to 5,632) | 10,937 to 10,939, all new, no cache hit in any run |
| Tools offered to the model | 24 | 12 entries: 11 named tools plus one placeholder entry |
| Size of the tool definitions (characters of JSON) | about 20,800 | about 29,700 |
| Size of the main system prompt (characters) | about 3,200 (log record size) | about 5,650, plus a separate environment section |
Source: My own logs of the runs on November 30, 2026, deepseek-flash at max effort. The task text was the same for both tools

The task text was identical, so by my reading the gap of about 5,000 tokens is mostly the harnesses' own text: instructions, tool descriptions and, in Claude Code, a separate environment section. A system prompt is the standing instruction text a harness sends with every request, and the tool descriptions tell the model what each tool does.
The tool lists also differ. The harness offered 24 tools. Claude Code's request listed 11 named tools and one placeholder entry. In my Claude Code runs on task 1 the model mostly used Bash and Write. So in Claude Code, most of the offered tools sat unused in these small jobs.
In my runs the bigger first request did not decide the cost. The job costs of the two tools overlapped, as the figures below show. DeepSeek charges much less for input it has already seen, called a cache hit: $0.003 per 1M tokens off-peak, against $0.15 for new input. Claude Code's first request had no cache hit in any run, but its later requests were mostly cache hits. On request 2 of task 1 run 2 it sent 237 new tokens and 11,776 cache hit tokens. The harness's first request had no cache hit in its very first run and was mostly cache hits after that, which I read as the same harness text having been sent before.
Every run in the 12 run test passed every hidden check, 33 of 33 per tool. Costs overlapped: $0.0054 to $0.0123 per job for the harness and $0.0057 to $0.0111 for Claude Code, by my math.
The parts of a harness
I split a harness into nine parts: the loop, tools, context, permissions, sandbox, session and memory, cost tracking, extensions and model choice. The table shows each part in the two harnesses I ran.
Harness parts, in the two harnesses I ran
| Part | What it does | DeepSeek Harness | Claude Code |
|---|---|---|---|
| Loop | Calls the model, runs the tool it asks for, returns the result, repeats | Model call, tool call, result, repeat. The Trajectory tab lists every tool call | The same cycle |
| Tools | Lets the model act on files and commands | 24 tools in the first request | 12 entries in the first request |
| Context | Decides what the model sees | System prompt of about 3,200 characters and about 20,800 characters of tool definitions | System prompt of about 5,650 characters plus an environment section, and about 29,700 characters of tool definitions. A compaction window setting exists, which I did not test |
| Permissions | Asks before risky actions | Read Only, Workspace Write, Full access | default, acceptEdits, plan, auto, dontAsk, bypassPermissions |
| Sandbox | Fences shell commands | Shell commands ran under Landlock, which was partial on the kernel I used | A sandbox using bubblewrap on Linux, off by default, covering shell commands only |
| Session and memory | Keeps a record of the work | Session logs with each request and its token use | Session transcripts with the request shape and usage |
| Cost tracking | Counts tokens and prices them | A per answer estimate, about $0.0072 in one run I checked, which matched my math | Prices unknown models at list price, so the readout was 42x to 48x too high until I added a modelPricing row |
| Extensions | Adds new abilities | Everything is a plugin: built in Subagent, Web search and fetch, Agent loop and Shell | Subagents, plugins, hooks and MCP |
| Model choice | Picks which model it talks to | 42 built in providers plus custom APIs | DeepSeek documents the setup. Anthropic's gateway page says it does not support non Claude models |
Source: My own logs and runs on November 30, 2026, the DeepSeek Harness README and Anthropic's Claude Code docs. I did not test compaction or Claude Code's sandbox
In DeepSeek Harness you can watch the loop happen in the Trajectory tab.

For the cost row, my Claude Code setup post shows the readout problem and the fix. For the install side, see the DeepSeek Harness setup guide.
Agent harness vs agent loop vs framework vs runtime vs MCP
In my reading, the agent loop is one part of a harness, a framework is a toolkit you build an agent with, a runtime is a lower layer that can power a framework, and MCP is a standard for plugging tools and data into a harness. The terms are not settled. LangChain's Harrison Chase writes "the lines are blurry". In a Turing Post interview, OpenAI's Michael Bolin says the harness is "what we sometimes call the agent loop". The arXiv paper uses the wider definition from above.
Running coding agents on real work? Get a practical setup that wastes less of your limit.
How the common terms are used
| Term | What it means in the source | Source |
|---|---|---|
| Agent harness | The runtime around the model: loop, tools, context management and safety controls. LangChain lists DeepAgents as a harness, with batteries included | arXiv paper; LangChain |
| Agent loop | The cycle where the model either answers or requests a tool call, repeating until it stops requesting tools. Bolin also uses harness for the loop | OpenAI, Unrolling the Codex agent loop; Turing Post interview with Bolin |
| Agent framework | Examples from LangChain: LangChain, Vercel's AI SDK, CrewAI, OpenAI Agents SDK, Google ADK, LlamaIndex. LangChain gives no single definition and says the lines are blurry | LangChain |
| Agent runtime | Lower level than a framework and able to power one. LangChain's example is LangGraph, which it says is probably best described as both a runtime and a framework | LangChain |
| MCP | An open source standard for connecting AI applications to external systems | modelcontextprotocol.io |
Source: LangChain, OpenAI, the arXiv paper and the MCP docs, checked November 30, 2026. The terms are not settled and sources use them differently
An agent harness vs agent loop: the loop is one part inside the harness, unless you follow Bolin, who uses the two words for the same thing. An agent harness vs agent framework: in my reading, a framework is something you build with, and a harness is something that already runs, but LangChain itself says the lines are blurry. Of DeepAgents, LangChain writes that "it comes with batteries included". It also admits LangGraph is "probably best described as both a runtime and a framework". The arXiv paper's source code study of the eleven systems found "no agent runtime imports a general-purpose agentic framework".
MCP is not a harness. It is a standard way to plug tools and data into an AI application, and it does not run the loop. A harness can use MCP servers as one source of tools. My MCP explainer covers it in full.
Harness engineering
The arXiv abstract defines it: "Harness engineering, named as a discipline in early 2026, is the design and evolution of that runtime."
OpenAI's post "Harness engineering: leveraging Codex in an agent-first world" by Ryan Lopopolo came out on February 11, 2026. It does not define a harness. Martin Fowler's site has a memo by Birgitta Böckeler noting the article mentions the word only once in its text. The post's idea is that engineers work "to design environments, specify intent, and build feedback loops". Its numbers: a product built over five months with "0 lines of manually-written code", on the order of a million lines of code, and roughly 1,500 pull requests opened and merged.
Anthropic's engineering post "Effective harnesses for long-running agents" describes a case of changing only the harness. It calls the Claude Agent SDK "a powerful, general-purpose agent harness adept at coding". Without help, the agent tried "to one-shot the app", and a later session would "declare the job done" too early. Anthropic's fix was in the harness, not the model. A first session with a special prompt sets up the environment, a claude-progress.txt file "that keeps a log of what agents have done" carries the state, and later sessions work on "only one feature at a time".
Agent harness examples
Claude Code, Codex CLI, DeepSeek Harness and Pi are four coding harnesses. Two more are the Claude Agent SDK and LangChain's DeepAgents, which the Anthropic and LangChain posts call harnesses.
Agent harness examples
| Name | Who makes it | License or status | Source |
|---|---|---|---|
| Claude Code | Anthropic | Not open source. The repo says all rights reserved | github.com/anthropics/claude-code |
| Codex CLI | OpenAI | Apache 2.0. Described as a coding agent that runs locally on your computer | github.com/openai/codex |
| DeepSeek Harness (dsh) | DeepSeek AI | MIT. Described as an open source agent harness | github.com/deepseek-ai/deepseek-harness |
| Pi | The earendil-works GitHub organization | MIT. Described as a minimal, extensible agent harness | github.com/earendil-works/pi |
| Claude Agent SDK | Anthropic | Renamed from the Claude Code SDK in 2025. Anthropic calls it the harness that powers Claude Code | Anthropic blog, September 29, 2025 |
| DeepAgents | LangChain | Listed by LangChain as a harness | LangChain blog, October 25, 2025 |
Source: Each project's own page, the Anthropic and LangChain posts and the arXiv paper, checked November 30, 2026
The arXiv paper's list of eleven systems also has Gemini CLI, Mistral Vibe, OpenHands, Aider, Mini-SWE-Agent, Hermes, OpenCode and OpenClaw. I make no claims about those. The same paper's abstract ends by mentioning "a 90-line minimum-viable-harness scaffold".
Which harness should you use?
Both of mine passed all 33 checks, so the checks did not help me choose. What I actually ran into was the sandbox and the cost readout, and Claude Code's readout was 42x off until I fixed it.
For DeepSeek jobs on my own server I use DeepSeek Harness, and its cost estimate matched my math in the one run I checked. If you run Claude Code on DeepSeek, the pricing row in my setup post fixes its cost readout. Anthropic does not support that setup.
Read the series
The other posts in this series, plus my MCP explainer:
- DeepSeek Harness vs Claude Code: 12 Runs, Under 10 Cents: the 12 run test, with the hidden checks and the costs.
- Claude Code with DeepSeek: Setup and the Real Cost: the 9 settings, the readout that was 42x too high and the modelPricing fix.
- DeepSeek Harness Setup: Install, Login, 24/7 Server: a fresh install on Windows, then how to run it as a 24/7 service on a server.
- MCP explained: what MCP is and how it plugs tools into an agent.
What I did not test
My numbers come from two small tasks, one model and one machine. This is not a benchmark and not a ranking.
- Other models. Both harnesses ran
deepseek-flash. - Gemini CLI, OpenHands, Aider and the other systems in the arXiv list.
- Codex CLI, Pi, the Claude Agent SDK and DeepAgents. I list them from their own pages and I did not run them.
- Compaction, which is how a harness shrinks a long history, on either tool.
- Whether the roughly 5,000 extra tokens in Claude Code's first request change how the model behaves. I only measured the size.
- The small separate request that DeepSeek Harness sends to name a session. I only saw it in the harness log, and I make no claim about whether Claude Code does the same.
Sources
- arXiv: Harness Engineering: Anatomy, Architecture, and Evolution of Coding Agents
- OpenAI: Unrolling the Codex agent loop
- Turing Post: interview with Michael Bolin
- OpenAI: Harness engineering, leveraging Codex in an agent-first world
- Martin Fowler: harness engineering memo
- Anthropic: Building agents with the Claude Agent SDK
- Anthropic: Effective harnesses for long-running agents
- LangChain: Agent Frameworks, Runtimes, and Harnesses
- DeepSeek Harness on GitHub
- Pi on GitHub
- Claude Code on GitHub
- Codex CLI on GitHub
- DeepSeek: API pricing
- Model Context Protocol: introduction
All pages were checked on November 30, 2026. The test runs are mine, and every figure marked as my math is token counts priced at DeepSeek's list prices, not a bill.
FAQ
What is an agent harness in simple words?
It is the program around an AI model that lets the model act. It sends the model your task and a tool list, runs the tools the model asks for and returns the results.
What is the difference between an agent harness and an agent framework?
In my reading, a framework is a toolkit you use to build your own agent, and a harness is a runtime that already comes with the loop, tools and safety controls. LangChain's own post admits the lines are blurry, so people use the words in different ways.
What is the difference between an agent harness and an agent loop?
The loop is one part of the harness: call the model, run the tool it asks for, give back the result, repeat. OpenAI's Michael Bolin says the harness is what they sometimes call the agent loop. The arXiv paper uses a wider meaning that also covers tools, context and safety controls.
Is MCP an agent harness?
No. MCP is an open source standard for connecting AI applications to external systems. It is a way to plug tools and data into a harness, and it does not run the loop itself.
What is harness engineering?
The arXiv paper calls it the design and evolution of the runtime around the model, a discipline named in early 2026. OpenAI used the term in a February 2026 post about building with Codex. Anthropic described harness changes, not model changes, as its fix for long coding jobs.
Which agent harnesses are open source?
DeepSeek Harness and Pi are MIT licensed, and OpenAI's Codex CLI is Apache 2.0. Claude Code is not open source, and its repo says all rights reserved.

Founder of Spectrum AI Labs, testing AI tools and models, and writing up what actually ships.
More about Paras →Stay ahead of the AI curve
We test new AI tools every week and share honest results. Join our newsletter.



