Using AI tools

Context engineering

In short

Context engineering is the work of deciding exactly what information goes into an AI model's working memory for each step of a task: instructions, documents, tool results and past messages. It extends prompt engineering beyond the wording of a single request.

Topic
Using AI tools
Level
Some background helps
First described
The term was popularised in June 2025, when Tobi Lütke wrote that he preferred "context engineering" to prompt engineering and Andrej Karpathy agreed six days later34.

A language model can only use what is in its context window, the text it is given at that moment. In a simple chat that is your question. In an AI agent that runs for many steps, it fills up with instructions, tool descriptions, search results, files and the history so far.

Anthropic describes context engineering as "the natural progression of prompt engineering": the set of strategies for curating the best set of tokens during a model's work, including everything that lands there outside the prompt itself1. A July 2025 survey of more than 1,400 papers treats it as a discipline covering retrieval, memory systems, tool use and multi-agent set-ups2.

More context is not automatically better. Anthropic points to "context rot": as the number of tokens grows, a model's ability to recall information from them falls, an effect seen across models1. It argues good practice is finding "the smallest possible set of high-signal tokens" for the job1.

Common techniques include compaction, where a conversation near the limit is summarised and restarted from the summary; structured note-taking, where an agent saves notes outside the context window and reads them back later; and splitting work between several agents, each with a clean context1. Anthropic says its Claude Code agent uses compaction, asking the model to summarise the message history while keeping key decisions and unresolved bugs1. Retrieval-augmented generation, which fetches only the relevant document passages, is another2.

Example

A coding assistant fixing a bug in a large app cannot read every file at once. Good context engineering means it loads the error message, the two files involved and a short project summary, rather than the whole codebase.

Why it matters

It is a large part of why some AI agents stay on track over long tasks and others drift or forget. For people building with AI, choosing what the model sees now matters as much as how the request is phrased.

Questions people ask

Is context engineering the same as prompt engineering?

No, but it builds on it. Anthropic says prompt engineering is about writing and organising instructions, while context engineering covers managing all the information the model sees, including tool results, documents and message history1.

Who coined the term context engineering?

It is not clear who used it first. It spread in June 2025 after Tobi Lütke posted that he preferred it to prompt engineering3, and Andrej Karpathy backed the term days later4.

Why not just give the model everything?

Because models get worse at recalling details as their context grows, an effect Anthropic calls context rot1. Extra material also costs money and time. Selecting the most useful information usually gives better results.

Related terms

Tools that use it

Sources

  1. Anthropic (2025), Effective context engineering for AI agents
  2. Mei et al. (2025), A Survey of Context Engineering for Large Language Models, arXiv:2507.13334
  3. Tobi Lütke (@tobi), post on X, 19 June 2025
  4. Andrej Karpathy (@karpathy), post on X, 25 June 2025

Back to the glossary