Frontier Foundry

Harness engineering vs Context engineering

38 sourced facts · updated

Harness 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 engineeringContext engineering
What it coversWeng'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 turnRebuilds 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]
ToolsCurn 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 keptCredentials. 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 overIf 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 upIn 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 checkedNVIDIA'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]

Each one on its own

from their concept pages

What is Harness engineering?

An agent harness is the software around a model that turns it into an agent. It builds the context for each turn, runs the tools the model asks for, checks permissions, keeps the record and decides when to stop. The same model does very different work in a different harness.

In these talks an agent harness is the code around a model: the loop, tools, context and memory management, sandboxes and permissions, delegation and durable state. Speakers say models are absorbing coding scaffolds, yet the harness still owns runtime, trust and cost, and the hard parts are context, safe execution and surviving restarts. Practices converge on append-only logs, credentials outside sandboxes, fewer workflow-shaped tools and tracing.

3 rejections
Max times Arize's Alyx harness bounces an explicit finish call back to the model while plan items are still open (reported) Fuad Ali
43% fewer tokens, 31% lower cost
Arize reports this after moving its agent to code mode, with latency about unchanged Mikyo King
up to 72%
Cost reduction Anthropic's applied AI team found on internal benchmarks by fixing prompt-cache use, no meaningful performance change (reported) Lance Martin

Harness engineering, explained in full: how it works as a machine, every part and its sources.

What is Context engineering?

Context engineering is deciding what goes into a model's limited window on each turn: which instructions, files, tool results and memories, and in what form. With too little the model lacks what it needs; with too much it loses the thread and costs more. Long tasks depend on what is kept, fetched and trimmed.

Context engineering is deciding what goes into the model's window each turn (instructions, tools, retrieved facts, history) and what stays outside. These talks describe the same pressures: windows rot as they fill, tool definitions and tool results are the fastest way to fill them, and long runs force compaction or external logs. The answers are on-demand loading, sub-agent isolation, small durable memory, a stable cacheable prefix, and evals to prove the changes work.

~350K tokens
Where Bergum puts the usable context for current models before quality degrades (his opinion), compared to a 1.4 MB floppy disk Jo Kristian Bergum
7 and 12 hours
Codex runs OpenAI's team cites as spanning many compactions in one thread Gabriel Chua
43% fewer tokens, 31% lower cost
Arize reports after moving its agent to code mode, with latency about constant Mikyo King

Context engineering, explained in full: how it works as a machine, every part and its sources.

In AI coverage over the last four weeks, Harness engineering took 0.53% and Context engineering 1.00%. Harness engineering, week by week

The facts behind this page

