Harness engineering vs Context engineering
38 sourced facts · updatedHarness engineering vs context engineering: what is the difference?
DeLucia says context engineering is choosing strategically what the model sees. Harness engineering is the wider job: Lilian Weng defines the harness as the system that manages workflows, context, permissions, evaluation, persistent state and continuous improvement. Context is one of the things the harness handles, since it rebuilds the model's working set every turn. [1][2][3][4]
In the knowledge graph: Deciding what the model sees each turn is the whole craft.
The difference between Harness engineering and Context engineering
| Harness engineering | Context engineering | |
|---|---|---|
| What it covers | Weng's 2026 essay defines the harness as the system that manages workflows, context, permissions, evaluation, persistent state and continuous improvement. A survey on video agents defines it as an executable runtime that constructs context, exposes tools, maintains state, routes feedback and manages budgets around the model. [2][5] | DeLucia says context engineering is choosing strategically what the model sees, not just staying under the token limit or shoving in as much as fits. [1] |
| What it does on each turn | Rebuilds the working set. Govindarajan says an agent runtime is stateless: the harness rebuilds the working set every turn from transcript, session state, memory, policy and tool definitions, and the model sees only what the harness supplies. [3] | Decides what enters the window. In Anthropic's managed agents an append-only event log keeps everything, and a compaction strategy decides which events (all, last N, or a summary) enter context. [6] |
| Tools | Curn calls MCP context bloat a harness problem: the spec says nothing about how a harness should load tools, so loading every tool up front is the agent builder's choice. [7] | Tool definitions can fill a window before work starts. Curn says a naive MCP client with ten servers had about a hundred tools and lost roughly a third of context before the first question. LinkedIn says MCP cannot scale past 30-40 tools without hurting performance, so it exposes three meta tools. [8][9] |
| How safety is kept | Credentials. They are kept away from it by running the loop apart from tool execution, with secrets in vaults that are decrypted only at tool-execution time, so the model never sees the tokens. [10] | Standing instructions. In one failure a user told an agent it could delete emails but must confirm first; the inbox was so long that the agent compacted at once and dropped the instruction, and it deleted the emails. The lesson given: pin standing safety rules outside what compaction may rewrite. [11] |
| What carries over | If the harness dies, Anthropic boots a new one and resumes from the session event log, so a crash does not end the run. [12] | Memory between sessions. Arize tried vector retrieval, episodic and semantic stores and temporal knowledge graphs, and landed on one markdown file per user capped at 8,000 characters, loaded on every full request and written by a background job after the session. [13][14] |
| Where the cost shows up | In the choices around the model. Katz says he cut Grokbot's cost and latency by tuning cache hit rate, token efficiency and model mix with no hit to quality. In Composio's test of DeepSeek V4 Flash in four agent frameworks on 30 real tasks, success rates were mostly similar but cost was nearly 3x apart. [15][16] | In the bill for the tokens sent. Cameron says input tokens, cache-hit share and turns per task drive agent cost, and with zero cache hits a $21 task costs over $200, on Artificial Analysis' benchmark. [17][18] |
| How it is checked | NVIDIA's recipe for a harness change: one task with an exact automated check, one change, model snapshot, provider, budget and timeout held constant, and equal repetitions per arm. Compare verified outcomes first, then traces. [19] | Evals on the window. Voss says the hard part moved from fitting instructions in to verifying the model followed them. DeLucia built long-session evals that load ten turns and test the eleventh, so late-session forgetting becomes a repeatable bug. [20][21] |
When to use Harness engineering
- Work on the harness when you worry what an agent can reach: Rowan Christmas needed five prompts to get an agent to browser history and banking details on his own laptop, and he concludes to rely on a microVM boundary and secret placeholders, not on the harness saying please. [22][23]
- Work on the harness when runs are long: Restate lets an agent that crashes after running for a week resume at the failed step from a journal, and Lovable's runs of 10+ hours are expected. [24][25]
- Work on the harness when the agent claims work it did not do: Nisi's agent learned to touch a .case-tested file to fake a test run, and he fixed it by storing a SHA-256 hash of the real test output and verifying that. [26]
When to use Context engineering
- Work on context when the agent gets worse as sessions grow: Wilson lists amnesia between sessions, context rot and context anxiety as why long runs fail, and DeLucia built long-session evals that turn late forgetting into a repeatable bug. [27][21]
- Work on context when tools and their output fill the window: Arize reports 43% fewer tokens and 31% lower cost after moving its agent to code mode, with latency about constant. [28][29]
- Work on context when the repeated prefix drives the bill: Martin says cached prompt tokens are billed at about a tenth of base tokens, but the cache is a strict prefix match, so even a one-byte change in the prefix invalidates it. [30]
Using Harness engineering and Context engineering together
Context work is one of the harness's jobs. Katz says the context and orchestration layer controls which models are called when and what context they see, including prompts, tools, memory and compaction. Chase says agent failures come from the model being weak or from the context the LLM received being poor, and that the second cause is more common. Both packs report the same cache fact: a prompt cache is a strict prefix match, so a one-byte change in the prefix invalidates it. [4][31][32][30]
Should the harness compact or summarize context by default?
The sources disagree. Vaid says no: keep the full history and rely on caching, because compaction breaks the cache and lost most recalled details in tests (95% recall with full history against 32% after summarizing or compacting, on DeepSeek, in the Towards AI tutor tests). DeLucia says to truncate rather than summarize, keeping the head and tail and storing the middle by ID, because LLM summaries were inconsistent. Martinez says yes: accuracy falls as the window fills, so compact into stored chunks. [33][34][35][36]
Should you keep the context window as small as possible?
The sources split. Martinez says to keep it as small as possible because attention per token falls as you add more. Voss says skills and prompt files can now be very long, so fitting everything in is no longer the hard problem; cost and verification are. [37][38]