In 2025, "context engineering" replaced "prompt engineering" in conversations about agents. In 2026 another word showed up, "harness", and a lot of people started using the two as if they meant the same thing. They don't, and the difference decides where you make changes when the agent gets something wrong.
I work with two coding agents on the same server every day, and almost everything that improved in that workflow was harness: an instructions file, a briefing, a hook that blocks dangerous commands, a queue so the CPU doesn't fall over. Switching models changed less. This article separates the two concepts, shows what each serious source says about them and what happens when one is missing.
What Context Is
Context is the window the model sees in a call. It holds the system prompt, the messages, the tool descriptions, what the tools returned and any file or snippet someone pasted in. The model has no other source: if it isn't in the window, as far as the model is concerned, it doesn't exist.

Context engineering is deciding what goes into that window at every step. The oldest use of the term I found is from Walden Yan, at Cognition, in June 2025: the next level after the prompt, "doing this automatically in a dynamic system" (Cognition, 2025). A few days later, Tobi Lütke, from Shopify, and Andrej Karpathy backed the name. Karpathy called it "the delicate art and science of filling the context windowMaximum amount of text, measured in tokens, that a language model can take into account at once, counting both input and output. with just the right information for the next step" (Simon Willison, 2025).
Anthropic gave the most operational definition: "the set of strategies for curating and maintaining the optimal set of tokens" (Anthropic, 2025). And it explained why this matters. As context grows, the model's ability to "accurately recall information from that context decreases". That's what's called context rot. Chroma tested 18 models and saw performance vary a lot with input length, "even on simple tasks" (Chroma, 2025). A big window isn't a well-used window; I also covered this in the article on RAG and CAG.
LangChain organized the techniques into four verbs (LangChain, 2025):
| Verb | What it does | Example |
|---|---|---|
| Write | stores it outside the window | notes in a file, a task list |
| Select | brings it in only when needed | search, a skill loaded on demand |
| Compress | summarizes or trims | compaction near the limit |
| Isolate | splits it into another window | a subagent that returns only the summary |
What a Harness Is
A harness, in its original sense, is the set of straps that connects a horse's strength to the cart and lets you steer it where you want. In the world of agents, it's the same idea. The model has the strength; the harness turns that strength into useful, safe work.

