Short answer
An agent harness is everything around an AI model that turns it into an agent. The usual shorthand:
Agent = model + harness.
The model reads text and writes text. The harness is what lets that text do something: it runs commands, edits files and calls tools the model asks for, feeds the results back, and repeats until the job is done. It also decides what the model can see and which actions need a human to approve them.
Claude Code, Codex CLI and Cursor's agent are all harnesses. Same idea, different wiring.
Why it matters
When a client asks "which AI should we use?", they usually mean the model. But two products running the same model can behave very differently, because the harness decides:
- What the model knows about your project. Which files, instructions and history get loaded into its context.
- What it's allowed to do. Read only, edit files, run commands, browse, deploy.
- When it stops to ask. Approval prompts for risky actions are a harness feature, not a model feature.
- What it remembers. Between steps, and between sessions.
So "the AI deleted a folder" is rarely a model problem alone. It's usually a harness that was allowed to.
What's inside a harness
| Part | Job |
|---|---|
| Agent loop | Call the model, run what it asked for, send back the result, repeat |
| Tools | The actions available: read a file, run a shell command, search the web |
| Context management | What goes into the model's limited memory, and what gets summarized or dropped |
| Controls | Permissions, approvals, sandboxing, logs |
A 2026 research paper proposes these four as the minimum for something to count as a harness.
Example
This page was drafted inside Claude Code. The model wrote the text. The harness read the existing pages, ran web searches, wrote the file, and auto-formatted it through a hook. The instructions file (AGENTS.md) telling it where learn pages go and which frontmatter to use is also loaded by the harness, not by the model.
Swap the model and keep the harness, and most of that workflow still works. Swap the harness, and you're setting all of it up again.
Often confused with
- The model (GPT, Claude, Gemini): the brain. The harness is the hands, the rules and the notebook.
- ADE (agentic development environment): the app where you manage one or several agents and review their work. A harness runs inside it. See ADE.
- Evaluation harness: in benchmarks like SWE-bench, "harness" means the test rig that runs an agent against tasks. Same word, older and narrower meaning.