Skip to content

Context engineering vs harness engineering: what changes in an AI agent

Context is what the model reads; the harness is everything that isn't the model. Definitions from Anthropic, OpenAI and LangChain, how an agent uses its harness, the numbers and what breaks without one.

Ramon Gomes 18 min read Level: Intermediate

Also available in: Español, Français, Português

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.

Professional kitchen counter at the start of service, with stainless steel containers full of chopped ingredients, an order ticket clipped to a rail above, a knife and a folded towel; a blurred cook in the background
Context is the counter: the cook only uses what's on it. Too little and an ingredient is missing; too much and the order comes out wrong.

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.

Draft horse standing in a wooden stable, wearing a worn leather harness that fits well; a person with their back turned tightens a buckle, tools hang on the wall and there's hay on the floor
The horse is the same before and after the harness. What changes is whether its strength becomes a journey or damage.

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).

Layered diagram: on the outside, the harness, with loop and tools, permissions and sandbox, hooks and verification, file-based memory and git; inside it, the context, with instructions, history, results and files; at the center, the model, with fixed weights
The model sits at the center and doesn't change. The context is what it reads right now. The harness is everything else, including whatever decides what goes into the context.

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.

One agent turn in six stations on three levels, linked by arrows and a return path: documents build the context; a processor represents the model decision; a padlock and barrier represent permission; an isometric server inside a sandbox runs the tool; a sheet returns to the context tray; a clipboard checks test, lint and typecheck. Cyan identifies context, purple identifies model and green identifies harness. The loop repeats until verification passes or the budget runs out.
Of the six stages, one belongs to the model. The other five are harness, and that's where most mistakes are prevented or caught.
  1. Build the context. Instructions, rules file, history, tool descriptions. If the conversation is close to the limit, compact it first.
  2. The model decides. It answers in text or asks for a tool with arguments.
  3. Check permission. The harness checks whether that tool can run without asking. In Claude Code, a PreToolUse hook 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).
  4. Run the tool, preferably inside a sandbox.
  5. 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.
  6. 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.

Two-column diagram: guides before acting, with a short AGENTS.md as a map, skills loaded when needed and well-described tools and MCP; sensors after acting, with lint and typecheck in a hook, tests and E2E, and review by another model or a human
A guide without a sensor is advice. A sensor without a guide is rework. A good harness has both.

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.md rewritten 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.
Watercolor cartoon: a smiling robot runs wild through an office, knocking over papers, opening drawers and pressing the coffee machine buttons all at once, while a developer in the background holds his head in his hands
An agent without a harness: lots of energy, no fence and nobody checking. The coffee does come out, but so does the contracts drawer.

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

  1. A short instructions file, with the stack, the commands to run and test, and what not to touch. OpenAI replaced a huge AGENTS.md with about 100 lines that point to the docs/ folder: "give Codex a map, not a 1,000-page instruction manual".
  2. A sensor the agent can't skip: lint and typecheck in a hook or in pre-commit.
  3. A lock on anything irreversible: a hook that blocks rm -rf, force push or access to the secrets folder.
  4. File-based memory for long tasks: progress, feature list, decisions. Git is part of the memory.
  5. 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

1. How do context and the harness relate to each other?
Show answer

Answer: The harness contains context engineering: it assembles, trims and isolates the context

One contains the other. Choosing what goes into the window is one of the harness's jobs, maybe the most important one.

2. By the definition that stuck, what is an agent's harness?
Show answer

Answer: Everything that isn't the model: loop, tools, permissions, hooks, memory and verification

Agent equals model plus harness. A framework or an instructions file is only a part of that idea, or a neighbor of it.

3. A rule must never be broken, like deleting the secrets folder. Where should it live?
Show answer

Answer: In a hook that blocks the action before the tool runs

The instructions file is treated as context, not as enforced configuration. To really block something, use a hook.

4. In Böckeler's split, what are guides and sensors?
Show answer

Answer: Guides steer before the agent acts; sensors check after it has acted

AGENTS.md and skills steer beforehand. Lint, tests and review check afterwards. A good harness has both.

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

Source: https://ramongomessilva.com.br/blog/context-engineering-vs-harness-engineering · Accessed on December 02, 2026

Share Share on LinkedIn Share on X
Cite this article

Ready-made reference, with today as the access date.

ABNT

Brazilian standard (NBR 6023). Use it in theses and academic papers submitted in Brazil.

GOMES, Ramon. Context engineering vs harness engineering: what changes in an AI agent. Ramon Gomes, 20 nov. 2026. Disponível em: https://ramongomessilva.com.br/blog/context-engineering-vs-harness-engineering. Acesso em: 2 dez. 2026.

APA

American Psychological Association style. Common in scientific papers and journals, especially in the social, behavioral and health sciences.

Gomes, R. (2026, November 20). Context engineering vs harness engineering: what changes in an AI agent. Ramon Gomes. https://ramongomessilva.com.br/blog/context-engineering-vs-harness-engineering

BibTeX

Format for LaTeX users (Overleaf, for example). Paste it into your .bib file or import it into Zotero or Mendeley.

@online{gomes2026contextengineeringvs,
  author = {Gomes, Ramon},
  title = {{Context engineering vs harness engineering: what changes in an AI agent}},
  organization = {Ramon Gomes},
  year = {2026},
  month = nov,
  date = {2026-11-20},
  url = {https://ramongomessilva.com.br/blog/context-engineering-vs-harness-engineering},
  urldate = {2026-12-02}
}
Found a mistake?

Wrong fact, broken link, outdated information: tell me and I will fix it.

10 to 2,000 characters. If you can, point to the right source.

Only so I can reply. It never shows on any page of the site.

Written by

Ramon Gomes

Software Engineer

Full stack software engineer. I like taking a messy problem, listening to the people who live with it and shipping something that holds up day to day. These days I split my time between my own products, applied AI and client work.

Available for projects

Need Something Like This Built?

I build websites, systems, apps and AI automations, from design to deploy. Tell me what you need or see what I offer.

Related Articles