The most widely accepted definition came from LangChain: a harness is "every piece of code, configuration, and execution logic that isn't the model itself", or, in one sentence, "If you're not the model, you're the harness" (LangChain, 2026). Birgitta Böckeler, from Thoughtworks, used the same yardstick on Martin Fowler's site: agent = model + harness, and the harness is everything "except the model itself" (martinfowler.com, 2026).
Phil Schmid proposed a helpful analogy: the model is the CPU, the context window is the RAM, the harness is the operating system and the agent is the application (Phil Schmid, 2026).
The term took off in February 2026. OpenAI published "Harness engineering", describing how a team of 3 to 7 engineers shipped about 1 million lines and about 1,500 PRs in 5 months without writing code by hand, using Codex (OpenAI, 2026). The same week, Mitchell Hashimoto described the "Engineer the Harness" stage of his own adoption: every agent mistake becomes a rule or a script, "such that the agent never makes that mistake again" (Mitchell Hashimoto, 2026).
Harness, Framework and Runtime Aren't the Same Thing
Harrison Chase, from LangChain, separated three words that used to be mixed up (LangChain, 2025):
- Framework: abstractions for building the agent. LangChain, OpenAI Agents SDK, Google ADK, Vercel AI SDK.
- Runtime: the durable execution underneath, with persistence, streaming and pauses for a human. LangGraph is the example.
- Harness: the "batteries-included" layer, with tools, prompts and context management already in place. Claude Agent SDK and Deep Agents.
Chase himself admits the boundaries aren't sharp. Anthropic, for example, renamed the Claude Code SDK to Claude Agent SDK because the harness "that powers Claude Code" was useful for other agents (Anthropic, 2025).
How the Agent Uses the Harness, Step by Step
An agent is, in Simon Willison's short definition, an LLMAI model trained on large amounts of text to predict the next word, which lets it chat, summarize, translate and write code. that "runs tools in a loop to achieve a goal" (2025). The loop belongs to the harness. On each pass, the model only decides the next step; everything else happens around it.
- Build the context. Instructions, rules file, history, tool descriptions. If the conversation is close to the limit, compact it first.
- The model decides. It answers in text or asks for a tool with arguments.
- Check permission. The harness checks whether that tool can run without asking. In Claude Code, a
PreToolUsehook can block the action; the documentation says CLAUDE.md is treated "as context, not enforced configuration" and that, to actually block something, the way to do it is the hook (Claude Code). - Run the tool, preferably inside a sandbox.
- The result goes back into the context. Huge output goes to a file and only the beginning and the end make it into the window.
- Verify. Tests, lint, typecheck. If something fails, the error becomes context for the next pass.
Böckeler names the two halves that surround the action: guides (feedforward), which steer before, and sensors (feedback), which check after. And she separates what is computational, deterministic, from what is inferential, like one LLM judging another.
Where Context and Harness Meet
The short answer: context engineering is one of the things the harness does, probably the most important one. Böckeler calls the harness the user puts together "a specific form of context engineering". LangChain says harnesses are "largely delivery mechanisms for good context engineering".
The most detailed account comes from Manus, which rewrote its own framework four times (Manus, 2025). Some of their decisions are context and harness at the same time:
- Cache hit rate as "the single most important metric for a production-stage AI agentProgram that uses a language model to choose actions, call tools and repeat the loop until a task is done, with little human input.". Input is about 100 times larger than output, and cached tokens cost 10 times less on the model they were using.
- Don't remove tools mid-task, only mask them, so the cache doesn't break.
- The file system as memory, with compression that can be undone: keep the path, not the content.
- A
todo.mdrewritten at every step, to keep the goal at the end of the window in a task of about 50 tool calls. - Keep errors in the context, so the model doesn't repeat the same attempt.
Anthropic uses the same logic for agents that work for hours: an initializer agent creates an init.sh, a progress file and a feature list in JSON, all with "passes": false; after that, each session moves one feature forward and leaves the repository clean for the next one (Anthropic, 2025). They chose JSON because the model changes that format less than Markdown. It's the harness taking care of context between windows that can't see each other.
Same Model, Different Harness
If the harness matters that much, it should show up in the numbers. And it does.
- Terminal-Bench 2.0. LangChain fixed the model (gpt-5.2-codex) and changed only the harness: a self-verification checklist before finishing, a directory map at the start, loop detection and a variable reasoning budget. The agent went from 52.8% to 66.5%, from outside the top 30 to the top 5 (LangChain, 2026).
- SWE-bench Verified. Anthropic reached 49% with a minimal harness, with only the bash and edit tools, and wrote that the result "can vary significantly based on this scaffolding" (Anthropic, 2025).
- ICML 2026. A workshop paper on Terminal-Bench concluded that "the gains from simply picking the best harness are comparable to those from picking the best LLM" (Han and Sun, 2026).
One caveat: even hardware moves the score. Anthropic measured a 6-point difference on Terminal-Bench 2.0 just by varying CPU and memory, with the same model and the same harness (Anthropic, 2026). A fair comparison fixes the environment.
In my own workflow the effect is similar, on a smaller scale. I measured 71 briefings I send to Codex: with a "pattern to follow" field pointing to a reference file, the median was 50,022 tokens; without it, 77,612. On a front-end task that didn't say where to look, the agent read 211 of the repository's 247 files. In a client repository with 1,041 files, a well-written AGENTS.md made an architecture question cost 5,250 tokens, against an average of 43,016. The model was the same; what changed was what the harness handed it. I described the whole workflow in AI agents on the front end.
An Agent Without a Harness: What Goes Wrong
A chatbotProgram that talks by text or voice, replying to messages from a script or a language model. It answers, but usually does not act outside the chat. with a raw APIContract that defines how one program asks another for data or actions: which endpoints to call, what to send and what comes back. On the web, usually HTTP with JSON. call has no harness: it doesn't act, doesn't check and forgets everything when the session ends. For conversation, that's fine. For multi-step work, the failures Anthropic listed for long-running agents show up:
- trying to do everything at once and running out of context halfway through;
- declaring the project done too early ("declares victory on the entire project too early");
- marking a feature as complete without testing it end to end;
- spending every new session figuring out how to run the project.

