
Agent harness: the code that runs an AI agent's loop
In short: An agent harness is everything around the model: the loop, tools, context, permissions and logs, and it shapes results as much as the model.
An agent harness is the software that wraps a language model and turns it into an agent. It runs the loop, exposes tools, assembles the context sent on each turn, enforces permissions, handles errors and records what happened. Anthropic used the term in November 2025, calling its Claude Agent SDK a general-purpose agent harness. The same model can behave very differently in two harnesses.
Agent harness in plain words
The model is the engine. The harness is the rest of the car: steering, brakes, dashboard and the rules about who can drive it.
How it works
Anthropic's Building effective agents describes agents as LLMs using tools based on environmental feedback in a loop. The harness is the code that runs that loop.
On each turn it builds a prompt from the system instructions, the task, relevant files or memory and recent tool results. It sends that to the model, parses the reply, runs any requested tool inside a sandbox or permission check, appends the result and repeats.
It also decides when to stop, what to log and when to compact old context. Anthropic's context engineering guide from September 2025 describes compaction as summarising a nearly full context window and continuing from the summary.
Example
loop:
context = system + task + memory + last_tool_results (trimmed)
reply = model(context)
if reply.tool_call and allowed(reply.tool_call):
result = run_in_sandbox(reply.tool_call)
log(reply, result)
elif reply.done: break
Where you'll meet it
- Claude Code, OpenCode and similar coding agents
- Agent SDKs such as the Claude Agent SDK
- Evaluation setups, where the harness is what makes benchmark runs repeatable
- Internal enterprise agents built on plain API calls
What it changes for you
When an agent underperforms, check the harness before blaming the model: context assembly, tool descriptions, error messages and stop rules. For teams, the harness is where permissions and logging are enforced, so it is the part security and platform teams should review.
Agent harness vs agent framework
A framework is a library you use to build a harness. The harness is the running thing with your tools, prompts and policies baked in.
Common mistake
My view: benchmark scores are quoted as model scores when they are really model-plus-harness scores. Compare two models only inside the same harness, or you are comparing plumbing.
Related terms
AI agent · Agent loop · Context engineering · Agent sandbox · Permission modes
From the archive: Model leaderboards can't see the harness · Agent harnesses are release platforms
Compare two models inside the same harness, or the score tells you about the plumbing.


