
Context engineering is deciding what an AI model sees at each step of a task. That means choosing which instructions, records, tools and history go into the model's context window, the text it reads on that step. It also means choosing their form, and what stays out. Give an agent too much, the wrong version of a policy or a database schema it cannot make sense of, and it gives wrong answers. A stronger model reading the same context makes the same mistakes. An enterprise context layer makes those decisions once, for every agent that reads your data.
Researchers have now measured this. Chroma tested 18 models in July 2025, including GPT-4.1, Claude 4 and Gemini 2.5, and found that their performance grows increasingly unreliable as the input gets longer. A Microsoft and Salesforce team ran more than 200,000 simulated conversations. The same tasks scored 39% lower on average when the information arrived over several messages instead of one. Models make early assumptions and, in the authors' words, get lost and do not recover. Enterprise agents work in exactly those conditions: long tasks, many systems, and data that changes between steps.
Anthropic's engineering team defined it in September 2025 as the set of strategies for curating and maintaining the optimal set of tokens during inference. Tokens are the small pieces of text a model reads, and inference is the moment it runs. The prompt is one part of that set. The rest is everything else the model reads on a given step: tool definitions, retrieved documents, records from your systems, the conversation so far and any notes the agent wrote to itself.
Anthropic describes a model as having a limited attention budget, and every token uses some of it. So the goal is the smallest set of useful tokens that gets the step right. For an enterprise agent, that means a decision for every source. You decide which systems the agent may read and how a record is translated before the model sees it. You also decide when it is fetched, how long it stays, and who may see it.
Prompt engineering is about how the instructions are written. Context engineering is about what the model receives alongside them, and it is repeated on every step of an agent's run rather than written once.
| Aspect | Prompt engineering | Context engineering |
|---|---|---|
| Works on | The wording of instructions | Everything in the context window on each step |
| Done | Once, when the prompt is written | On every step, as the agent runs |
| Data | Pasted in or described | Fetched, filtered and formatted while the agent runs |
| Fails as | A misread instruction | Stale, conflicting or excess material in the window |
| Owned by | Whoever writes the prompt | The team that owns the data and the pipeline |
Good prompts still matter. But a precise instruction cannot rescue an agent that is reading last year's policy, and on enterprise data that failure is the more common one.
In June 2025 Drew Breunig gave the four failure modes names that have stuck: poisoning, distraction, confusion and clash. Each has a documented case. Google's Gemini 2.5 technical report describes an agent playing Pokémon whose goals and summaries were poisoned with wrong information about the game. It spent many hours chasing a goal it could not complete. The 39% drop over several messages, described above, is clash: early guesses stay in the context and contradict what arrives later. Pick the symptom you are seeing to find the failure behind it.
A better model or a stronger prompt fixes none of the four, because each one is a problem with what reached the model. So start any diagnosis with the agent's context. Check what was in the window on the step that went wrong, and where each piece came from.
Larger windows tempt teams into a simple fix: if the agent is missing something, give it everything. Chroma's study shows the cost. Adding one distractor, a passage similar to the answer but wrong, lowered accuracy compared with the clean test. Four distractors lowered it further. An enterprise search index is full of near-duplicates of exactly that kind: outdated policies, draft contracts, the same process described by three teams.
Size also costs money on every call. You pay for each token in the window, and each one adds delay. An agent that carries a 38,000-token policy manual to answer a question about one discount rule pays for the whole manual every time. Switch between the two windows below to see the same request built both ways.
The engineered window is smaller because each piece was chosen for this request. The rule comes from a store that tracks each version. The account arrives in business terms, not column names. The decision itself goes to a rules engine that returns a fixed answer. Our post on mapping business rules into the context layer shows how those rule records are written and owned.
Seven techniques cover the four failures between them. Four of them appear in Anthropic's guidance, and the other three are how our context layer handles rules and permissions.
Two of our builds show what this looks like in practice. An insurance client's daily MI alerting system calculates every figure in PostgreSQL views. The model gets finished numbers and writes a sentence around them, and a check step flags any figure the model was not given. Pinkcube's chat agent answers from a knowledge base built from support conversations the Pinkcube team had already resolved, checked before the agent can use them. After 76 hostile test scenarios, the worst-scoring case became a rule. Questions about a specific product now go straight to a support ticket and skip the knowledge base search (Pinkcube case study).
One agent can carry its own code for fetching data. Ten agents built that way each keep their own copy of the rules, their own data translations and their own access filters, and over time they stop matching. A context layer moves that work into one shared system. Sources are connected once and access is checked before anything is fetched. Rules are stored as records with versions, and every fetch is logged with where the data came from.
Our enterprise context layer is built inside your private cloud network (VPC), on n8n and the Model Context Protocol. MCP is the open standard AI tools use to connect to company data, and every agent reads from the layer through it. The five-layer blueprint covers how each layer is built. Our guide to context layer vs semantic layer covers how it differs from the metric definitions your reporting tools already use. Our explainer what is an MCP server covers the protocol itself.
The same log answers the governance questions later: who asked, what the agent read and which version of each rule it applied. Our post on data governance for AI covers what to record, and AI guardrails covers the checks that stop a bad answer before it becomes an action. Our comparison of AI audit logging tools shows which ones record what an agent read, returned and changed.
Context engineering is designing everything an AI model receives when it runs: instructions, retrieved data, tool definitions, conversation history and memory. Anthropic defines it as curating the optimal set of tokens for each step. For agents, it happens again on every step of a run.
Prompt engineering shapes how instructions are worded. Context engineering decides what data, tools and history sit beside those instructions, how they are formatted, and when they are fetched or dropped. Prompt engineering is one part of context engineering.
When the model can do the task, the failure usually sits in the context. The agent may keep building on an early error, or carry a history so long it crowds out the instructions. It may get tools and records the task did not need, or sources that contradict each other. Logging the full context on the failing step usually shows which one.
Context rot is Chroma's name for the decline in model reliability as the input grows. Its July 2025 study of 18 models found that performance grows increasingly unreliable as the input gets longer. Passages that look like the answer but are wrong lower accuracy further.
No. A larger window lets in more irrelevant or conflicting material. That makes distraction, confusion and clash more likely, and adds cost and delay to every call. A smaller window chosen for the step usually does better.
A context engineer designs how data reaches the model. That covers which sources an agent may read, how records are translated into business terms and how access is checked before anything is fetched. It also covers when history is summarized and what is logged for each answer.
To find the workflow where better context would pay off first, start with the AI Audit, or book a discovery call and walk through an agent that is failing today.