All articles

ai-agents

How context engineering differs from prompt engineering

Prompt engineering is about what you say to the model. Context engineering is about everything the model can see when it acts. What changed, what did not, and the four ways a context goes wrong.

Victor K Kiptum

5 min read

A context window drawn as a long bar split into instructions, tools, files, history and notes, with the prompt as one small highlighted slice and three items left outside the window

In March 2023, Anthropic advertised a "prompt engineer & librarian" role with a salary range of $175,000 to $335,000, Fortune reported. Two years later, TechRepublic, citing The Wall Street Journal, described the job as "basically obsolete".

The skill did not disappear. It became one part of a larger one, which now has its own name.

The short answer

In June 2025, Shopify's Tobi Lütke wrote that he preferred "context engineering" because it describes "the art of providing all the context for the task to be plausibly solvable by the LLM". Andrej Karpathy agreed: people hear "prompt" and think of a short task description, while real applications depend on "filling the context window with just the right information for the next step".

The context window is everything the model reads before it answers: instructions, tool definitions, files, earlier turns, tool results, notes. Your prompt is one slice of it.

Prompt engineering and context engineering compared

AspectPrompt engineeringContext engineering
Unit of workOne requestA whole session or agent run
Main questionHow should I phrase this?What should the model see now?
Main skillWritingSelecting, saving, and cutting
Typical fixReword the instructionRemove, summarise, or load something
Who writes most of itYouYour tools, files, and the agent itself

Sources: Anthropic's guide to context engineering and LangChain's context engineering for agents.

The last row is the real shift. In a long agent run, most tokens come from file reads, search results, and the agent's own output, not from a person.

Why more context is not the answer

Bigger windows did not remove the problem. Chroma's context rot report tested 18 models and found that performance "consistently degrades with increasing input length", even on simple tasks. A single distracting passage, one that looks relevant but is not, lowered accuracy.

Anthropic's guide gives the practical rule: context is "a finite resource with diminishing marginal returns", so the goal is "the smallest possible set of high-signal tokens" for the outcome you want.

Prompt engineering asks what to say. Context engineering asks what to leave out.

The four moves

LangChain sorts the techniques into four groups:

  • Write: save information outside the window, such as a spec file, a notes file, or a handoff report.
  • Select: pull the right piece back in when it is needed, by a file path, a search, or a memory lookup.
  • Compress: keep only the tokens the task needs, for example by summarising a long session before it hits the limit.
  • Isolate: split work across subagents so each one starts with a clean window.

Anthropic's guide describes the same moves as compaction, structured note-taking, and sub-agents. It adds "just in time" loading: keep a lightweight reference, such as a file path, and open the file only when the agent needs it.

A worked example

I took this blog's cover images through a coding agent. My first request was two words, "draw them". I got four covers with the same dark background and the same teal accent, and threw them away.

The wording was not the problem. The agent needed the existing covers, the site's palette, and my rules for what a cover may contain. Two words carried none of that. The second attempt started with the agent inspecting the site and writing a proposal I approved, so the right material was in front of it before any file changed. Afterwards, the cover rules went into a file my writing skill loads every time, so the next session starts with them.

Four ways a context goes wrong

Drew Breunig names four failures. Each one has a fix from the moves above.

Four context failures and a fix for each

FailureWhat happensA fix
PoisoningAn early error stays in the context and keeps being referencedStart a fresh session from a written summary
DistractionA long history crowds out what the model already knowsCompact the session, or split the task
ConfusionIrrelevant tools or text shape the answerLoad fewer tools; load files just in time
ClashNew information contradicts older information in the windowKeep one current source of truth in a file

Sources: failure names and definitions from Breunig; fixes from Anthropic's guide and LangChain.

Most of these fixes are deletions: fewer tools, a shorter history, a fresh window. Prompt engineering rarely asked for that.

What did not change

Wording still matters. Anthropic's guide warns against system prompts that are either brittle and over-specified or vague. A clear instruction is still the cheapest improvement. It is now one decision among several.

Takeaways

  • When an agent gets something wrong, check what it could see before you reword the request.
  • Write decisions to files. A file can be selected into the next session; a chat message cannot.
  • Treat every tool definition, file, and old turn as costing attention, and remove the ones that do not earn it.

Sources

ai-agentscontext-engineeringprompt-engineering

Written by

Victor K Kiptum

Software Engineer · About me

More articles