
Context Engineering is the discipline of designing everything an AI agent sees, the data, rules, tools, and memory, in the right format at the right time, so it acts on meaning instead of guessing. It is broader than prompt engineering (a subset of it) and broader than RAG (one component of it), and for agents that work with company data, the decisive part lives in a governed data layer, not in the prompt. This guide covers what it is, where it came from, how it differs from prompt engineering and RAG, what breaks without it, how to build it, and how Nekt delivers it.
Context Engineering is the discipline of assembling everything an AI model needs to complete a task, the instructions, retrieved data, tools, examples, memory, and business rules, in the right format and at the right moment. It moves the craft from writing a better sentence to designing a better input. The premise behind it is blunt: frontier models are no longer the bottleneck. Two teams using the same model get very different results, and the gap comes from the context each agent is given, not from the wording of a single prompt.
Andrej Karpathy defined it as "the delicate art and science of filling the context window with just the right information for the next step."
For an agent that works with company data, the "right information" is not only documents pulled in at query time. It is the meaning of the data: what an active customer is, which date counts as revenue, that a cost field is stored in millionths, that two records are the same company. When that meaning is engineered into the system, the agent reads a rule. When it is missing, the agent invents one, and it does so with total confidence.
The term went mainstream in June 2025. On June 19, Shopify CEO Tobi Lutke posted that he preferred "context engineering" over "prompt engineering," calling it the art of providing all the context for a task to be plausibly solvable by the model. Karpathy amplified it days later, and Walden Yan at Cognition, the team behind the Devin coding agent, had been writing about the same practice earlier that year. June 2025 gave an old data problem a name that stuck.
Context Engineering is the superset. Prompt engineering is a subset of it, and RAG is one component of it. They are not competing choices; they are nested layers of the same problem.
ApproachWhat it optimizesScopeThe question it asksPrompt engineeringThe wording of one instructionA single static stringHow do I phrase this so the model responds well?RAGWhich data enters the windowOne retrieval stepWhat should I put in front of the model right now?Context EngineeringThe whole information environmentInstructions, retrieval, memory, tools, token budget, business semanticsWhat does the model need to answer correctly, and where does each piece come from?
The distinction is not academic. Rewording a prompt cannot fix a number that is wrong because the agent never knew a currency was stored in millionths. Retrieving the deals table is retrieval, but knowing that a merged, absorbed record must not be counted twice is context. An agent needs all three, and the two most people skip are the business semantics and the governance around them.
It spans everything that enters the context window, plus the systems that decide what belongs there. Six components carry most of the weight:
For a data agent, the semantics block is the one that decides whether the answer is trustworthy, and it is the one that cannot live in a prompt, because it has to apply to every question, every agent, and every report at once.
Because an agent, unlike an analyst, does not ask when it is unsure. It answers with confidence even when it is wrong, and a well written wrong answer is far harder to catch than an obvious one. A person who opens a table with a strange column name asks a colleague. An agent deduces. Context Engineering removes the guess by putting the rule next to the data.
The cost of skipping it is now visible at the portfolio level. Gartner projects that over 40% of agentic AI projects will be canceled by the end of 2027, citing rising costs, unclear business value, and inadequate controls. Rising cost and unclear value are precisely what an agent produces when it has to reconstruct meaning at query time instead of reading it. The failure is rarely the model; it is the work being pushed into the model that was never model work.
The agent invents definitions, joins data by reading it, and produces numbers no one can trust. Four failure modes recur, and none of them appears in the demo; they appear in month three of production:
The concrete cases are unglamorous and decisive. Each one is context about the data, not the data itself:
The caseWhat the agent does wrongThe rule that fixes itAd cost stored in millionthsReports a cost per acquisition a million times too high, explained convincinglyOne unit is 1,000,000; divide before any cost metricCorporate vs personal emailBlends the two and calls a healthy channel brokenCorporate converts at 15 to 20%, personal near 1%; split before measuringHistorical win after churnReports "never a customer" about someone paying todayA churned customer still carries the historical win; count itCreated, closed, first-charged datesAnswers "how much did we sell in June" three different waysPick one revenue date and define it once
None of that is data. All of it is context about the data.
For data-heavy agents, most of it belongs in a governed data layer, not the prompt. A rule written into a prompt applies to one agent and one conversation, and it drifts the moment someone edits the wording. A rule written into the data applies once, everywhere, to every agent and every report. A layered model makes this concrete:
On top of that layer, meaning is annotated per column and served with the data. That annotation, the note that says this cost is in millionths or this date is first-charge, is Context Engineering in its most literal form: the analyst's knowledge, written down, versioned, and delivered to the agent instead of kept in someone's head.

Start from the questions the business asks, not from the tools. A sequence that works:
MCP is the last step, not the first. Starting there, with no semantic layer underneath, is why so many agent projects stall.
The recurring anti-patterns are easy to name and expensive to live with:
Nekt is a data platform built to give AI agents governed context, which is Context Engineering delivered as a product rather than a project. It covers the three parts an agent needs, in one place:
The point is that the rule is written once and travels with the data to every agent, instead of being re-explained in every prompt. That is why the same question stops returning different numbers, and why an agent can cross many systems in a single query instead of paging through each one.
The gain shows up as accuracy, cost, and speed on the same model. In one production benchmark, an agent querying sources directly was compared with the same agent on a governed data layer, with context served alongside the data.
MetricQuerying sources directlyGoverned data layer, context servedAccuracy38%91%Work to answer234 tool calls1 SQL queryTime~15 minutes19 seconds
Same model, same question: 38% accuracy over 234 tool calls, or 91% accuracy in one query. The difference is not the model; it is the context beneath it. (Nekt benchmark.)
You can see this in your own data. See how Nekt works, or create a free account and connect your first source.
No. RAG is one component of Context Engineering. RAG handles retrieval, pulling relevant records into the context window. Context Engineering also covers memory, tool orchestration, token budget, and, for company data, the business rules that make retrieved data mean something.
No. Prompt engineering is a subset of Context Engineering. Wording still matters, but it cannot fix an answer that is wrong because the agent lacked the definition. That is a context problem, not a phrasing problem.
A semantic layer is a large part of Context Engineering for data agents, but not all of it. The semantic layer supplies governed definitions and models; Context Engineering also includes memory, tools, and how everything is assembled in the window at runtime.
The practical answer is a data platform that can connect sources, govern them with per-column meaning, and serve them to agents with the definitions attached, over MCP or an API. Nekt is built specifically for this: connect, govern, and serve context to agents from one place.
Yes. RAG gives the agent the right documents; it does not give the agent the rules for interpreting them. Without governed semantics, an agent can retrieve perfectly and still count the same customer twice.