Context Engineering: Getting the Right Information to the Model
Prompt engineering asks how to phrase a request. Context engineering asks a bigger question: of everything the model could see, what should actually be in its limited context window right now? It is the skill that most determines whether an LLM system is accurate.
What is context engineering?
A language model only knows what is in its context window — the bounded set of tokens it can attend to at once. Context engineering is the discipline of deciding what goes into that window, in what form, and in what order, so the model has exactly what it needs and little it does not.
It is a superset of prompt engineering. Phrasing matters, but in real systems the dominant factors are which documents you retrieve, how you summarise history, which tools you expose, and how you manage a budget that is always smaller than everything you could include.
Why it matters more than prompts
Most production LLM failures trace back to context, not phrasing. The model hallucinates because the grounding it needed was not retrieved. It ignores an instruction because it was buried under thousands of tokens of history. It picks the wrong tool because ten were in scope when two would do.
- ●Relevance — include what the task needs and exclude what it does not. More context is not better context.
- ●Position — models attend unevenly across a long window; critical instructions and facts belong where they will be seen.
- ●Form — structured, compact information is easier for the model to use than raw dumps.
- ●Budget — every token spent on noise is a token unavailable for signal, and it costs money and latency.
Core techniques
Retrieval
Pull only the most relevant chunks of your knowledge into context at query time, rather than stuffing everything in. Retrieval quality — chunking, embeddings, ranking — is usually where accuracy is won or lost.
Compaction
As conversations and agent runs grow, summarise older turns into compact state instead of carrying raw history. This keeps the window focused and costs bounded over long tasks.
Structuring
Give the model structure — clear sections, delimiters, and schemas — so it can locate and use information reliably. The same facts in a structured form outperform a wall of prose.
Tool scoping
Expose only the tools relevant to the current step. A smaller, well-described toolset produces far more reliable tool selection than a large one.
Context engineering in practice
In a real system these techniques combine: retrieve grounded knowledge, compact history to stay within budget, structure everything the model sees, and scope tools per step. Done well, the same model produces dramatically more accurate, cheaper, and faster results — without touching its weights.