What is context engineering?
Context engineering is the work of deciding what a language model sees each time it is called: instructions, documents, tool descriptions, earlier messages and stored notes. Anthropic, LangChain, Manus and Google write about it in posts on AI agents, which call a model in a loop. Five sources give a definition (pages retrieved on 5 December 2026):
| Source and date | Definition |
|---|---|
| LangChain, “The rise of “context engineering”” (23 June 2025; metadata: modified 25 August 2026) | “Context engineering is building dynamic systems to provide the right information and tools in the right format such that the LLM can plausibly accomplish the task.” |
| Anthropic, “Effective context engineering for AI agents” (published 29 September 2025; metadata: modified 18 October 2026) | “Context engineering refers to the set of strategies for curating and maintaining the optimal set of tokens (information) during LLM inference, including all the other information that may land there outside of the prompts.” |
| Gartner, Avivah Litan (6 October 2025; metadata: modified 14 August 2026) | “Gartner defines context engineering as designing and structuring the relevant data, workflows and environment so AI systems can understand intent, make better decisions and deliver contextual, enterprise-aligned outcomes” |
| Birgitta Böckeler on martinfowler.com, quoting her colleague Bharani Subramaniam (5 February 2026) | “Context engineering is curating what the model sees so that you get a better result.” |
| IBM, “What Is Context Engineering?” (the page does not show a date; its metadata gives 28 April 2026) | “Context engineering is the practice of deliberately designing, structuring and optimizing the context provided to a large language model (LLM) to produce more accurate, relevant and reliable outputs.” |
LangChain speaks of systems, Anthropic of strategies, IBM of a practice. Gartner's sentence continues with “without relying on manual prompts”.
What goes into the context
The context is everything the model reads in one call. Anthropic's post lists its parts as follows: “we need strategies for managing the entire context state (system instructions, tools, Model Context Protocol (MCP), external data, message history, etc).” LangChain's post of 2 July 2025 names one group of them: “Instructions – prompts, memories, few‑shot examples, tool descriptions, etc”. The entry on few-shot prompting explains the few-shot examples named there. Mem0's page (updated 9 September 2026) gives this list: “That information can include instructions, conversation history, retrieved documents, tool results, and relevant memories.”
Wikipedia treats the term in its article on prompt engineering (last edited on 30 November 2026): “Context engineering is a related process that focuses on the context elements that accompany user prompts, which include system instructions, retrieved knowledge, tool definitions, conversation summaries, and task metadata.” The limit on how much fits into one call is covered in the entry on the context window.
Anthropic · 29 Sep 2025
system instructions
tools
Model Context Protocol (MCP)
external data
message history
LangChain · 2 Jul 2025
Instructions (prompts · memories · few-shot examples · tool descriptions)
Knowledge (facts · memories)
Tools (feedback from tool calls)
Mem0 · updated 9 Sep 2026
instructions
conversation history
retrieved documents
tool results
relevant memories
Wikipedia · edited 30 Nov 2026
system instructions
retrieved knowledge
tool definitions
conversation summaries
task metadata
context of one model call
Context engineering and prompt engineering
The sources describe the relation between the two terms in three different ways: as a progression, as a subset and as a difference in the question asked.
| Source and date | Wording |
|---|---|
| Anthropic (29 September 2025) | “At Anthropic, we view context engineering as the natural progression of prompt engineering.” |
| Weaviate (9 December 2025) | “In simple words, prompt engineering is how you ask the question, while context engineering is making sure the model has access to the right textbook, calculator, and even notes/memories from your previous conversation before it starts thinking.” |
| Elastic Search Labs (20 January 2026) | “While prompt engineering asks, ‘How should I phrase this?,’ context engineering asks, ‘What information does the model need access to right now?’” |
| IBM (metadata: 28 April 2026) | “Prompt engineering is the process of creating an LLM prompt that will lead to a better output. This method is a subset of context engineering, but narrower in scope.” |
The GitHub Blog (12 January 2026, updated 14 January 2026) puts it in one line: “Context engineering is the evolution of prompt engineering.” Elastic calls context engineering “the broader discipline of curating and maintaining the optimal set of tokens during LLM inference”. On runtruffle.com, the entry on prompt engineering for brands uses the words prompt engineering for something else: writing the test prompts that show how AI assistants talk about a brand.
Why the context has to be managed
Anthropic's post explains why more text in the window is not free: “Studies on needle-in-a-haystack style benchmarking have uncovered the concept of context rot: as the number of tokens in the context window increases, the model’s ability to accurately recall information from that context decreases.” It uses an image for this: “LLMs have an “attention budget” that they draw on when parsing large volumes of context.” And it draws the conclusion: “Context, therefore, must be treated as a finite resource with diminishing marginal returns.”
Hangfei Lin does not treat a larger window as the whole answer either, writing on the Google Developers Blog (4 December 2025): “A large context window will help context-related problems but won't address all context-related problems.” LangChain locates failures of agents here: “Most of the time when an agent is not performing reliably the underlying cause is that the appropriate context, instructions and tools have not been communicated to the model.”
Techniques the sources name
LangChain's post of 2 July 2025 sorts the techniques into four groups:
| Group | Wording |
|---|---|
| Write | “Writing context means saving it outside the context window to help an agent perform a task.” |
| Select | “Selecting context means pulling it into the context window to help an agent perform a task.” |
| Compress | “Compressing context involves retaining only the tokens required to perform a task.” |
| Isolate | “Isolating context involves splitting it up to help an agent perform a task.” |
Anthropic describes three techniques for long tasks. Compaction: “Compaction is the practice of taking a conversation nearing the context window limit, summarizing its contents, and reinitiating a new context window with the summary.” Notes: “Structured note-taking, or agentic memory, is a technique where the agent regularly writes notes persisted to memory outside of the context window.” Sub-agents: “Rather than one agent attempting to maintain state across an entire project, specialized sub-agents can handle focused tasks with clean context windows.”
The Manus post by Yichao ‘Peak’ Ji (18 July 2025, shown on the page as 2025/7/18) writes from the operation of its agent. On cost and speed: “If I had to choose just one metric, I'd argue that the KV-cache hit rate is the single most important metric for a production-stage AI agent.” What that cache holds is explained in the entry on the KV cache, and its reuse across requests in the entry on prompt caching. On storage outside the window: “That's why we treat the file system as the ultimate context in Manus: unlimited in size, persistent by nature, and directly operable by the agent itself.”
Context engineering, RAG, memory and MCP
IBM places two known methods under the term: “It encompasses two closely related and commonly discussed techniques: Prompt engineering and retrieval augmented generation (RAG)”. On the second, IBM writes: “RAG focuses on ways to add information from documents or databases to the LLMs’ context window”. How a system retrieves those documents is described in the entry on retrieval-augmented generation.
Weaviate (9 December 2025) links the term to memory: “In practice, context engineering is how you build LLM memory: deciding what stays in the context window, what gets stored as long-term memory, and what gets retrieved later.” Anthropic's list of the context state includes the Model Context Protocol, an open protocol for connecting models to tools and data; the entry on MCP describes it. The entry on AI agents covers the systems that the posts by Anthropic, LangChain and Manus are written for.
What papers report
Abstracts of papers on context engineering, by date of the version quoted. Each figure is the authors' own result under the conditions their abstract names.
| Paper and version | Wording |
|---|---|
| Mei et al., “A Survey of Context Engineering for Large Language Models”, arXiv 2507.13334, version 1 (17 July 2025) | “This survey introduces Context Engineering, a formal discipline that transcends simple prompt design to encompass the systematic optimization of information payloads for LLMs.” |
| Mohsenimofidi et al., “Context Engineering for AI Agents in Open-Source Software”, arXiv 2510.21413, version 4 (5 February 2026) | “we present the results of a preliminary study investigating the adoption of AI context files in 466 open-source software projects.” and “Our findings indicate that there is no established content structure yet and that there is a lot of variation in terms of how context is provided” |
| Qizheng Zhang et al., “Agentic Context Engineering”, arXiv 2510.04618, version 3 (29 March 2026) | “We introduce ACE (Agentic Context Engineering), a framework that treats contexts as evolving playbooks that accumulate, refine, and organize strategies through a modular process of generation, reflection, and curation.” The authors report: “Across agent and domain-specific benchmarks, ACE optimizes contexts both offline (e.g., system prompts) and online (e.g., agent memory), consistently outperforming strong baselines: +10.6% on agents and +8.6% on finance” |
| Junrui Zhang et al., “Revisiting LLMs as Context Engineers”, arXiv 2611.30494, version 1 (23 November 2026) | The abstract uses LCE for LLM context engineering: “We compared different LCE methods with different LLM families in 8B size, showing that there is no single winner for all tasks, even compared with simple baselines like chain-of-thought.” |
| Geiger et al., “Search-Based Context Engineering for AI Agents”, arXiv 2612.02484, version 1 (25 November 2026) | “We evaluate our approach with two open-weight LLMs on fact verification and question-answering benchmarks against the baseline configuration.” and “On fact verification, NSGA-II finds configurations that reduce token usage by 8%-27% without any significant loss in accuracy.” |
Names and dates in the sources
Simon Willison wrote on 27 June 2025: “The term context engineering has recently started to gain traction as a better alternative to prompt engineering.” His page quotes two posts from X and links to them. The one by Tobi Lütke reads, as quoted on Simon Willison's page: “I really like the term “context engineering” over prompt engineering.” The one by Andrej Karpathy, quoted on the same page: “+1 for ‘context engineering’ over ‘prompt engineering’”. Philipp Schmid wrote on 30 June 2025: “Context Engineering is new term gaining traction in the AI world.” The Prompting Guide (last updated 1 February 2026) states: “I am not entirely sure who coined context engineering”.
Hua et al. (arXiv 2510.26493, version 1, 30 October 2025) look further back: “Although it is often regarded as a recent innovation of the agent era, we argue that related practices can be traced back more than twenty years.”
Abstracts change between versions. The survey by Mei et al. reads “Through this systematic analysis of over 1300 research papers” in version 1 (17 July 2025) and “Through this systematic analysis of over 1400 research papers” in version 2 (21 July 2025). Version 1 of the ACE paper (6 October 2025) begins its central sentence with “Building on the adaptive memory introduced by Dynamic Cheatsheet”; version 3 (29 March 2026) starts the same sentence with “We introduce ACE”.
27 Jun 2025
Simon Willison,
blog post
30 Jun 2025
Philipp Schmid,
blog post
17 Jul 2025
Mei et al.,
survey version 1 (“over 1300 research papers”)
21 Jul 2025
Mei et al.,
survey version 2 (“over 1400 research papers”)
6 Oct 2025
Q. Zhang et al.,
ACE version 1
30 Oct 2025
Hua et al.,
version 1
1 Feb 2026
Prompting Guide,
last updated
29 Mar 2026
Q. Zhang et al.,
ACE version 3
Harness engineering and other neighbouring terms
Birgitta Böckeler describes, in “Harness Engineering - first thoughts” on martinfowler.com (17 February 2026), the harness that an OpenAI team built to maintain a large application with AI agents: “The OpenAI team’s harness components mix deterministic and LLM-based approaches across 3 categories (grouping based on my interpretation)”. Context engineering is one of the three: “Context engineering: Continuously enhanced knowledge base in the codebase, plus agent access to dynamic context like observability data and browser navigation”.
Lorena A. Barba (arXiv 2609.11728, version 1, 10 September 2026) applies the term to reproducible research practices: “Reproducible research practices are context engineering for AI coding agents.”
Context engineering and related terms
Context window. The window is the amount of text a model reads in one call; the entry on the context window explains its limits.
Retrieval-augmented generation. RAG fetches documents and adds them to the context; the entry on RAG explains the method.
Model Context Protocol. MCP connects a model to tools and data sources whose descriptions end up in the context; the entry on MCP covers the standard.
AI agent. Agents call a model repeatedly and carry context from step to step; the entry on AI agents explains what they are.
Prompt caching. Providers can reuse a prompt beginning that stays the same between calls; the entry on prompt caching quotes their documentation.
Source
- LangChain, “The rise of “context engineering”” (23 June 2025; metadata: modified 25 August 2026). Source for the LangChain definition and agent failures (retrieved 2026-12-05): https://www.langchain.com/blog/the-rise-of-context-engineering
- LangChain, “Context Engineering” (2 July 2025). Source for write, select, compress and isolate (retrieved 2026-12-05): https://blog.langchain.com/context-engineering-for-agents/
- Simon Willison, “Context engineering” (27 June 2025). Source for his wording and the two quoted posts (retrieved 2026-12-05): https://simonwillison.net/2025/jun/27/context-engineering/
- Philipp Schmid, “The New Skill in AI is Not Prompting, It's Context Engineering” (30 June 2025). Source for his wording (retrieved 2026-12-05): https://www.philschmid.de/context-engineering
- Anthropic, “Effective context engineering for AI agents” (published 29 September 2025, metadata modified 2026-10-18). Source for the Anthropic definition, context rot, attention budget and techniques (retrieved 2026-12-05): https://www.anthropic.com/research/effective-context-engineering-for-ai-agents
- Gartner, Avivah Litan, “Context engineering: Why it’s Replacing Prompt Engineering for Enterprise AI Success” (6 October 2025, metadata modified 2026-08-14). Source for the Gartner definition (retrieved 2026-12-05): https://www.gartner.com/en/articles/context-engineering
- Weaviate, “Context Engineering - LLM Memory and Retrieval for AI Agents” (9 December 2025). Source for the comparison with prompt engineering and memory (retrieved 2026-12-05): https://weaviate.io/blog/context-engineering
- Hangfei Lin, “Architecting efficient context-aware multi-agent framework for production”, Google Developers Blog (4 December 2025). Source for the sentence on large context windows (retrieved 2026-12-05): https://developers.googleblog.com/architecting-efficient-context-aware-multi-agent-framework-for-production/
- GitHub Blog, “Want better AI outputs? Try context engineering.” (12 January 2026, updated 14 January 2026). Source for its wording (retrieved 2026-12-05): https://blog.github.com/ai-and-ml/generative-ai/want-better-ai-outputs-try-context-engineering/
- Elastic Search Labs, “Context engineering vs. prompt engineering” (20 January 2026). Source for the comparison with prompt engineering (retrieved 2026-12-05): https://www.elastic.co/search-labs/blog/context-engineering-vs-prompt-engineering
- Birgitta Böckeler, “Context Engineering for Coding Agents”, martinfowler.com (5 February 2026). Source for the definition by Bharani Subramaniam (retrieved 2026-12-05): https://martinfowler.com/articles/exploring-gen-ai/context-engineering-coding-agents.html
- Birgitta Böckeler, “Harness Engineering - first thoughts”, martinfowler.com (17 February 2026). Source for harness engineering (retrieved 2026-12-05): https://martinfowler.com/articles/exploring-gen-ai/harness-engineering-memo.html
- IBM, “What Is Context Engineering?” (no visible date, metadata 2026-04-28). Source for the IBM definition and the relation to prompt engineering and RAG (retrieved 2026-12-05): https://www.ibm.com/think/topics/context-engineering
- Yichao ‘Peak’ Ji, Manus, “Context Engineering for AI Agents: Lessons from Building Manus” (2025/7/18 on the page). Source for KV-cache hit rate and the file system (retrieved 2026-12-05): https://manus.im/blog/Context-Engineering-for-AI-Agents-Lessons-from-Building-Manus
- Prompting Guide, “Context Engineering Guide” (last updated 1 February 2026). Source for its wording on the origin (retrieved 2026-12-05): https://www.promptingguide.ai/guides/context-engineering-guide
- Mem0, “What Is Context Engineering in AI? Techniques, Components & Best Practices” (updated 9 September 2026). Source for the list of inputs (retrieved 2026-12-05): https://mem0.ai/library/context-engineering/what-is-context-engineering-ai
- Wikipedia, “Prompt engineering”, section on context engineering (last edited on 30 November 2026). Source for the Wikipedia wording (retrieved 2026-12-05): https://en.wikipedia.org/wiki/Prompt_engineering
- Mei et al., “A Survey of Context Engineering for Large Language Models”, arXiv 2507.13334, version 1 (17 July 2025) and version 2 (21 July 2025). Source for the survey and its two versions (retrieved 2026-12-05): https://arxiv.org/abs/2507.13334
- Qizheng Zhang et al., “Agentic Context Engineering: Evolving Contexts for Self-Improving Language Models”, arXiv 2510.04618, version 1 (6 October 2025) and version 3 (29 March 2026). Source for ACE and its figures (retrieved 2026-12-05): https://arxiv.org/abs/2510.04618
- Mohsenimofidi et al., “Context Engineering for AI Agents in Open-Source Software”, arXiv 2510.21413, version 4 (5 February 2026). Source for context files in open-source projects (retrieved 2026-12-05): https://arxiv.org/abs/2510.21413v4
- Hua et al., “Context Engineering 2.0: The Context of Context Engineering”, arXiv 2510.26493, version 1 (30 October 2025). Source for the longer history (retrieved 2026-12-05): https://arxiv.org/abs/2510.26493v1
- Barba, “Reproducibility in the Age of Agentic AI: Context Engineering at the Timescale of a Codebase”, arXiv 2609.11728, version 1 (10 September 2026). Source for reproducible research practices (retrieved 2026-12-05): https://arxiv.org/abs/2609.11728v1
- Junrui Zhang et al., “Revisiting LLMs as Context Engineers”, arXiv 2611.30494, version 1 (23 November 2026). Source for the comparison of LCE methods (retrieved 2026-12-05): https://arxiv.org/abs/2611.30494v1
- Geiger et al., “Search-Based Context Engineering for AI Agents: Optimizing Token Usage and Task Performance”, arXiv 2612.02484, version 1 (25 November 2026). Source for token usage on fact verification (retrieved 2026-12-05): https://arxiv.org/abs/2612.02484v1
Frequently asked questions
What is context engineering in simple terms?
It is the choice of what a language model gets to see before it answers: instructions, documents, tool results and earlier messages. Birgitta Böckeler quotes her colleague Bharani Subramaniam on martinfowler.com (5 February 2026): “Context engineering is curating what the model sees so that you get a better result.”
Is context engineering the same as prompt engineering?
The sources relate the two in different ways. Anthropic (29 September 2025) calls context engineering “the natural progression of prompt engineering”. IBM calls prompt engineering “a subset of context engineering, but narrower in scope”. Elastic Search Labs (20 January 2026) describes context engineering as the broader discipline of choosing the tokens a model receives.
What is an example of context engineering?
Anthropic describes compaction in Claude Code (29 September 2025): “In Claude Code, for example, we implement this by passing the message history to the model to summarize and compress the most critical details.” The Manus team (post of 18 July 2025) keeps material outside the window and writes that it treats “the file system as the ultimate context”.
Is context engineering the same as harness engineering?
Birgitta Böckeler (martinfowler.com, 17 February 2026) describes the harness an OpenAI team built to maintain a large application with AI agents. She groups its components into three categories, “based on my interpretation”: context engineering, architectural constraints and “Garbage collection”.
How does context engineering relate to RAG?
IBM places retrieval-augmented generation under context engineering: “It encompasses two closely related and commonly discussed techniques: Prompt engineering and retrieval augmented generation (RAG)”. RAG adds retrieved documents to the context; context engineering also covers instructions, tools, memory and message history.