Context engineering is the practice of assembling everything an AI model has in front of it when it works: instructions, relevant documents, conversation history, tool descriptions, memory and results from earlier steps. It extends prompt engineering from wording a single request to managing the whole flow of information an AI agent sees over a long task.
A new name for a growing job
The term spread in June 2025, when Shopify’s chief executive Tobi Lütke said he preferred it to “prompt engineering,” and the AI researcher Andrej Karpathy agreed a few days later, calling it both art and science: too little in a model’s context window starves it, too much raises cost and lowers quality. The shift reflected a change in how AI is used. A chatbot answering one question needs a good prompt; an agent that writes software or researches a topic for an hour makes dozens or hundreds of model calls, each of which must be given the right material. Anthropic, which published a guide to the practice in September 2025, frames the aim as giving the model as little as possible, but everything that counts.
Why more is not better
Context windows now hold hundreds of thousands of tokens or more, but filling them is not a solution. A 2023 study found that models used information at the beginning and end of a long input better than material in the middle. Later tests found that results grew less reliable as inputs lengthened, even on easy tasks – a problem nicknamed “context rot” on Hacker News and studied by the retrieval-database company Chroma in July 2025. Long contexts are also slower and more expensive. Irrelevant or contradictory material can distract a model, and untrusted content can carry hidden instructions, the risk known as prompt injection.
Techniques
Practitioners, for instance at LangChain, group the methods into writing, selecting, compressing and isolating context:
- Retrieval: Fetching only the relevant documents at the moment they are needed, as in retrieval-augmented generation.
- Tool design: Giving an agent a few clear, well-described tools rather than many overlapping ones (see tool use).
- Memory and notes: Letting the agent write notes to files and reload them later instead of carrying everything in its context.
- Compression: Condensing a long history into a summary when space runs short (see compaction).
- Isolation: Splitting work among helper agents, each focused on one part, so that no single context gets cluttered (see multi-agent system).
Why it matters
Context engineering helps explain why the same model can perform very differently from one product to another: what it is given to work with matters as much as how capable it is. It shifts attention from magic phrases to information design – a discipline that mixes software engineering with good briefing. For users, the lesson carries over: an AI assistant does better work when it gets the relevant files, background and goals, and worse when it is buried in everything at once.
Written with Claude, made by Anthropic, which has published guidance on context engineering for building agents with Claude and offers several of the techniques described here as product features.
Related
Prompt Engineering · Context Window · Retrieval-Augmented Generation · Compaction · AI Agent · System Prompt
Sources: Simon Willison: Context engineering (June 27, 2025, quoting Tobi Lütke on June 19 and Andrej Karpathy on June 25) · Simon Willison: Context rot (June 18, 2025) · Lance Martin: Context Engineering for Agents (June 23, 2025) · Anthropic: Effective context engineering for AI agents (September 29, 2025) · Nelson F. Liu et al.: Lost in the Middle: How Language Models Use Long Contexts (arXiv) (July 2023) · Kelly Hong, Anton Troynikov, Jeff Huber: Context Rot: How Increasing Input Tokens Impacts LLM Performance (Chroma) (July 14, 2025)
Leave a Reply