Agent harness (harness engineering)
Everything around the model that makes it an agent: the loop, tools, permissions, instructions, saved state, checks and session handoff.
The harness is the system the model runs inside: the agentic loop, the tools it can call, what needs approval, how files are read and when context is compacted. Claude Code, Codex and Cursor are harnesses, and the same model behaves very differently in each. Harness engineering is the practice of designing that environment so a coding agent finishes real tasks in a real repository, across many sessions. It does not make the model smarter; it makes its output dependable.
The open course Learn Harness Engineering splits a harness into five parts. Instructions: an AGENTS.md that says what to read first and points to deeper files, instead of one giant file. State: progress and a feature list kept on disk in the repository, so the next session can resume; what the agent cannot see in the repo does not exist for it. Verification: tests, lint, type checks and an end-to-end run as proof before the agent may call a task done, because agents declare victory too early. Scope: one feature at a time, with no editing the feature list to hide gaps. Session lifecycle: an init script at the start, and at the end a clean, committed state with a note for the next session. Hooks and a sandbox turn the most important rules into hard limits rather than requests.
Larger setups wrap this in loops and graphs of agents that plan, build and check each other’s work. The term spread through write-ups by OpenAI, Anthropic and Martin Fowler’s site. When an agent fails, the harness is often the fix, not the model.
Sources
- GitHub: walkinglabs/learn-harness-engineering github.com
- OpenAI: Harness engineering: leveraging Codex in an agent-first world openai.com
- Anthropic: Effective harnesses for long-running agents anthropic.com
- Martin Fowler: Harness engineering for coding agent users martinfowler.com
Related terms
- Agentic loop: The cycle of model call, tool call and result that an agent repeats until it stops.
- Hooks: Scripts the harness runs automatically at fixed points, such as before a tool call or after an edit.
- Context engineering: Deciding what goes into the model’s context, in what order and when, across a whole task.
- Ralph loop (Ralph Wiggum technique): Running the same prompt against a coding agent again and again, each time with a fresh context, while progress lives in files and tests decide when it is done.
- AGENTS.md and CLAUDE.md: Files in a repository with the rules a coding agent reads at the start of every session.
- Agent graph (state graph): Modeling an agent as explicit nodes, edges and shared state, with checkpoints, so each step can be paused, resumed, inspected and tested.
- Compaction: Replacing the older part of a long conversation with a summary so the agent can keep going.
- Agent sandbox: An isolated environment where an AI agent runs code and commands without access to your network, secrets or real files.
- Trajectory evals: Tests that grade an agent’s whole path to an answer: which tools it called, in what order, how many steps and at what cost, not only the final output.
- Validation loop (agent backpressure): Commands a coding agent runs after every change (tests, types, lint, build) and fixes against until they pass, so it checks itself before a person looks.
- Agent-ready codebase: A repository a coding agent can work in reliably: one fast command to check everything, types, clear module borders, examples to copy and written rules.
- Agent permission modes (YOLO mode): Settings that decide what a coding agent may do without asking, from approving every command to skipping all checks, known as YOLO mode.
