ANAlpesh Nakrani
SolutionsBlogBooksPraiseAboutWork with me
Back to the blog
Blog/Aug 30, 2026 · 12 min

Why Context Engineering Replaced Prompt Engineering

Context engineering curates every token in a model's context window: instructions, tools, memory, retrieved documents, not just the wording of one prompt.

Context engineering is the discipline of deciding what tokens sit inside a large language model's context window at each step of inference: system instructions, tool definitions, memory, retrieved documents, and message history. It is not a better-written prompt. It is a budget you manage, turn by turn, for a model that runs out of usable attention long before it runs out of window.

Prompt engineering asks what to say to the model. Context engineering asks what the model should know when it answers. That distinction stopped being academic the moment teams moved from single-turn chatbots to agents that run for hundreds of steps, call a dozen tools, and carry a growing pile of history into every new decision. The prompt was never the bottleneck in those systems. The context was.

Key takeaways

  • Context engineering manages the whole window, not one prompt. Instructions, tools, memory, retrieved documents, and history all compete for the same finite attention budget.
  • It superseded prompt engineering because agents fail on bad context, not bad phrasing. Multi-step, multi-tool systems break from irrelevant, stale, or conflicting tokens more often than from a clumsy instruction.
  • Bigger context windows do not mean more usable context. Independent testing across 18 frontier models found reliability degrading well before advertised limits, a pattern researchers call context rot.
  • Four moves do the actual work: write, select, compress, isolate. Scratchpads and memory, retrieval, compaction, and sub-agents each protect the budget a different way.
  • More context without curation makes things worse, not better. Context pollution and context confusion are the honest failure modes, and no amount of retrieval rescues a weak model or the wrong architecture.

What context engineering actually is

Context engineering is the practice of curating the tokens an LLM sees before it generates a response, so the model has exactly what it needs and nothing that competes with it. That includes the system prompt, the tool schemas available to it, any retrieved documents, prior turns of conversation, and whatever a memory system has chosen to carry forward. Every one of those pieces occupies space in a window that has a hard ceiling, and a much lower, softer ceiling on what the model uses well.

Prompt engineering decides what to ask. Context engineering decides what the model knows when it answers. A well-phrased instruction sitting next to twelve pages of stale tool output and three contradictory memory entries still produces a bad answer, because the phrasing was never the constraint. Anthropic's engineering team made a similar case in its September 2025 write-up on the discipline, framing context as a finite resource with a real attention budget rather than an unlimited scratchpad. Anthropic's guide to effective context engineering reframes the design question from how to phrase an instruction to what configuration of context is most likely to produce the behavior you want.

Prompt engineering decides what to ask. Context engineering decides what the model knows when it answers.

Why prompt engineering ran out of runway

Prompt engineering earned its reputation on single-turn chatbots. One instruction, one user message, one response. Getting the phrasing, the examples, and the format right genuinely moved output quality, because the entire input fit in view and stayed static.

Agents broke that model. A coding agent, a research agent, or a support-triage agent runs for dozens or hundreds of steps. Each step adds a tool call, a result, a decision. By step forty, the "prompt" is no longer a prompt. It is a sprawling transcript of everything that happened, most of it irrelevant to the next decision, some of it contradicting instructions given twenty steps earlier. No amount of clever phrasing at step one controls what the model sees at step forty.

That shift is what Anthropic named alongside the release of Claude Sonnet 4.5 in 2025: context, not the prompt, had become the scarce resource in agentic systems. The industry had spent two years optimizing the wrong variable.

The four moves that manage a context budget

Practitioners building long-running agents tend to group the techniques that protect a context budget under four verbs: write, select, compress, isolate. Each one answers a different question about what belongs in the window right now.

Write means giving the agent somewhere to put information that is not the context window itself: a scratchpad, a file, a memory store. An agent that writes its plan to a file and rereads it only when needed carries less forward than one that keeps re-stating the plan every turn.

