Context engineering
Context engineering is the practice of deciding what instructions, information, tools and history go into an AI model's context window at each step, so it has what it needs for a task and little else.
A language model only knows what is in front of it when it generates a response: its training plus the tokens in its context window. Anthropic's engineering team defines context as exactly that set of tokens. In a simple chat the context is mostly the user's prompt. In an AI agent it also holds a system prompt, tool definitions, the results of every tool call so far, retrieved documents, notes from memory and the conversation history, and it changes every time the model is called.
The term caught on in mid-2025. On June 23, 2025 Harrison Chase of LangChain described it as building dynamic systems that give a model the right information and tools in the right format, building on earlier remarks by Tobi Lutke and others. In September 2025 Anthropic called it the natural progression of prompt engineering: prompt engineering is about writing good instructions, while context engineering is about curating everything that lands in the model's input, turn after turn.
The reason it matters is that context is finite and gets less useful as it fills. Anthropic points to needle-in-a-haystack tests in which recall falls as the window fills, a decline it calls context rot, and explains that in a transformer every token attends to every other, so n tokens create n squared pairwise relationships and attention is spread thinner. Stuffing in everything that might be relevant can make the model worse, not better.
The techniques are mostly practical housekeeping. Compaction summarises a long conversation and starts a fresh window from the summary. Structured notes let an agent write progress to a file outside the context and read it back later. Sub-agents do focused work in their own clean windows and return a short summary. Just-in-time retrieval keeps lightweight references, such as file paths, and loads the content only when needed. A coding agent, for example, does not read a whole repository up front; it searches, opens the files it needs and summarises as it goes.
Much of this gathers existing ideas, such as retrieval-augmented generation and conversation summaries, under one heading. What the label adds is a way of thinking about failures. Chase argues that when an agent performs badly, the usual cause is that it was not given the right context, instructions and tools, rather than a lack of ability in the model. That is a useful first question to ask before blaming the model or switching to a larger one.
Prompt engineering is about writing and structuring the instructions you give a model. Context engineering is broader: it covers everything in the model's input, including retrieved documents, tool results, memory and conversation history, and it is done again at every step of an agent's work. Anthropic describes context engineering as the natural progression of prompt engineering. Agents run for many steps, and each step adds tool output and history to the context. Because models become less reliable as their context fills, an agent that keeps everything soon degrades. Deciding what to keep, summarise or fetch later is what lets an agent work on long tasks. No. A larger window lets you include more, but research such as Chroma's July 2025 study of 18 models found that performance becomes less reliable as input length grows, even on simple tasks. Keeping the context focused still tends to give better results than filling it. The main ones are compaction, which summarises a long history into a fresh context; note-taking to files outside the context; sub-agents that work in separate windows and return summaries; and retrieving information only when it is needed. Retrieval-augmented generation and long-term memory are also part of the toolkit.Common questions
What is the difference between context engineering and prompt engineering?
Why does context engineering matter for AI agents?
Does a bigger context window make context engineering unnecessary?
What are common context engineering techniques?
Search for "context engineering" together with "AI agents", "compaction" or "context window management" to find practical guides. The most useful sources are engineering posts and documentation from model makers and agent framework developers, which describe techniques they use in production, and research on long-context performance for why the problem exists. Many posts on the subject are marketing for a framework, so look for ones that explain trade-offs and show measurements.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.