Last Updated: May 30, 2026
When teams try to improve LLM output, they often start by rewriting the prompt. That helps, but in real systems the prompt is only one piece of the input.
Modern LLM applications send far more than a single instruction to the model. The model may receive a system prompt defining its behavior, retrieved documents from a knowledge base, conversation history from earlier messages, tool definitions, and the user's question. All of this together forms the context window the model uses to generate its response.
Context engineering is the practice of designing and managing that entire context. It involves deciding what information to include, what to exclude, how to structure it, how much history to keep, and how to combine retrieved knowledge with user instructions. In many production systems, context selection has more impact than another round of prompt wording changes.
This chapter focuses on the engineering work: token budgets, context types, selection strategies, formatting, conversation history, and long-context failure modes.