harness-and-context-engineering
Harness & Context Engineering
Prompt engineering optimizes the string you send the model. Harness and context engineering optimize everything else: the loop that decides when to call the model, the tools it can reach, what gets retrieved and assembled into the window, what gets remembered across turns, how failures retry, and what budgets cap it. In production agent systems the harness — not the prompt — is the dominant lever on reliability. A perfect prompt inside a loop with no retry, no tool error-handling, no token budget, and a stale context will fail; a mediocre prompt inside a disciplined harness ships.
The mental model that organizes this whole skill: the context window is the model's working memory, and it is a managed budget, not a bucket you fill. Every token you spend on a tool definition is a token you can't spend on retrieved evidence or conversation history. Context engineering is the discipline of allocating that scarce budget — assembling, ordering, compacting, and evicting — so the right tokens are present at the right position for each model call. This skill is the playbook for both the harness around the model and the context inside it.
Modern sources to anchor on: Anthropic's Building effective agents (2024) and Effective context engineering for AI agents (2025); the "lost in the middle" finding (Liu et al., TACL 2024); Chroma's Context Rot report (2025); the ReAct loop (Yao et al., 2022); and the prompt-caching mechanics from the major providers (cross-reference the prompt-caching skill for the cache-specific depth).
1. Harness engineering vs prompt engineering
| Prompt engineering | Harness engineering | |
|---|---|---|
| Unit of work | The text in one request | The code around every request |
| Optimizes | Phrasing, examples, format, role | Loop, tools, retries, budgets, memory, routing |
| Failure it fixes | "model misunderstood the instruction" | "model called a broken tool and the loop hung" |
| Tested by | eval on prompt variants | integration tests on the control loop + failure injection |
| Owns reliability | a little | most of it |