Guide · Context engineering

Context engineering vs prompt engineering: one string, or the whole input.

Prompt engineering words the instructions. Context engineering decides every token the model reads on a turn — instructions included.

A model answers from what is in front of it and nothing else. For a single question, good wording is most of the job. For an agent that calls tools across dozens of turns, the instructions are a small slice of the input — and the rest has to be built, budgeted and checked every time. This guide shows what each discipline covers, why long contexts fail, and the techniques teams use to fix them.

Updated · 8 sources

What fills one turn of an agent’s context
01
System instructionsrole, rules and tone
prompt
02
Tool definitionseach tool’s name, purpose and schema
context
03
Examplesa few canonical cases to imitate
prompt
04
Retrieved materialdocuments fetched for this request
context
05
Memoryearlier turns, a summary, saved notes
context
06
Tool resultswhat the last calls returned
context
07
The new messagewhat the person just asked
input

What is the difference in context engineering vs prompt engineering?

Prompt engineering is writing and refining the instructions a language model receives. Context engineering is deciding everything the model sees on each turn — instructions, tool definitions, retrieved documents, memory and tool results — and how much of each fits. In context engineering vs prompt engineering, the second contains the first: Anthropic calls context engineering “the natural progression of prompt engineering”.

Side by side

Context engineering vs prompt engineering, dimension by dimension.

The two differ in what they work on, when the work happens and who does it. Prompt engineering is mostly done once, by a person, at design time. Context engineering is done on every turn, by software.

the instructions

Prompt engineering

Crafting the words of a request so the model understands the task, the format and the constraints.

  • Works on one piece of text
  • Done by a person, then reused
  • Wording, structure, examples, format
  • Enough for single-turn tasks
the whole input

Context engineering

Choosing and assembling everything the model reads on each turn, inside a finite token budget.

  • Works on every block in the window
  • Done by software, every turn
  • Selection, order, compression, memory
  • Needed once an agent runs many turns
How should this be worded?Core questionWhat should the model know right now?
A prompt templateUnit of workA context assembled from many sources
At design timeWhen it runsAt run time, before each model call
Ambiguous or brittle instructionsMain failureMissing, stale, buried or excess context
Rewrite, add examples, set a formatTypical fixesRetrieve, summarise, reorder, drop, isolate
Output quality on test promptsMeasured byOutput quality and tokens spent per turn
From prompts to context

How prompt engineering grew into context engineering.

Each step below moved more of the model’s input out of a hand-written prompt and into material gathered at run time — until the prompt was the smallest part.

  1. May 2020Few-shot promptingThe GPT-3 paper shows a model can learn a task from examples placed in the prompt, with no retraining.
  2. Jan 2022Chain-of-thoughtPrompt examples that show intermediate reasoning steps improve results on arithmetic, commonsense and symbolic reasoning.
  3. Oct 2022ReActReasoning interleaved with actions: the model calls tools and reads their results back into its context.
  4. Jul 2023Lost in the MiddleResearchers show models use facts at the start and end of a long input better than facts in the middle.
  5. Dec 2024The augmented LLMAnthropic describes agents as models enhanced with retrieval, tools and memory.
  6. Sep 2025Context engineeringAnthropic publishes its guide: curate the smallest set of high-signal tokens for each step.
The evidence

Why more context makes answers worse, measured.

A larger context window is not a larger attention span. Research and the model providers’ own documentation agree: as the input grows, recall falls — and position, distractors and noise all make it fall faster.

56.1%
GPT-3.5-Turbo’s score with no documents at all — higher than its score with 20 or 30 documents when the answer sat in the middle
Liu et al., Lost in the Middle
18
models tested by Chroma; performance grew less reliable as input length grew, even on simple tasks
Chroma, Context Rot (2025)
n²
pairwise relationships for n tokens — every token attends to every other, so attention is a budget
Anthropic, Effective context engineering
length

Context rot

Accuracy and recall degrade as the token count grows. Claude’s documentation names it and says curating what is in context matters as much as how much space there is.

position

Lost in the middle

Facts placed mid-context are used least. Important material belongs at the start or near the question.

noise

Distraction

In Chroma’s tests even a single near-miss distractor lowered accuracy, and four lowered it further.

choice

Tool confusion

Bloated tool sets with overlapping purposes leave the model unsure which to call — Anthropic lists this among the most common failures.

The toolkit

Six context engineering techniques, and the loop that applies them before every call.

Every technique below does one of four things: puts less in, puts it in later, puts it in a better place, or moves work to a separate context. Most production agents use several at once.

What runs before every model call
  1. GatherCandidates from every source: instructions, memory, tools, retrieval.
  2. SelectKeep what this step needs; leave references for the rest.
  3. CompressSummarise old turns; clear stale tool results.
  4. OrderStable blocks first, key facts near the question.
  5. CheckDrop what this person may not see; mark untrusted text.
  6. CallThe model reads the context and answers or calls a tool.

The tool result joins the context, and the next turn is built again from the top.