Select means retrieval: pulling in only the documents, tool results, or memory entries relevant to the current step, on demand, instead of front-loading everything a task might conceivably need. Anthropic calls this just-in-time retrieval, and it is the difference between an agent that reads a file when it needs it and one that has an entire repository pasted into its system prompt "to be safe."

I have watched a version of that second failure with a coding agent that pasted an entire monorepo into context to be thorough. It had ten times more code than the task needed, including three deprecated versions of the same function, and confidently edited the wrong one. That is not a reasoning failure. That is a context failure.

Compress means compaction: summarizing a long history into a smaller, high-signal version and reinitializing the window from that summary instead of letting the transcript grow unbounded. This is the move that keeps a long-horizon agent from eventually drowning in its own output.

Isolate means sub-agents with their own, separate context windows. A lead agent delegates a bounded piece of work to a sub-agent, which does its research or analysis in a clean window and returns a condensed result, so the lead agent's context stays small no matter how much raw work happened underneath it. I go deeper on the specific failure modes of that kind of delegation in my field guide to agentic workflows, where the same isolation principle is the difference between a reliable agent chain and one that compounds errors at every hop.

Context rot: why bigger windows don't mean better answers

A model with a one-million-token window does not give you one million tokens of reliable reasoning. Chroma's July 2025 Context Rot technical report tested eighteen frontier models, including GPT-4.1, Claude 4, Gemini 2.5, and Qwen3, on simple tasks like retrieval and replication. Every model got measurably less reliable as input length grew, even on tasks that should be trivial regardless of length.

The degradation is not a cliff at the advertised limit. It is a curve that starts well before it, with the steepest drop-off clustering in the hundreds of thousands of tokens for models advertising windows in the millions. A distractor a model shrugs off at ten thousand tokens can derail it at two hundred thousand. The researchers also found content that is structurally coherent, a well-organized document, sometimes hurts performance compared to the same information shuffled, because coherent structure invites the model to over-trust proximity as relevance.

A one-million-token window is not one million tokens of usable context. It is a budget that gets less reliable long before it runs out.

The practical consequence: stuffing the window is a tactic, not a strategy. I wrote a full technical breakdown of why long context and memory are different problems in Long Context Is Not Memory, because the confusion between "the model can hold it" and "the model will use it well" is where most context-engineering mistakes start.

The context engineering stack: RAG, memory, MCP, and sub-agents

Four layers do the work of supplying and managing context in a production agent, and each earns its place for a different reason.

Retrieval-augmented generation supplies facts the model was not trained on and cannot be expected to know: your product docs, your latest pricing, last week's support tickets. RAG is a select move. It only helps if it retrieves the right handful of documents, not the ten it was allowed to fetch.

Memory supplies continuity across sessions: what a user prefers, what an agent already tried, what failed last time. Memory is a write move that has to be curated as carefully as retrieval, because a memory system that never forgets is context rot with a longer fuse.

The Model Context Protocol is the standardized way tools and data enter an agent's context at all, rather than every team hand-rolling its own tool-calling format. MCP matters here because it turned context supply from an ad hoc integration problem into an engineering layer with its own reliability guarantees. The protocol's July 2026 specification update converted MCP from a stateful, session-bound protocol into a stateless request-and-response model. A remote MCP server that once needed sticky sessions and a shared session store can now sit behind a plain round-robin load balancer, because every request carries its own identity and capabilities instead of depending on a handshake from requests earlier. That is context-supply infrastructure maturing the way web APIs did, a sign the discipline has moved past blog-post advice into production plumbing.

Sub-agents supply isolation: a way to do expensive, token-heavy work in a window that never touches the lead agent's budget. A research agent that spawns three sub-agents to search different sources, then reads only their three-paragraph summaries, spends far less context than one that reads every search result itself.

A context audit you can run this week

You do not need a new architecture to start managing your context budget. You need to look at what is already in the window and ask four questions.

