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

Context Engineering vs Prompt Engineering: What's Different

Prompt engineering shapes one request. Context engineering curates everything the model sees across an agent run: tools, memory, retrieval, history.

Context engineering vs prompt engineering comes down to scope and time horizon. Prompt engineering decides what and how you ask a model in a single turn. Context engineering decides what the model has in front of it, the system prompt, tools, retrieved data, memory, conversation history, across an entire agent run. One optimizes a sentence. The other optimizes the pipeline that fills the context window before that sentence ever gets read.

I have shipped both kinds of work, and I still see teams treat them as the same skill with a rebrand. They are not. A well-tuned prompt can carry a single-shot task a long way. It cannot carry an agent that loops for forty steps, calls six tools, and has to remember what happened at step twelve when it reaches step thirty-five. That job belongs to context engineering, and most teams building agents in 2026 are doing it by accident instead of by design.

Prompt engineering optimizes a sentence. Context engineering optimizes the pipeline that fills the window before the sentence gets read.

Key takeaways

  • Different units of work. Prompt engineering tunes one instruction. Context engineering manages the full token budget across an entire agent session.
  • Bigger windows didn't fix reliability. Chroma tested 18 models and found performance degrades well before the token limit, a pattern researchers call context rot.
  • Four strategies do the job. Write, select, compress, and isolate, the framework Anthropic and LangChain both converge on for managing agent context.
  • A focused prompt beats a full context dump. In one Chroma test, a 300-token prompt sharply outperformed the equivalent 113,000-token version of the same task.
  • Match the tool to the task. Single-shot task, prompt engineering. Multi-step agent, context engineering, usually layered on top of good prompts, not instead of them.

What is prompt engineering?

Prompt engineering is the discipline of designing a single instruction to get the best output from a model on one turn. It covers format ("respond in JSON with these three fields"), tone ("write like a senior engineer, not a press release"), reasoning strategy ("think step by step before you answer"), and few-shot examples that show the model the pattern you want.

Done well, prompt engineering is high-leverage and cheap. A better system prompt can lift accuracy on a classification task by double digits without touching the model or the infrastructure around it. It is also, by construction, local. The prompt does not know what happened three turns ago unless you put that history back in front of it, and it does not know which of your fifteen tools is relevant to this specific step unless you tell it.

That locality is the whole limitation. A prompt is a single artifact you tune once and reuse. It has no opinion about what data gets retrieved, what gets summarized, or what gets dropped when the conversation runs long. Those are context engineering questions, and a prompt engineer working alone will eventually hit them without a framework for solving them. If you want the tactics for this layer in depth, I go through them in prompt engineering techniques and advanced prompt engineering techniques.

What is context engineering?

Anthropic defines context engineering as "the set of strategies for curating and maintaining the optimal set of tokens (information) during LLM inference," and that definition is precise for a reason (Anthropic, 2025). The word doing the work is "maintaining." Context engineering is not a one-time setup. It is a running discipline across a session that can span dozens of model calls.

Concretely, context engineering owns everything that fills the window before the model generates a token: the system prompt, the tool definitions and their descriptions, retrieved documents, memory the agent has written to itself, and the trimmed or summarized history of everything that happened earlier in the run. Andrej Karpathy's framing, cited widely in the field, captures the craft well: it is "the delicate art and science of filling the context window with just the right information for the next step."

Claude Code is Anthropic's own worked example. It preloads a CLAUDE.md file with stable project context, then fetches files just-in-time as the agent needs them rather than front-loading the whole repository. It ships a memory tool that persists facts across sessions instead of re-deriving them every run. And when a session runs long, it compacts the transcript into a summary that preserves architectural decisions and open bugs while discarding redundant tool output. None of that is a prompt. All of it is context engineering.

The core difference: a sentence vs. a pipeline

The cleanest way to see the split is side by side. Prompt engineering is an artifact you write once and version like a template. Context engineering is a system you run continuously, with its own failure modes and its own metrics.

DimensionPrompt engineeringContext engineering
Unit of workOne instruction, one turnThe full token budget across a session
Time horizonStatic, tuned once, reusedDynamic, curated turn by turn
Typical failure modeAmbiguous instruction, wrong formatContext rot, stale memory, tool overload
Who owns itWhoever writes the system promptWhoever designs the retrieval, memory, and compaction pipeline
Scales withBetter wordingBetter engineering: retrieval logic, sub-agents, compaction

Notice what the table implies about ownership. A prompt lives in a text file a product manager can edit in an afternoon. A context pipeline lives in code: retrieval calls, summarization jobs, sub-agent orchestration. That is why context engineering shows up as an engineering line item on a roadmap, not a copy edit.

Why this shift happened now: agents run in loops

Context engineering became its own discipline because agents changed the shape of the problem. A chatbot answers a question and the turn ends. An agent plans, calls a tool, reads the result, updates its plan, and calls another tool, often dozens of times before it is done. Every one of those steps adds tokens to the window: the tool call, the tool's raw output, the model's reasoning about what to do next.

Bigger context windows were supposed to make this easy. A million-token window looks like room to paste in the whole codebase, the whole conversation history, every tool spec you own, and let the model sort it out. That assumption is where most teams go wrong, and it is the exact failure mode context engineering exists to prevent.

The honest trade-off: managing context well costs real engineering effort. Retrieval logic, compaction jobs, sub-agent boundaries, all of that is work a single well-crafted prompt never demanded. For a one-shot task, that overhead is not worth paying. For a multi-step agent running in production, it is the difference between a system that holds and one that quietly drifts wrong for a week before anyone notices.