Six techniques from Anthropic’s guide

  • Instructions at the right altitudeSpecific enough to guide, general enough to avoid brittle if-then logic.
  • Canonical examplesA few diverse examples instead of a long list of edge-case rules.
  • Token-efficient toolsClear, non-overlapping tools whose results are compact.
  • Just-in-time retrievalKeep identifiers such as file paths or queries; load the content with a tool when needed.
  • Compaction and notesSummarise near the limit and restart; write persistent notes outside the window.
  • Sub-agentsSpecialists work in clean windows and return a condensed summary — often 1,000–2,000 tokens.
The same request, twice

A worked example: one question, prompt-engineered and context-engineered.

A claims handler on a claim page types “why is this one stuck?”. The prompt alone cannot answer it — the model does not know who is asking, which claim “this one” is, or what happened to it. The engineered context does.

Prompt engineering only
SYSTEM
You are a helpful claims assistant.
Answer clearly and concisely.
If unsure, say so.

USER
why is this one stuck?

→ The model must guess, or ask
  which claim is meant.
Context engineering (abridged)
SYSTEM  role, rules, output format
USER    M. Ortiz · claims handler
PAGE    Claim CL-2291 · status Pending
RECENT  opened CL-2291; viewed notes
MEMORY  summary of 14 earlier turns
TOOLS   names + one line each
RETRIEVED  CL-2291 history:
  “awaiting police report since 3 Oct”
USER    why is this one stuck?

What changed. The instructions are almost the same. What changed is everything around them: who is asking, the page, a summary of the conversation, the tools that exist and one retrieved fact — each chosen for this turn, within a budget.

Decision guide

When prompt engineering is enough, and when context engineering takes over.

The more turns, tools and sources a system has, the less of its behaviour the prompt decides. Place your system on the scale, then answer one question.

The prompt decides mostThe context decides most
1234
  1. Single-shot taskClassify, rewrite, extract from one input. Wording and examples do the work.
  2. Chat with retrievalRetrieved passages and short history join the prompt.
  3. Tool-using agentTool definitions and results outweigh the instructions within a few turns.
  4. Long-running agentHours or sessions of work: compaction, notes and sub-agents are mandatory.

Does the model’s input change from turn to turn?

No — one fixed inputPrompt engineering is the job. Test wording and examples against a set of known cases.
Yes — history and retrievalAdd context engineering: budget the history, place retrieved facts near the question, cite sources.
Yes — tools and many turnsContext engineering leads: just-in-time retrieval, compaction, clear tool results, isolate sub-tasks.
On Botminds

How Botminds builds an agent’s context on every turn.

On Botminds the prompt is one input to a build that runs the same way for every agent, every turn — from named sources, held to budgets, and open to preview before any model reads it.

One context profile per agentbuilt fresh on every turn, on every replica
Named sourceswho is asking, the project, the page, the conversation
Budgets per tierlowest priority dropped first; every drop recorded
Stable firstunchanging blocks lead, in a cache-friendly order
Typed words stay dataa person’s words enter as quoted data, never as instructions
Names firstskills, tool servers and tables listed in one line; bodies fetched when needed
Folding memorylatest messages word for word, one rolling summary of the rest
Variables at eight scopesone agent, each team’s own names and wording
Previewevery block with its tier and token count, no model call

Read the full design in context engineering on Botminds, and how instructions, tools and knowledge come together in the anatomy of an agent.

Questions people ask

Context engineering vs prompt engineering: common questions.

The technology behind itContext engineeringExactly what the model sees, each turn
What is context engineering vs prompt engineering in simple terms?

In context engineering vs prompt engineering, prompt engineering is writing good instructions, and context engineering is deciding everything else the model sees on each turn — tools, retrieved documents, memory and tool results — and how much of each fits. Context engineering includes prompt engineering.

Is context engineering replacing prompt engineering?

No. Clear instructions still matter — Anthropic’s guide spends a section on writing system prompts at the right altitude. What changed is that, for agents, instructions are a small share of the input, so the rest needs its own discipline.

What is harness engineering, and how does it relate?

Harness engineering improves an agent by changing the software around the model — tools, context, checks and recovery — rather than the model itself. Context engineering is one part of the harness; prompt engineering is one part of context engineering.

What is an example of context engineering?

An agent asked “why is this one stuck?” on a claim page gets who is asking, the claim on screen, recent actions, a summary of earlier turns and the claim’s history retrieved for that turn. The instructions barely change; the assembled context answers the question.

What is context rot?

Context rot is the fall in accuracy and recall as a model’s input grows. Claude’s documentation names it, and Chroma measured it across 18 models in 2025. It is why curating the context matters as much as the size of the window.

Is RAG part of context engineering?

Yes. Retrieval-augmented generation is one way to bring material into the context. Context engineering also decides when to retrieve, how much to keep, where to place it and what to drop — and covers memory and tool results, which RAG does not.

What does Anthropic recommend for context engineering?

Find the smallest set of high-signal tokens that makes the desired outcome likely: instructions at the right altitude, a few canonical examples, compact non-overlapping tools, just-in-time retrieval, compaction, structured notes and sub-agents for long tasks.

Do bigger context windows make context engineering unnecessary?

No. Research such as Lost in the Middle shows models use information in the middle of long inputs worst, and more documents add little after a point. A bigger window raises the ceiling; it does not choose what goes in.

See it on
your own work.

Bring one process and its documents. We’ll show you the agents, the controls and the record, running on your data.