← AI glossary

AI glossary · Basic · Language models · Agents

Context engineering

Context engineering is the work of designing all the information an AI model (LLM) sees when it produces an answer. It decides which of the instructions, conversation history, retrieved documents and tool results to include, how much, and in what order.

About this term
Level
Basic · Technical terms you often meet in AI news
Added
2026-10-08
In plain words It is similar to preparing a packet of materials for a presenter before a meeting. The presenter can answer properly only if everything needed is included, useless material is left out, and important material is placed up front.

How it works

Apart from the knowledge it learned in training, an LLM answers based only on the text it receives as input right now (the context). But there is a limit to how much it can see at once (the context window). So there is a step of selecting, condensing and arranging what is needed from materials such as instructions and questions, previous conversation history, documents found through RAG, and tool outputs. For example, old conversation is summarized, only relevant documents are included, and tool descriptions are added only when needed. The context prepared this way is passed to the model to get an answer.

How context is builtInstructions · question → Select · summarize · arrange; Conversation history → Select · summarize · arrange; Retrieved documents → Select · summarize · arrange; Tool results → Select · summarize · arrange; Select · summarize · arrange → Context window(Fit in); Context window → LLM; LLM → AnswerInstructions ·questionConversationhistoryRetrieveddocumentsTool resultsSelect · summarize· arrangeContext windowLimited spaceLLMAnswerFit in
How context is built From the materials on the left, only what is needed is selected, condensed and arranged to fit into the limited context window, and the model then answers based on it.

Why it matters

Even with the same model, results vary greatly depending on what information it is shown. AI agents that carry out multiple steps on their own are a particular case: as a task runs longer, tool results and conversation pile up and the context fills quickly. Include too much, and costs rise and important information gets buried. Include too little, and the model may make up things it does not know, which is hallucination. As a result, attention has broadened from writing a single good instruction to designing the whole way information is fed to the model.

Good to know

It overlaps heavily with prompt engineering. Where prompt engineering focuses on writing the instructions well, context engineering covers all the information the model sees, including the instructions. There is no fixed formula; it is tuned through experimentation for each task. A longer context window does not mean putting everything in solves the problem. It is known that the longer the input, the more likely information in the middle is missed.

Example

When a coding agent receives a user request, it does not load the entire repository but finds and reads only the relevant files. It also includes the project's rules file, and when the conversation gets long, it summarizes the earlier part to free up space. A customer support chatbot likewise picks only that customer's information, relevant FAQ documents and recent inquiry history before generating an answer.

Related terms