Black October, explainedAppsGuidesAI DictionarySmall FixesOn RecordAboutFollow the lab

Context engineering

Context engineering is deciding exactly what information an AI gets to read for a task: the right instructions, files, history and tool results, and nothing that distracts.

Using AITechnical

In plain words

A prompt is what you type. But when an AI app or agent works, the model reads much more than that: hidden instructions, earlier messages, documents found by search, results from tools, saved notes about you. All of that together is its context.

The model can only read so much at once, and the more clutter it gets, the more likely it is to miss what matters. Context engineering is the job of filling that limited space well: put in what the task needs, summarise what is long, leave out what isn't relevant, and fetch details only when they're needed.

The term caught on in June 2025, when people building AI products argued it describes the real skill better than "prompt engineering". It matters most for agents that work for many steps.

Everyday example

Packing for a work trip

Your suitcase has limited space. Throw in everything you own and you can't find your charger when you need it. Pack only the formal shirt, the laptop, the printed tickets and a note of the hotel address, and the trip goes smoothly. Context engineering is packing the AI's suitcase for each task.

Where the example breaks: A suitcase is packed once. For an agent, context is repacked at every step: new tool results come in, old ones are summarised or dropped, and notes are read back in.

Go deeper

How it actually works

Anthropic's engineering team defines it as "the set of strategies for curating and maintaining the optimal set of tokens (information) during LLM inference".

  1. Why space is precious

    Every model has a context window, a maximum number of tokens it can read. Even within that limit, Anthropic's guide describes "context rot": recall gets less accurate as the context grows. The aim is the smallest set of high-signal information.

  2. Write lean instructions and tools

    Keep the system prompt clear and at the right level, neither rigid rules for every case nor vague advice. Offer a small set of distinct tools whose outputs are short.

  3. Retrieve just in time

    Instead of loading every document up front, give the agent references, such as file names or links, and let it open what it needs. This works alongside up-front retrieval.

  4. Compact, take notes, split work

    When context fills up, summarise it and continue in a fresh window (compaction). Let the agent write notes to a file and reread them later (memory). Give sub-tasks to sub-agents, each with a clean context, that report back short summaries.

Popularised
June 2025, when Shopify CEO Tobi Lütke and AI researcher Andrej Karpathy each backed the term over "prompt engineering"
Karpathy's description
"the delicate art and science of filling the context window" with the right information
Practical guide
Anthropic, "Effective context engineering for AI agents", September 2025
Relation to prompts
Prompt engineering is one part of it: writing the instructions. Context engineering covers everything else in the window too

Questions people ask

What is the difference between prompt engineering and context engineering?

Prompt engineering is about wording the instructions well. Context engineering is about everything the model reads: instructions, examples, retrieved documents, tool results, conversation history and memory, and deciding what to include, summarise or leave out at each step.

Why does context engineering matter for AI agents?

Agents run for many steps and collect a lot of material: web pages, files, tool outputs. Without curation the context window fills with clutter, costs rise and accuracy drops. Good context engineering keeps each step focused.

Is a bigger context window a replacement for context engineering?

No. Larger windows help, but models still recall less reliably as context grows, and every extra token costs time and money. Choosing well beats including everything.

Who coined the term context engineering?

No single person is credited. It spread in June 2025 when Shopify's CEO Tobi Lütke wrote that he preferred it to prompt engineering, and Andrej Karpathy agreed, calling it the art and science of filling the context window.

Further reading