# illustrative context budget, 200K-token agent
system_instructions: 1,200 tokens
tool_definitions: 3,400 tokens
retrieved_docs: 18,000 tokens
message_history: 42,000 tokens # uncompacted, growing every turn
available_for_reasoning: 135,400 tokens

Run this against a live agent and you usually find the same four problems.

  • What is stale? System instructions and tool descriptions written months ago, for a product that has since changed, still consuming tokens on every call.
  • What is duplicated? The same fact retrieved twice from two different sources, or a memory entry that repeats what the system prompt already says.
  • What should be a tool call instead of standing context? Pricing, inventory, or account data that changes daily has no business living in a static system prompt. Fetch it just in time.
  • What is winning the model's attention that shouldn't be? Long, structurally tidy documents near the top of the window often out-compete a short, relevant fact buried in message twelve.

Fix what you find in order: cut the stale content first, move the volatile facts to tool calls second, then compact history and isolate the heavy work into sub-agents. The audit costs an afternoon. Skipping it costs a production incident you spend a week debugging, convinced the model got dumber when the context did.

Where context engineering breaks

It is easy to oversell this discipline as "add more tools, more memory, more retrieved documents." That is the opposite of what it is. More context without curation produces two specific failure modes.

Context pollution is irrelevant or redundant tokens degrading reasoning: the monorepo pasted in to be thorough. Context confusion is the model losing the ability to tell instructions from data, or holding two directives that quietly contradict each other because they were written weeks apart by different people. Both get worse, not better, as you add more sources without a curation step.

The honest cost is real engineering overhead. Retrieval pipelines, compaction logic, and sub-agent isolation are systems you build, instrument, and maintain, not settings you toggle on. Most teams underinvest here because it does not look like progress the way a new feature does. None of it rescues a weak model or the wrong architecture. Context engineering makes a capable model reliable. It does not make an incapable one capable.

That is the trade-off worth naming plainly: context engineering is necessary, and it is not sufficient. Treat it as the second engineering discipline it is, not a prompt-tweaking shortcut.

Frequently asked questions

What is context engineering in AI, in plain terms?

Context engineering is deciding what information a language model has access to at each step: instructions, tools, memory, retrieved documents, and conversation history. It is the discipline of managing that whole set as a limited budget, instead of only wordsmithing the instruction you send.

Is context engineering just a rebrand of prompt engineering?

No. Prompt engineering optimizes the phrasing of a single instruction for a single-turn interaction. Context engineering manages an entire, changing set of tokens across a multi-step agent run: what to retrieve, what to keep, what to compress, and what to isolate. A good prompt is still part of a well-engineered context, but phrasing was never the whole job.

What is "context rot" and how do you prevent it?

Context rot is the documented tendency for model reliability to decline as input length grows, even on simple tasks, well before the advertised context limit is reached. You limit it by keeping the window small and high-signal: retrieve only what the current step needs, compact history regularly, and isolate token-heavy work in sub-agents instead of letting it accumulate in the main context.

Do I need RAG, MCP, and agent memory, or just one of them?

Most production agents need some combination, not all three at full strength. RAG supplies facts the model was not trained on. Memory supplies continuity across sessions. MCP standardizes how tools and data enter context in the first place. Start with whichever gap causes your agent to fail, and add the others only when a specific failure demands them.

Where this leaves you

Context engineering is not prompt engineering with a new name. It is the discipline of curating a finite, degrading resource across every step an agent takes, using retrieval, memory, compaction, and isolation instead of hoping a bigger window covers for a lack of curation. Run the audit, fix what is stale and duplicated, and treat the context window the way you already treat memory and compute: as a budget, not a bottomless bucket.

If you are building agents that need this discipline baked in from day one, not bolted on after the first production incident, that is the kind of system work a team with production context-engineering experience does well. Talk to ViitorCloud's technology consulting team about auditing and architecting the context layer of your AI systems before it becomes the reason your agent stops working at scale.

Share
Next

Keep reading

View all blogs

Ask AI about Why Context Engineering Replaced Prompt Engineering