Context Engineering
Context engineering is the discipline of curating exactly what enters an LLM's context window so it has the right information and nothing else.
Context engineering is deciding what actually enters an LLM's context window each turn: instructions, retrieved data, tool results, and prior history, plus what to summarize or drop. It matters because context is a budget, not a free pile. Every token costs latency and money, attention dilutes over long inputs, and a focused window beats a stuffed one.
Context engineering is the practice of deliberately curating what goes into an LLM's context window — instructions, retrieved data, tool results, and history — so the model has exactly the information it needs and nothing extraneous.
It has become the central discipline for building agents, largely superseding "prompt engineering" as the unit of work. A long-running agent's context is assembled dynamically across many turns: system instructions, results from RAG retrieval, outputs from tools, and prior conversation. Deciding what to include, what to summarize, and what to drop is what separates a reliable agent from one that drifts or stalls.
It matters because context is a budget, not a free pile: every token costs latency and money, and model attention dilutes over long inputs so buried facts go unused. The practical craft is loading the relevant slice rather than everything — retrieving instead of dumping, compacting old turns, and trimming tool output to the essentials. The tradeoff is engineering effort: good context assembly takes work, but a focused window consistently outperforms a stuffed one. For the full discipline, see the context engineering guide.
Frequently asked questions
- How is context engineering different from prompt engineering?
- Prompt engineering focuses on wording a single instruction well. Context engineering is broader: it's about deciding everything that goes into the window — instructions, retrieved data, tool outputs, and conversation history — and what to leave out. As applications became multi-step agents, what's in context started to matter more than how the prompt is phrased, so context engineering supersedes prompt engineering for agentic work.
- Why not just put everything in the context window?
- Because more context isn't better context. Every token costs money and latency, and models attend less reliably to information buried in long inputs, so relevant facts get lost amid noise. Loading only the right slice — through retrieval, summarization, and selective tool results — reliably beats stuffing the window full.
Filed under
context · prompting · agents · retrieval
Related
- Extended ThinkingExtended thinking is the reasoning tokens a model generates before its final answer, trading latency and cost for higher accuracy on hard problems.
- Context WindowThe context window is the maximum text — measured in tokens — an LLM can consider at once: prompt, conversation, documents, and its own output combined.
- RAG (Retrieval-Augmented Generation)RAG retrieves relevant documents from your own data and injects them into an LLM's prompt at query time, grounding answers in facts the model wasn't trained on.
- Token (LLM)A token is the unit LLMs read and write — a word fragment of roughly 3–4 characters in English. Models are priced, limited, and measured in tokens, not words.
- AGENTS.mdAGENTS.md is a versioned instruction file that tells coding agents how to work in a repository — including commands, conventions, boundaries, and checks.
- Prompt EngineeringPrompt engineering is the practice of designing an LLM's inputs — instructions, context, examples, and format — to reliably get the output you want.