What a harness is
In the last two lessons you wrote a tiny harness: a loop that sends messages, runs tools and stops. Real harnesses do the same thing with many more parts. Anthropic’s documentation describes Claude Code as the layer around the model that provides the tools and manages the context the model sees, and calls that layer the agentic harness. A June 2026 survey of agent systems splits a harness into six jobs:
| What it means | Example in a coding agent | |
|---|---|---|
| Observation | Turning the world into text the model can read | File contents, command output, test results, error messages |
| Context | Choosing what goes into the context window, and what comes out | Loading instruction files, trimming old tool output, summarising |
| Control | Running the loop and deciding when to stop or ask | Step limits, interrupt keys, asking before risky actions |
| Action | Carrying out what the model asked for | Editing a file, running a command, fetching a page |
| State | Remembering things across steps and sessions | Session logs, file snapshots, memory notes |
| Verification | Checking whether the work is right | Running tests and linters, showing type errors after edits |
Quick check
Inside a coding harness
Coding harnesses are the most developed kind, because code gives clear feedback: it runs or it does not, and the tests pass or fail. Claude Code’s documentation describes its loop as three phases that blend together, gather context, take action and verify results, and groups its built-in tools into five kinds:
| What the model can do | |
|---|---|
| File operations | Read files, edit code, create, rename and reorganise files |
| Search | Find files by name pattern, search their contents, explore a codebase |
| Execution | Run shell commands, start servers, run tests, use git |
| Web | Search the web, fetch documentation, look up error messages |
| Code intelligence | See type errors after an edit, jump to a definition, find every use of a function |
Around those tools sit the parts that make a long session work:
- A system prompt written by the harness makers: how to use each tool, how to behave, when to ask.
- Instruction files written by you, such as
AGENTS.mdorCLAUDE.md, loaded at the start of every session. - A session log. Claude Code writes every message, tool call and result to a plain-text file, so a session can be resumed, forked or rewound.
- Checkpoints. Before editing a file, the harness saves a copy, so you can rewind. They cover file edits only: nothing a command sends to a database, a server or GitHub can be checkpointed.
- Compaction. When the context fills up, the harness first clears old tool output, then summarises the conversation (the next lesson).
- Extensions: skills, hooks, MCP servers and subagents, covered below.
- Interrupts. You can stop the agent at any moment, or type a correction that it reads before its next step.
| Made by | Notes | |
|---|---|---|
| Claude Code | Anthropic | Terminal, desktop, editors and web; runs Claude models |
| Codex CLI | OpenAI | Open source, written in Rust; reads AGENTS.md |
| Qwen Code | Alibaba (Qwen team) | Open source (Apache 2.0); began as a fork of Google’s Gemini CLI and has been developed separately since. Works with Qwen, other cloud APIs and local models through Ollama or vLLM |
| Kimi Code CLI | Moonshot AI | Moonshot’s terminal agent for its Kimi models; replaces the earlier open-source Kimi CLI |
| OpenHands | An open-source community, started by researchers | A platform for coding agents, with a research paper (2024) and many model choices |
| OpenCode, Aider | Open-source projects | Terminal agents that can use almost any provider, including a model on your own computer |
| mini-swe-agent, Terminus 2 | Researchers (SWE-bench and Terminal-Bench teams) | Deliberately tiny harnesses: one shell, few rules. Used to compare models fairly |
Checked on 21 October 2026. These products change every few weeks; check each project’s own page before relying on a detail.
Permissions and sandboxes
A coding agent can run any command you could run. That power is the point, and also the risk: a misunderstanding, a buggy plan or untrusted text read from the web (the tool-calling lesson) could lead to a harmful command. Harnesses answer with two tools. Permission modes decide what runs without asking. Sandboxes limit what a command can reach, whatever the model asks.
Start in “Ask first” and count how often you would be interrupted. Switch on the rule that always allows npm test: one fewer question for a command you trust. Try “Sandbox”: most actions now run without questions, but the agent still cannot write outside the project. Look closely at the last action: the sandbox lets the agent delete a folder inside your project, and no checkpoint brings it back. That is why you also keep your work in git.
This interactive part needs JavaScript.
| Claude Code | Codex CLI | |
|---|---|---|
| Modes | Manual (asks before edits and commands), Accept edits, Plan (explores and proposes, no edits), Auto (a classifier reviews actions and blocks risky ones) | Sandbox: read-only, workspace-write or danger-full-access; approvals: on-request or never |
| Sandbox on macOS | Seatbelt, built into macOS | Seatbelt |
| Sandbox on Linux | bubblewrap | bubblewrap |
| Network | Goes through a proxy outside the sandbox that limits which domains can be reached and asks about new ones | Approval is needed before using the internet, unless full access is chosen |
From each product’s documentation on 21 October 2026. Codex also has a native Windows sandbox.
Sandboxes also make agents faster to work with. Anthropic reported in October 2025 that, in its own use, sandboxing cut permission prompts by 84 %: when the operating system guarantees that a command cannot escape the project folder, the harness no longer needs to ask about every one.
Quick check
Instructions that last: AGENTS.md and friends
Every session starts with an empty context window. Anything the agent should always know, such as how to run the tests, what not to touch or how you like code written, goes into an instruction file that the harness loads at the start. OpenAI released AGENTS.md in August 2025 as “a README for agents”. In December 2025 it became, with Anthropic’s MCP and Block’s goose, one of the first three projects of the Linux Foundation’s new Agentic AI Foundation, which said over 60,000 open-source projects and agent frameworks already used it. Claude Code reads CLAUDE.md, and can read an AGENTS.md instead.
# Weather station dashboard
## Setup
- Python 3.12. Install with: pip install -r requirements.txt
- Run the app: python app.py, then open http://localhost:8000
## Tests
- Run all tests: pytest -q
- Every change must keep the tests passing. Add a test for every bug you fix.
## Code style
- Keep functions short. Use type hints.
- Temperatures are stored in Celsius; convert only when displaying.
## Do not
- Do not edit data/raw/ (readings from the station; read-only).
- Do not add new dependencies without asking.
- Commands come first: the agent can only check its work if it knows how to run the tests.
- Rules are short and concrete. “Keep functions short” is weaker than a test that fails, but it helps.
- In a large project, put another AGENTS.md in a subfolder: agents read the nearest one, and your chat instructions override them all.
- Keep it short. The file is loaded into every session and uses context every time.
Some harnesses also keep automatic memory: notes the agent writes for itself, such as your preferences, that are loaded next time. Claude Code loads up to the first 200 lines of its memory index at the start of each session. Treat both kinds of file like code: review them, and delete what is out of date.
Extensions: skills, hooks, MCP and subagents
Harnesses let you add abilities without changing the model. Four kinds of extension are now common:
| What it is | How it uses context | |
|---|---|---|
| Skill | A folder of instructions, and sometimes scripts, for one kind of task, such as making slides or following a review checklist | Only a short description is loaded at the start; the full text loads when the skill is used |
| Hook | Your own command that the harness runs at a fixed moment: before a tool runs, after an edit, when the agent stops | Uses none, unless the hook sends a message back to the model |
| MCP server | A standard plug that connects the agent to another program or service (two lessons from now) | Tool names load at the start; full definitions can load when needed |
| Subagent | A second agent with its own fresh context window, given one job | Its work stays out of the main context; only its summary comes back (the multi-agent lesson) |
Hooks deserve a closer look, because they solve a problem that words cannot. An instruction such as “always format the code after editing” depends on the model remembering it. Claude Code’s documentation calls hooks deterministic control: certain actions always happen, rather than relying on the model to choose them. A hook that runs before a tool can also refuse it.
{
"hooks": {
"PreToolUse": [{
"matcher": "Edit|Write",
"hooks": [{ "type": "command", "command": "python .claude/protect.py" }]
}],
"PostToolUse": [{
"matcher": "Edit|Write",
"hooks": [{ "type": "command", "command": "ruff format ." }]
}]
}
}
PreToolUseruns before every edit. The scriptprotect.pychecks the file path, and if it is a protected file (say, insidedata/raw/) it exits with code 2, which blocks the edit and shows the model why.PostToolUseruns after every edit and formats the code, every time, whether or not the model remembers.- Hooks run with your permissions on your computer. Only use hooks you have read and understood.
Quick check
The harness changes the score
Terminal-Bench 2.0 (ICLR 2026) has 89 hard tasks done in a computer terminal, each with its own Docker container and tests. Because every result is a model and a harness together, the benchmark’s paper could compare the same model in different harnesses. Its own minimal harness, Terminus 2, gives the model a single tool, a terminal, so that models can be compared fairly.
From Table 2 of the Terminal-Bench paper (arXiv 2601.11868). Each score has an uncertainty of about 3 points.
The same model solved about half the tasks in one harness and about a third in another. A Gemini model from the same period ranged from 15.7 % to 32.6 % across four harnesses, while Claude models varied by under 3 to about 6 points. The authors still conclude that choosing the model usually matters more than choosing the harness, and they warn that these comparisons are not fully controlled: a company’s own harness is often tuned for its own models.
Quick check
Your first session with a coding agent
You do not need an expensive subscription to start. Open-source harnesses such as Qwen Code, OpenCode, Aider and OpenHands can use cheap cloud models or a model on your own computer through llama.cpp or Ollama (the local AI lesson). Small local models make more mistakes in long sessions, so start with small tasks. Whatever you use, work like this:
- Make a folder for the project and run
git init. Commit before every session, so any mistake can be undone. - Write a short
AGENTS.md: how to run the project, how to run the tests, and what must not be touched. - Start in plan or read-only mode and ask for a plan first. Read it. Correct it if it misunderstands the goal.
- Switch to a mode that asks before commands, and let it work. Approve commands you understand; refuse and ask about the rest.
- When it finishes, read the changes with
git diffand run the tests yourself. - Commit if you are happy; restore with
git restore .if you are not. Then add what you learned to AGENTS.md.
Is each habit safe, or risky?
-
Committing to git before each session
Answer: Safe habit
-
Running in full-access mode on your everyday computer
Answer: Risky habit
-
Reading the diff before committing
Answer: Safe habit
-
Pasting your API key into the chat so the agent can use it
Answer: Risky habit
-
Starting with a plan in read-only mode
Answer: Safe habit
-
Approving every command without reading it
Answer: Risky habit
-
Allowing only the test command to run without asking
Answer: Safe habit
-
Installing a hook from a stranger without reading it
Answer: Risky habit
Remember
- A harness is the program around a model. Its six jobs are observation, context, control, action, state and verification.
- A coding harness gives the model file, search, execution, web and code-intelligence tools, and adds a system prompt, instruction files, a session log, checkpoints, compaction and interrupts.
- Permission modes decide what runs without asking; sandboxes (Seatbelt on macOS, bubblewrap on Linux) limit what commands can reach. Neither replaces git for protecting the project itself.
- AGENTS.md (or CLAUDE.md) carries lasting instructions into every session: commands first, rules short, the nearest file wins.
- Skills load on demand, hooks enforce rules in code, MCP servers connect other programs, and subagents work in their own context.
- The same model can score very differently in different harnesses: one GPT model ranged from 33.9 % to 49.6 % on Terminal-Bench 2.0. Always ask which harness a score used.
- A safe first session: git first, a short AGENTS.md, a plan in read-only mode, approvals for commands, then review the diff and run the tests.
Words to know
- harness
- The program around a model that provides its tools, runs the loop, manages its context and enforces the rules.
- coding agent
- An agent whose tools read, edit and run code in a project.
- permission mode
- The harness setting that decides which actions run at once, which ask you first and which are refused.
- allow rule
- A setting that lets one trusted command, such as the tests, run without asking.
- sandbox
- An operating-system boundary that stops commands from reaching files or networks outside what is allowed.
- checkpoint
- A copy of a file saved by the harness before an edit, so the edit can be undone.
- compaction
- Making room in a full context window by clearing old tool output and summarising the conversation.
- AGENTS.md
- An open format for a project’s instructions to coding agents, read at the start of each session.
- CLAUDE.md
- Claude Code’s instruction file, which plays the same role as AGENTS.md.
- skill
- A packaged set of instructions, and sometimes scripts, that loads only when its task comes up.
- hook
- Your own command that the harness runs at a fixed moment, such as before a tool call; it can block the call.
- subagent
- A helper agent with its own context window, which returns only a summary of its work.
- harness engineering
- Designing the instructions, tools, tests and feedback around agents so that they work reliably.
- Terminal-Bench
- A benchmark of hard tasks done in a terminal, scored for each model and harness pair.
Go to the source
This lesson is built on these papers and documents. Paper links open arxiv.org, a separate site.
-
Terminal-Bench: Benchmarking Agents on Hard, Realistic Tasks in Command Line Interfaces
89 tasks, the Terminus 2 harness, and Table 2 comparing the same models in different harnesses.
-
From Question Answering to Task Completion: A Survey on Agent System and Harness Design
The six jobs of a harness, and where the bottleneck lies: model, harness or both.
-
OpenHands: An Open Platform for AI Software Developers as Generalist Agents
How an open coding harness is built, from its sandbox to its agents.
-
SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering
The first clear evidence that the interface around a model changes its results.
-
How Claude Code works
The loop, the five kinds of tools, sessions, checkpoints, compaction and permission modes.
-
Claude Code: Automate actions with hooks
Hook events and how a hook blocks a tool call with exit code 2.
-
Anthropic Engineering: Claude Code sandboxing
Filesystem and network isolation, and the 84 % drop in permission prompts.
-
Codex: Sandboxing
Codex’s sandbox modes, approval policies and the operating-system tools behind them.
-
AGENTS.md
The format, examples, and the list of agents that read it.
-
Linux Foundation announces the formation of the Agentic AI Foundation
MCP, goose and AGENTS.md as the foundation’s first projects.
-
Harness engineering: leveraging Codex in an agent-first world
What changes when people design the environment and agents write the code.
-
Qwen Code
Alibaba’s open-source terminal agent, a readable example of a full harness.
Check yourself
5 questions. Tap the answer you think is right.
0 of 5 answered
Lesson complete
Answer every question above to complete this lesson.
Your progress is saved on this device only.
Next lessonContext engineering: choosing what the model sees