The clearest historical data point comes from SWE-bench. In the original 2023 paper, the best model at the time resolved "a mere 1.96%" of the issues in a non-interactive setting (Jimenez et al., 2023). Months later, SWE-agent, with an interface built for the agent to use the computer, reached 12.5% (Yang et al., 2024). The models were different, so it isn't a pure comparison, but the direction is the same as everything else.
The Harness Ecosystem
| Piece | What it is | Context or harness? |
|---|---|---|
AGENTS.md |
"a README for agents", in more than 60 thousand projects, maintained by the Linux Foundation's Agentic AI Foundation (agents.md) | a guide that goes into the context |
CLAUDE.md |
Claude Code's equivalent, loaded at the start of the session | a guide that goes into the context |
| Skills | folders with instructions and scripts the agent loads when needed; an open standard since December 2025 (Anthropic) | context selection done by the harness |
| MCP | a protocol for plugging tools and data into the agent | harness tools |
| Hooks | commands that run at fixed points, such as before every tool | harness sensor and guardrail |
| Subagents | another clean window that returns a summary | context isolation |
| Sandbox | file and network isolation | harness security |
The difference between agents and skills, and where MCPOpen protocol that standardizes how AI apps connect to external tools and data: a server exposes actions and the agent discovers and calls them. and hooks fit in, is covered in detail in agents or skills. If the question is whether to plug in a tool via MCP or via API, see MCP or API.
How to Build a Minimal Harness
- A short instructions file, with the stack, the commands to run and test, and what not to touch. OpenAI replaced a huge
AGENTS.mdwith about 100 lines that point to thedocs/folder: "give Codex a map, not a 1,000-page instruction manual". - A sensor the agent can't skip: lint and typecheck in a hook or in pre-commit.
- A lock on anything irreversible: a hook that blocks
rm -rf, force push or access to the secrets folder. - File-based memory for long tasks: progress, feature list, decisions. Git is part of the memory.
- Every repeated mistake becomes a rule, as in Hashimoto's "Engineer the Harness". Every line in the instructions file comes from a bad behavior.
Böckeler made the criticism of the OpenAI post that stuck with me most: "What I am missing in the write-up is verification of functionality and behaviour." A harness without verification is just an agent that's faster at getting things wrong.
Tools to Try
- MCP documentation, to understand how tools get into the harness.
- Chrome DevTools MCP, a real sensor for a front-end agent: it opens the page and checks.
- Jules, Google's coding agent that runs in a VM, good for seeing a ready-made harness from the outside.
- Ollama, to test the same harness with open models and see how much of the result comes from the model.
To see where context and harness fit among the different specialties, read the types of AI engineering.
Quick check
Frequently Asked Questions
What's the difference between context engineering and harness engineering?
Context engineering decides what the model reads at every step. Harness engineering takes care of everything around the model: loop, tools, permissions, verification and memory. The harness is what carries out context engineering, so the latter sits inside the former.
What is an agent harness?
It's all the code, configuration and execution logic that isn't the model. It includes the loop that calls the model, the tools, the sandbox, the hooks, context compaction and the memory files. Claude Code, Codex CLI and Deep Agents are ready-made harnesses.
Did context engineering replace prompt engineering?
It expanded it. The prompt still exists, but it became one part of the context, alongside the history, tool results and documents. Anthropic calls context engineering the "natural progression of prompt engineering".
Is a harness the same thing as a framework?
Not exactly. A framework gives you abstractions for building the agent; a harness comes with tools, prompts and context management already in place. In Harrison Chase's split, LangChain is a framework, LangGraph is a runtime and Claude Agent SDK is a harness.
Should I switch models or improve the harness?
Measure both. There's research showing that picking the best harness yields gains comparable to picking the best model, and LangChain gained 13.7 points from the harness alone. Improving the harness is usually cheaper and carries over to the next model too.
Are AGENTS.md and CLAUDE.md harness or context?
They're harness guides that go into the context. That's why they need to be short: everything in them takes up space on every call. A rule that must not be broken shouldn't depend on them alone; make it a hook or a test.
Do I need a harness for a simple chatbot?
For questions and answers, little beyond the prompt and the history. As soon as the bot starts acting, like opening a ticket, touching files or running code, you need permissions, verification and logging, and that's harness.
How do I know if my harness is any good?
With evals: a set of real tasks where you know what success looks like. Anthropic suggests starting with 20 to 50 tasks drawn from real failures and running them again after every change to the harness.
References
- Anthropic, Effective context engineering for AI agents, 2025.
- Anthropic, Effective harnesses for long-running agents, 2025.
- Anthropic, Building agents with the Claude Agent SDK, 2025, and Raising the bar on SWE-bench Verified, 2025.
- Anthropic, Quantifying infrastructure noise, 2026, and Demystifying evals for AI agents, 2026.
- OpenAI, Harness engineering: leveraging Codex in an agent-first world, 2026.
- Birgitta Böckeler, Harness engineering for coding agent users, martinfowler.com, 2026, and first thoughts, 2026.
- LangChain, Context Engineering for Agents, 2025; Agent Frameworks, Runtimes, and Harnesses, 2025; The Anatomy of an Agent Harness, 2026; Improving Deep Agents with harness engineering, 2026.
- Manus, Context Engineering for AI Agents: Lessons from Building Manus, 2025.
- Cognition, Don't Build Multi-Agents, 2025.
- Simon Willison, Context engineering, 2025.
- Phil Schmid, The importance of Agent Harness in 2026, 2026.
- Mitchell Hashimoto, My AI Adoption Journey, 2026.
- Chroma, Context Rot, 2025.
- Han and Sun, How good is your harness?, ICML 2026 workshop.
- Carlos E. Jimenez et al., SWE-bench, 2023, and John Yang et al., SWE-agent, 2024.
- Book: Chip Huyen, AI Engineering: Building Applications with Foundation Models, O'Reilly, 2025. Chapter 6, "RAGTechnique that retrieves relevant passages from a document base and hands them to the model with the question, so it answers from sources, not memory alone. and Agents", covers the agent loop, tools and failure modes.