Context engineering is deciding what an AI model sees when it answers: instructions, message history, tools, retrieved documents and memory. LangChain's documentation defines it as providing the right information and tools in the right format so the model can finish a task. The context is an artefact you can test, review and version.
What is context engineering?
LangChain’s documentation on context engineering defines it as “providing the right information and tools in the right format so the LLM can accomplish a task”. In plain terms: you decide what the model sees, because the model answers from what it is given.
That includes more than the instruction. LangChain splits it into model context (instructions, message history, tools and response format), tool context (what tools can read and write) and life-cycle context (what happens between calls, such as summarizing a long history). The decision it helps with is where to spend effort when an AI feature gives wrong answers: on a better model, or on what the model is handed.
How is it different from prompt engineering?
Prompt engineering tunes the wording of an instruction. Context engineering is wider: the instruction is one input among several, and the others can change between calls. A perfect prompt cannot make up for a missing document, a stale instruction file or a tool result that came back empty.
It also overlaps with two checks we cover elsewhere. Scoring whether retrieved documents were right is RAG evaluation, and checking that an answer stays inside its sources is groundedness. Context engineering is the step before both: choosing what goes in.
What sources make up the context, and what fails in each?
| Context source | What fails when it is wrong or stale | The check that catches it |
|---|---|---|
| System instructions | The agent follows an old rule or two rules that conflict | Review the file on every change; run a fixed set of cases after it |
| Repository rules file | A coding agent uses the wrong build command or house style | A change to the file goes through code review |
| Retrieved documents | The answer cites a page that is out of date | A groundedness and retrieval score on a labelled set |
| Tool results | An empty or truncated result is treated as “no data” | Cases where each tool returns an error, nothing or too much |
| Conversation history | Early details are lost or contradicted late in a long session | A long-session case that checks an early fact |
| Memory | An old preference or correction is applied where it no longer fits | Review what memory holds; clear it between test runs |
Instructions, tools, message history and memory are named in the LangChain and Claude Code documentation; retrieved documents are our addition. The failure and check columns are our reading, not those vendors’ statements.
When output is wrong, is it the model, the prompt or the context?
LangChain says LLMs fail for one of two reasons, either the model is not capable enough or the “right” context was not passed, and that “more often than not” the second is what makes agents unreliable. That is a vendor’s claim, not a measured rate. Our rule of thumb for a single bad answer:
- Log exactly what the model received for that case.
- Ask whether a person given only that input could answer correctly.
- If not, add the missing fact and rerun. A correct answer now means a context fault.
- If the answer is still wrong with complete context, look at the prompt, then at the model.
This tells you whether to spend on prompt work, retrieval work or a model change. Our AI QA adoption service covers tool choice, a measured pilot, written working rules and training.
Who should own the context files your coding and testing agents read?
Give each file one named owner and review changes like code. Anthropic’s documentation says Claude “treats CLAUDE.md files and auto memory as context” and that they “aren’t enforced configuration”, so a rule written there is a request, not a guarantee. The same page describes a prompt audit that looks for outdated instructions, references to files that do not exist, and files that contradict each other.
Formats differ across tools. AGENTS.md describes itself as “a README for agents”. GitHub’s documentation on repository instructions says that when Copilot is working, the nearest AGENTS.md file in the directory tree takes precedence. Our judgment: if two files can disagree, someone must own the tie-break, and a test should show which one the agent followed. The agentic test case standard we published shows one way to write such cases. For agents that write or change code, read the AI code review checklist next, and for agents in general, how to test AI agents. Where a model grades another model’s output, see LLM-as-a-judge.
What does context engineering not solve?
Better context raises the odds of a right answer; it does not check the answer. Output still needs tests, review and an evaluation set. More context is also not better by default: Anthropic’s context windows documentation says that as token count grows “accuracy and recall degrade”, a phenomenon it calls context rot. A fuller window can make results worse. In our view context also drifts, because files and documents change, so a check that passed last month proves little today.
What does Zapple.Tech do about it?
If you are not sure what your AI features are given when they answer, start with the evidence. Zapple.Tech starts with a one-week QA audit of one product area. It looks at its tests, pipeline and release process, and ends in a written report on what is at risk and what to fix first, plus a pilot plan you can run with Zapple.Tech or without it. Read more on the QA audit and assessment page.
Tell us about your AI feature in the form below.
How does context engineering relate to other terms?
- RAG evaluation
RAG evaluation measures a retrieval-augmented generation system in two parts: whether the search step returned the right passages, and whether the answer built from them is supported and useful. Scoring the two separately tells you which one to fix. You need a labelled question set before any score means something.
- Groundedness
Groundedness tells you whether an AI answer is supported by the source material the model was given, such as retrieved documents or a tool result. A grounded answer adds nothing the sources do not say. It does not tell you whether the sources are right, so you still need a check on correctness.
- LLM evaluation
LLM evaluation is the practice of measuring how a language-model feature or agent behaves on a defined set of tasks, using written success criteria and scores. It does not by itself show the feature is correct. Our AI agent testing builds a task set, a measured baseline and a suite that scores each model, prompt or tool change.
- Model Context Protocol
The Model Context Protocol (MCP) is an open standard for connecting AI applications to external tools and data. An AI application, the host, opens one client connection per MCP server, and each server offers tools, resources or prompts. MCP standardizes the connection, not what the agent does with it, so every server still needs its own tests.
- Spec-driven development
Spec-driven development is a way of building software in which a written specification, not the code, is the main artifact. You write the spec first, then an AI coding tool generates a plan, code and tests from it. In our view the spec needs a reviewer, and the code needs tests that do not come from the same spec.
Sources
- LangChain documentation, Context engineering in agents (current docs) (read 5 December 2026)
- Anthropic documentation, Context windows (current docs) (read 5 December 2026)
- Claude Code documentation, How Claude remembers your project (current docs) (read 5 December 2026)
- AGENTS.md, a README for agents (current site) (read 5 December 2026)
- GitHub Docs, Adding repository custom instructions for GitHub Copilot (current docs) (read 6 December 2026)