If your team is past the point of a single prompt and into agents that plan, act, and loop, that is usually where an outside team helps most, wiring the retrieval and compaction layer correctly the first time instead of after an incident. That is the kind of build we take on in technology consulting engagements at ViitorCloud, where the deliverable is the pipeline, not just the prompt.

The four context engineering strategies: write, select, compress, isolate

LangChain's framework for agent context management names four moves, and I use the same four vocabulary words when I explain this to a team for the first time (LangChain, 2025).

  • Write. Save information outside the active context window so the agent can retrieve it later instead of carrying it forward every turn. A scratchpad file or a memory tool are both write strategies.
  • Select. Pull only the relevant slice of saved information back into context for the current step. Claude Code's just-in-time file access is a select strategy: it fetches a file when the agent needs it, not the whole repository up front.
  • Compress. Summarize what has accumulated so the window holds the meaning without holding every token. Claude Code's auto-compact does exactly this when a session runs long, distilling the transcript into a summary and discarding what is now redundant.
  • Isolate. Split a task across multiple agents or sub-agents so no single context window has to hold everything at once. A sub-agent does focused work and returns a condensed result, often in the 1,000 to 2,000 token range, instead of dumping its full working context back to the orchestrator.

Picture a research agent that has to synthesize five sources into one answer. Handed to a single agent, that job means five full documents sitting in one context window while the model tries to reason across all of them at once, which is exactly the setup where recall gets shaky. Isolate that job into five sub-agents, each reading one source and returning a tight summary, and the orchestrator reasons over five short summaries instead of five long documents. Same task, a fraction of the tokens the final reasoning step has to hold.

Where context engineering breaks: context rot in practice

The strategies above exist because of a specific, measured failure mode. Chroma tested 18 frontier models, including GPT-4.1, Claude 4, Gemini 2.5, and Qwen3, across five controlled experiments and found that performance degrades non-uniformly as input length grows, often well before the model hits its stated token limit (Chroma, 2025). They call this context rot, and it holds even on tasks that should be trivial.

The sharpest result is a conversational-QA test called LongMemEval. A focused 300-token prompt sharply outperformed the equivalent full 113,000-token version of the same task, with Claude Opus 4 showing the largest gap between the two. Opus 4's failure mode under load was notable: it tended to abstain rather than guess, stating it could not find an answer instead of hallucinating one. Chroma's distractor tests found Claude models hallucinating at roughly 10 to 20 percent versus 30 to 40 percent for GPT models on the same setup, a real difference in how each family fails under pressure.

A 300-token prompt beat the same task run at 113,000 tokens. More context is not the same thing as better context.

I have watched the practical version of this play up close: a support agent whose context window fills with every prior turn of a long conversation, plus the tool outputs from each lookup along the way. By turn twenty, the model is reasoning across thousands of tokens of mostly irrelevant history, and its answer to a simple follow-up question gets worse, not better, than it was at turn three. Nothing crashed. No error fired. Recall quietly degraded, exactly the pattern Chroma measured at scale, playing out one conversation at a time.

A practical framework for choosing between them

You do not have to pick one discipline forever. Most real systems use both, layered. Here is the checklist I use to decide where to invest first.

  • Single-shot task, one model call, no memory needed? Invest in prompt engineering. Tune the instruction, add few-shot examples, and stop there.
  • Multi-step task where the model plans and calls tools? You need context engineering. Design what gets written, selected, compressed, and isolated before you scale the number of steps.
  • Session length growing past a few turns? Add compression before you add a bigger context window. A summary that preserves decisions beats raw history every time.
  • Agent handling more than one distinct sub-task? Isolate with sub-agents so no single window carries the whole job.
  • Seeing answers get worse as a conversation gets longer? That is context rot, not a prompting problem. Fix the pipeline, not the wording.

The pattern underneath all five: prompt engineering asks "what should I say." Context engineering asks "what should the model see, and when." An agent that plans and acts needs both questions answered, and a good context pipeline makes every prompt inside it work harder.

FAQ

Is context engineering just prompt engineering with a new name?

No. Prompt engineering optimizes the wording of a single instruction. Context engineering manages the full set of information available to the model across an entire session: retrieval, memory, tool definitions, and conversation history. A well-engineered prompt can still fail if the context pipeline around it is feeding the model stale or bloated information.

Do I need context engineering if I'm not building an agent?

Usually not, at least not as a formal discipline. A single-turn chatbot or a one-shot classification task lives comfortably inside prompt engineering. Context engineering earns its overhead when a system runs multiple steps, calls tools, or has to carry state across turns, which is exactly what agents do and single-shot calls do not.

What is context rot and how do I know if it's happening to me?

Context rot is the non-uniform degradation in model performance as input length grows, documented across 18 models by Chroma's research. You are likely seeing it if answer quality drops as a conversation or agent run gets longer, even though you have not changed the model or the underlying question. The fix is usually compression or retrieval discipline, not a bigger context window.

What are the four context engineering strategies?

Write, select, compress, and isolate. Write saves information outside the active window for later retrieval. Select pulls back only the relevant slice when needed. Compress summarizes accumulated context to preserve meaning while cutting tokens. Isolate splits work across sub-agents so no single window holds the entire task.

Prompt engineering still matters. Every context pipeline eventually hands the model an instruction, and a sloppy one wastes a well-curated window. But if you are building anything that plans, calls tools, or runs longer than a few turns, the pipeline is where reliability actually lives. My book, From Prompt to Pipeline, walks through the shift in full, including where I have watched teams try to skip straight to agents without ever building the context discipline underneath them. Start with the pillar piece on context engineering if you want the full strategy before you touch a single line of pipeline code.

Share
Next

Keep reading

View all blogs

Ask AI about Context Engineering vs Prompt Engineering: What's Different