What is context engineering in AI?
Also called context management, context curation
Definition
Context engineering is the practice of selecting, structuring, and pruning all the information placed in an LLM's context window at each step, including instructions, retrieved data, tool results, and memory.
Context engineering is the discipline of deciding what goes into a model's context window, in what form, and at which step. The discipline treats context as a limited resource to curate, not a container to fill. The term spread in June 2025, when Shopify CEO Tobi Lütke and Andrej Karpathy both publicly endorsed "context engineering" over "prompt engineering" as the name for this work.
How context engineering works#
At each step, an agent's context is assembled from several sources, and each source needs its own selection policy:
Anthropic's engineering post Effective context engineering for AI agents (September 2025) describes four core techniques:
- Just-in-time retrieval: keep lightweight references such as file paths or queries, and load the data with tools only when it is needed.
- Compaction: summarize the conversation as it nears the limit, then continue in a fresh window that starts from the summary.
- Structured note-taking: write notes to agent memory outside the window and read them back later.
- Sub-agents: hand focused subtasks to sub-agents with clean contexts that return condensed results.
Retrieval quality is part of the job: the retrieval step in retrieval-augmented generation determines which chunks enter the window. Ordering matters for cost and latency too, because prompt caching reuses only an unchanged prefix, so stable content belongs at the front.
Why context engineering matters#
More context is not automatically better. Anthropic uses the term "context rot" for the finding that a model's ability to recall information accurately declines as its context window fills. Every irrelevant tool result or stale message competes for attention with the information that matters. Long-running AI agents add context on every step, so without pruning, their windows fill with outdated tool output.
Context engineering vs prompt engineering#
Prompt engineering is a subset of context engineering. Prompt engineering optimizes the instructions for a single call; context engineering also manages the data, tools, and history around those instructions across many turns. The context engineering explainer goes deeper on both.
Related terms
Guides that cover context engineering
Cite this definition
The AI Engineering Editors. "What is context engineering in AI?" The AI Engineering, updated Nov 06, 2026. https://theaiengineering.com/glossary/context-engineering
- Title
- What is context engineering in AI?
- Author
- The AI Engineering Editors
- Publisher
- The AI Engineering
- Updated