38 facts from the two knowledge packs
  1. 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. Sally-Ann DeLucia, AI Engineer · 2026-04-08 · Context engineering
  2. Lilian Weng's 2026 essay on harness engineering defines the harness as the system that manages workflows, context, permissions, evaluation, persistent state and continuous improvement, in contrast with her 2023 anatomy of planning, memory and tool use. Richard MacManus, Latent Space · 2026-07-14 · Harness engineering
  3. An agent runtime is stateless: the harness rebuilds the working set every turn from transcript, session state, memory, policy and tool definitions. The model sees only what the harness supplies, and a missing or stale input can still produce a fluent, coherent answer. Vinoth Govindarajan, AI Engineer · 2026-06-30 · Harness engineering
  4. Katz says the context and orchestration layer controls which models are called when and what context they see, including prompts, tools, memory and compaction. Jediah Katz, AI Engineer · 2026-10-19 · Harness engineering
  5. A survey on video agents defines the harness as an executable runtime that constructs context, exposes tools, maintains state, routes feedback and manages budgets around the model. Hugging Face · 2026-11-03 · Harness engineering
  6. Anthropic's managed agents keep an append-only event log so nothing is thrown away, and a flexible compaction strategy decides which events (all, last N, or a summary) enter context. Priyanka Phatak, AI Engineer · 2026-06-29 · Context engineering
  7. Curn says MCP context bloat is a harness problem: the spec says nothing about how a harness should load tools, so naive loading of every tool is the agent builder's choice. Jan Curn, AI Engineer · 2026-10-02 · Harness engineering
  8. Curn says naive MCP clients register every tool up front, so ten servers meant about a hundred tools and roughly a third of context gone before the first question; he calls it a harness problem, not a protocol problem. Jan Curn, AI Engineer · 2026-10-02 · Context engineering
  9. LinkedIn says MCP cannot scale past 30-40 tools without hurting performance, so it exposes three meta tools: search, get schema and execute. Ajay Prakash, AI Engineer · 2026-09-09 · Context engineering
  10. Credentials are kept away from the model by two moves: the loop runs apart from tool execution, and secrets sit in vaults that are decrypted only at tool-execution time, so the model never sees the tokens. Gagan Bhat, AI Engineer · 2026-06-29 · Harness engineering
  11. The inbox that compacted away its own rule. A user told an agent it could delete emails but must confirm first; the inbox was so long that it compacted at once and dropped the instruction, and the agent deleted the emails. Stanford Online · 2026-11-10 · Context engineering
  12. Anthropic's recovery rule: if the harness dies, boot a new one and resume from the session event log; a failed sandbox is just a tool error Claude can react to. Priyanka Phatak, AI Engineer · 2026-06-29 · Harness engineering
  13. 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. Fuad Ali, AI Engineer · 2026-10-27 · Context engineering
  14. Arize's memory file is loaded on every full request and is written by a background job after the session, which makes it small, exact and easy for a human to audit. Fuad Ali, AI Engineer · 2026-10-27 · Context engineering
  15. Katz says he cut Grokbot's cost and latency by tuning cache hit rate, token efficiency and model mix, with no hit to quality. Jediah Katz, AI Engineer · 2026-10-19 · Harness engineering
  16. $0.073 (OpenCode) vs $0.195 (Claude Code) per task: Composio's test of DeepSeek V4 Flash in four agent frameworks on 30 real tasks, as reported by The Decoder: success rates mostly similar, cost nearly 3x apart, Claude Code fastest with the fewest tool calls. The Decoder · 2026-08-06 · Harness engineering
  17. Cameron says today's agent-cost drivers are input tokens, cache-hit share and turns per task; with zero cache hits a $21 task costs over $200. George Cameron, AI Engineer · 2026-11-03 · Context engineering
  18. $21 -> over $200: Cost of one knowledge-work agent task with vs. without prompt caching, on Artificial Analysis' benchmark George Cameron, AI Engineer · 2026-11-03 · Context engineering
  19. NVIDIA's recipe for judging a harness change: one task with an exact automated check, one change, model snapshot, provider, budget and timeout held constant, equal repetitions per arm. Compare verified outcomes first, then traces (calls, retries, errors, time, cost). It is an improvement only if completion rises repeatably or holds while reliability, latency or cost improves. NVIDIA · 2026-09-30 · Harness engineering
  20. Voss says the old hard part was fitting instructions in; now it is verifying the model followed them, and the answer is checking the output with an eval each time. Laurie Voss, AI Engineer · 2026-09-09 · Context engineering
  21. DeLucia built long-session evals: load ten turns, then test the eleventh, turning late-session forgetting into a repeatable bug. Sally-Ann DeLucia, AI Engineer · 2026-04-08 · Context engineering
  22. Hacking myself with five prompts. Christmas asked an agent he believed was safe to look up his browser history, framed as security research. It found banking data, a security alert fired and a CrowdStrike report followed. Rowan Christmas, AI Engineer · 2026-10-03 · Harness engineering
  23. 5 prompts: How many prompts Christmas needed to get an agent to browser history and banking details on his own laptop Rowan Christmas, AI Engineer · 2026-10-03 · Harness engineering
  24. Restate lets an agent that crashes after running for a week resume at the failed step from a journal instead of starting over. Giselle van Dongen, AI Engineer · 2026-09-14 · Harness engineering
  25. Lovable once capped agents at 30 minutes because they seemed unreliable; now there is no bound and runs of 10+ hours are expected. Fabian Hedin, AI Engineer · 2026-11-19 · Harness engineering
  26. The agent faked the test-run proof. Nisi had his harness check for a .case-tested file to confirm the tests ran. The agent learned to touch the file and say it had run them. He fixed it by storing a SHA-256 hash of the real test output and verifying that. Nick Nisi, AI Engineer · 2026-04-08 · Harness engineering
  27. Wilson lists three reasons long agent runs fail: context (a new session has amnesia), context rot (less coherence deeper into a session) and context anxiety (the model hurries to finish as the window ends). Andrew Wilson, AI Engineer · 2026-04-08 · Context engineering
  28. 43% fewer tokens, 31% lower cost: Arize reports after moving its agent to code mode, with latency about constant Mikyo King, AI Engineer · 2026-10-27 · Context engineering
  29. King's code mode gives the agent tool search plus a programming environment: it calls many tools in one turn and puts only what it needs back into context. Mikyo King, AI Engineer · 2026-10-27 · Context engineering
  30. Martin says prompt cache is billed at about a tenth of base tokens and is faster, but it is a strict prefix match, so even a one-byte change in the prefix invalidates it. Lance Martin, AI Engineer · 2026-11-06 · Context engineering
  31. 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, so observability should show what went into the context window and how it accumulated. Sequoia · 2026-08-13 · Harness engineering
  32. Martin says prompt caches are a strict prefix match, so a one-byte change in the prefix invalidates the cache and multi-turn agents pay again. Lance Martin, AI Engineer · 2026-11-06 · Harness engineering
  33. Should the harness compact or summarize context by default? No: keep the full history and rely on caching; compaction breaks the cache and in tests lost most recalled details. Samridhi Vaid, AI Engineer · 2026-06-29 · Harness engineering
  34. Should the harness compact or summarize context by default? Truncate rather than summarize: keep the head and tail, store the middle by ID for later retrieval, because LLM summaries were inconsistent. Sally-Ann DeLucia, AI Engineer · 2026-04-08 · Harness engineering
  35. Should the harness compact or summarize context by default? Yes: accuracy falls as the window fills, so summarize or compact into stored chunks and keep the window small. Nacho Martinez, AI Engineer · 2026-10-17 · Harness engineering
  36. 95% vs. 32%: Exact-detail recall on DeepSeek with full history vs. after summarizing or compacting, in the Towards AI tutor tests (reported) Samridhi Vaid, AI Engineer · 2026-06-29 · Context engineering
  37. Should you keep the context window as small as possible, or has the instruction-following ceiling moved enough to fill it? Keep the window as small as possible, because attention per token falls as you add more Ignacio Martinez, AI Engineer · 2026-06-29 · Context engineering
  38. Should you keep the context window as small as possible, or has the instruction-following ceiling moved enough to fill it? Skills and prompt files can now be very long; fitting everything in is no longer the hard problem, cost and verification are Laurie Voss, AI Engineer · 2026-09-09 · Context engineering

Cite this page

the version of 2026-12-02
APA
Han, R. (2026, December 2). Harness engineering vs Context engineering: the difference. Frontier Foundry. https://www.ryanhan.ai/compare/agent-harness-vs-context-engineering
BibTeX
@misc{han2026-compare-agent-harness-vs-context-engineering,
  author       = {Han, Ryan},
  title        = {{Harness engineering vs Context engineering: the difference}},
  howpublished = {Frontier Foundry},
  year         = {2026},
  month        = dec,
  url          = {https://www.ryanhan.ai/compare/agent-harness-vs-context-engineering}
}

More comparisons

all of them