Availit World How AI really works, in your language

Lesson 33 of 4627 minFacts checked October 21, 2026

Harnesses: the program around the model

Claude Code, Codex CLI, Qwen Code, OpenHands: these are not models. They are harnesses, the programs that give a model its tools, decide what it may touch, keep its notes, and manage what it sees. The same model can score many points higher or lower depending on the harness around it. This lesson opens a coding harness and names its parts, shows how permissions and sandboxes keep you safe, explains the instruction files and extensions you can add, and ends with a careful first session you can run yourself with free or local models.

In this lesson you will

  • Name the jobs a harness does around a model
  • Know the parts of a coding harness: tools, loop, memory files, checkpoints, compaction and extensions
  • Choose a permission mode, and know what a sandbox does and does not protect
  • Write an AGENTS.md or CLAUDE.md file, and know when a hook beats an instruction
  • Read benchmark results that compare harnesses, and know how much the harness matters
  • Run a safe first session with a coding agent
On this page
  1. What a harness is
  2. Inside a coding harness
  3. Permissions and sandboxes
  4. Instructions that last: AGENTS.md and friends
  5. Extensions: skills, hooks, MCP and subagents
  6. The harness changes the score
  7. Your first session with a coding agent
  8. Remember
  9. Check yourself

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:

The six jobs of a harness
What it meansExample in a coding agent
ObservationTurning the world into text the model can readFile contents, command output, test results, error messages
ContextChoosing what goes into the context window, and what comes outLoading instruction files, trimming old tool output, summarising
ControlRunning the loop and deciding when to stop or askStep limits, interrupt keys, asking before risky actions
ActionCarrying out what the model asked forEditing a file, running a command, fetching a page
StateRemembering things across steps and sessionsSession logs, file snapshots, memory notes
VerificationChecking whether the work is rightRunning tests and linters, showing type errors after edits

Quick check

Claude Code and Codex CLI are best described as…

Show the answer

Answer: Harnesses: programs that give a model tools, permissions, memory and context Each runs a model (from its own company, or others in many cases) inside a loop with tools and rules. The model reasons; the harness acts and keeps it safe.

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:

The tools a coding harness gives a model
What the model can do
File operationsRead files, edit code, create, rename and reorganise files
SearchFind files by name pattern, search their contents, explore a codebase
ExecutionRun shell commands, start servers, run tests, use git
WebSearch the web, fetch documentation, look up error messages
Code intelligenceSee 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.md or CLAUDE.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.
Some harnesses you can use
Made byNotes
Claude CodeAnthropicTerminal, desktop, editors and web; runs Claude models
Codex CLIOpenAIOpen source, written in Rust; reads AGENTS.md
Qwen CodeAlibaba (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 CLIMoonshot AIMoonshot’s terminal agent for its Kimi models; replaces the earlier open-source Kimi CLI
OpenHandsAn open-source community, started by researchersA platform for coding agents, with a research paper (2024) and many model choices
OpenCode, AiderOpen-source projectsTerminal agents that can use almost any provider, including a model on your own computer
mini-swe-agent, Terminus 2Researchers (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.

Try itWho decides?

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.

Two real examples
Claude CodeCodex CLI
ModesManual (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 macOSSeatbelt, built into macOSSeatbelt
Sandbox on Linuxbubblewrapbubblewrap
NetworkGoes through a proxy outside the sandbox that limits which domains can be reached and asks about new onesApproval 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

Your agent runs in a sandbox that allows writing only inside the project folder. It deletes the project’s test folder by mistake. What saves you?

Show the answer

Answer: Your last git commit, or another backup The sandbox allowed it, because the folder is inside the project. Checkpoints cover the harness’s own file edits, not shell commands. A commit made before the session lets you restore everything.

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.

AGENTS.md for a small projectmarkdown
# 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:

Four ways to extend a harness
What it isHow it uses context
SkillA folder of instructions, and sometimes scripts, for one kind of task, such as making slides or following a review checklistOnly a short description is loaded at the start; the full text loads when the skill is used
HookYour own command that the harness runs at a fixed moment: before a tool runs, after an edit, when the agent stopsUses none, unless the hook sends a message back to the model
MCP serverA 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
SubagentA second agent with its own fresh context window, given one jobIts 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.

.claude/settings.json with two hooksjson
{
  "hooks": {
    "PreToolUse": [{
      "matcher": "Edit|Write",
      "hooks": [{ "type": "command", "command": "python .claude/protect.py" }]
    }],
    "PostToolUse": [{
      "matcher": "Edit|Write",
      "hooks": [{ "type": "command", "command": "ruff format ." }]
    }]
  }
}
  • PreToolUse runs before every edit. The script protect.py checks the file path, and if it is a protected file (say, inside data/raw/) it exits with code 2, which blocks the edit and shows the model why.
  • PostToolUse runs 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

Your agent sometimes forgets to run the formatter after editing. What fixes this most reliably?

Show the answer

Answer: A hook that runs the formatter after every edit A hook runs every time, in code. An instruction is advice the model may forget, especially late in a long session.

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.

One GPT model (2025) on Terminal-Bench 2.0, in four harnesses
  • Codex CLI 49.6 % of tasks
  • OpenHands 41.5 % of tasks
  • Terminus 2 35.2 % of tasks
  • mini-swe-agent 33.9 % of tasks

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

Two teams report very different scores for the same model on the same agent benchmark. What is the most likely reason?

Show the answer

Answer: They ran the model in different harnesses, with different tools, prompts or limits An agent benchmark measures the model and harness together. Different tools, prompts, time limits and numbers of tries can move the score by many points.

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:

  1. Make a folder for the project and run git init. Commit before every session, so any mistake can be undone.
  2. Write a short AGENTS.md: how to run the project, how to run the tests, and what must not be touched.
  3. Start in plan or read-only mode and ask for a plan first. Read it. Correct it if it misunderstands the goal.
  4. Switch to a mode that asks before commands, and let it work. Approve commands you understand; refuse and ask about the rest.
  5. When it finishes, read the changes with git diff and run the tests yourself.
  6. 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?

0 of 8 sorted
  • 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.

Check yourself

5 questions. Tap the answer you think is right.

0 of 5 answered

Which of these is a job of the harness rather than the model?

Show the answer

Answer: Refusing a command that the permission mode does not allow The model reasons and asks; the harness enforces the rules, runs tools and keeps state.

What does a checkpoint let you undo?

Show the answer

Answer: File edits the harness made The harness snapshots files before editing them. Changes that leave your computer, or that shell commands make, are not covered.

What belongs in AGENTS.md?

Show the answer

Answer: Short instructions: how to run and test the project, the style to follow and what not to touch It is loaded into every session, so keep it short and practical. Secrets never belong in it.

Why is a hook more reliable than an instruction for a rule that must always hold?

Show the answer

Answer: The harness runs a hook in code every time, while an instruction depends on the model remembering it Deterministic control: the action happens whether or not the model thinks of it.

On Terminal-Bench 2.0, one model scored 49.6 % in one harness and 33.9 % in another. What should you conclude?

Show the answer

Answer: An agent score belongs to the model and harness together, so always ask which harness was used Tools, prompts and limits differ between harnesses, and a company’s own harness is often tuned for its own models.

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
Previous lesson All lessons

Choose your language