By Plainly Editorial

Updated

First published

Prompt vs context engineering

Filed under AI & modern tech

For a one-off question or a single-step task, a well-written prompt is usually enough. Once you build an agent that calls tools, reads documents, and runs for many steps, most failures come from what is in the context window, not how the instruction is phrased. Learn prompting first, then treat context as the main lever in production.

Side-by-side

DimensionPrompt engineeringContext engineering
Core questionHow should I phrase this instruction?What should the model see right now, and what should be left out?
ScopeThe instruction text, often the system prompt plus the user messageThe whole context window: instructions, documents, tools, memory, history
Typical techniquesClear goals, role, output format, few-shot examples, step-by-step reasoningRetrieval, just-in-time loading, compaction, note-taking, sub-agents, tool design
When the work happensMostly once, while writing and testing the promptOn every model call, as the context is assembled again
Who usually does itAnyone using a chat assistant, plus developers writing system promptsDevelopers building RAG apps, agents, and multi-step workflows
Main constraintAmbiguity: the model cannot read your mindToken budget: the context window is finite and attention is spread thin
Typical failureVague, contradictory, or overloaded instructionsMissing facts, irrelevant noise, stale tool output, or key details buried mid-context
Fix for a wrong answerRewrite the instruction, add an example, specify the formatRetrieve better documents, trim history, summarize, change what tools return
Relation to RAGTells the model how to use provided passagesDecides which passages are retrieved and where they are placed
Relation to tools and MCPExplains when to use a toolChooses which tools are exposed and how much of their output is kept
How you measure itOutput quality on a set of test promptsTask success, cost, and latency across long, multi-step runs

Choose Prompt engineering when

  • You are asking a chat assistant a single question and want a better answer on the first try.
  • The model already has every fact it needs, but the tone, length, or format of the output is wrong.
  • You are writing or refining a system prompt that sets the role, rules, and style for an app.
  • You need consistent structured output, such as JSON or a table, and can show one or two examples.
  • You are working on a short, single-step task such as classifying, rewriting, or extracting fields from one document.

Choose Context engineering when

  • Answers depend on private documents or live data that the model can only see if you retrieve it.
  • You are building an agent that calls tools over many steps, so history and tool results pile up in the window.
  • The prompt looks fine, yet the model ignores details, forgets earlier decisions, or uses outdated information.
  • Costs and latency are climbing because every call resends long histories or large documents.
  • You are connecting many tools, for example through MCP, and the model keeps picking the wrong one.
  • A task runs longer than one context window can hold and needs summaries or saved notes to continue.

Common questions

Is context engineering just a new name for prompt engineering?

Not quite. Anthropic describes context engineering as the natural progression of prompt engineering: prompting focuses on writing good instructions, while context engineering manages the whole set of tokens the model sees, including tools, outside data, and message history. The term spread with agents, because their context changes on every step and has to be curated repeatedly.

What is context rot?

Context rot is the gradual drop in a model's ability to recall and use information as its context grows longer. It is not a hard cliff at the window limit; quality slips steadily as more tokens compete for attention. Anthropic's guidance is to aim for the smallest set of high-signal tokens that gets the job done rather than filling the window.

What does lost in the middle mean?

It refers to a 2023 study by Liu and colleagues which found that language models used information best when it appeared at the beginning or end of a long input, and noticeably worse when it sat in the middle. The practical lesson is to place critical instructions and the most relevant documents near the start or end.

If context windows keep getting bigger, does context engineering still matter?

Yes. A larger window raises the ceiling but does not remove context rot, distraction, or cost. Every token you send is billed and adds latency, and irrelevant material can still pull the model off course. Bigger windows mostly give you more room to make choices; they do not make the choices for you.

What are compaction and sub-agents?

Both are ways to keep a long task inside a finite window. Compaction means summarizing a context that is nearly full, often starting by clearing old tool results, and continuing from the summary. Sub-agents are separate model calls with their own clean context that handle one part of the job and return a short summary to the main agent.

Do I still need prompt engineering skills?

Yes. The system prompt and tool descriptions are part of the context, and they still need clear, specific wording. Anthropic suggests writing system prompts at the right altitude: specific enough to guide behavior, but not so rigid that they become brittle lists of hard-coded rules. Good context engineering builds on good prompting.

Which should beginners learn first?

Start with prompt engineering, because it pays off immediately in any chat assistant: state the goal, give context about who it is for, show an example, and specify the format. Move on to context engineering when you start building something, such as a RAG app or an agent, where you control what the model is fed on each call.

Sources and further reading

  1. Effective context engineering for AI agents — Anthropic
  2. Lost in the Middle: How Language Models Use Long Contexts — arXiv (Liu et al., 2023)
  3. Prompt engineering overview — Anthropic

Keep reading