Context engineering
Context engineering is the practice of curating what tokens sit in a model's context window during a single agent run.
Category
Industry concept
See all terms
What is context engineering?
Context engineering is the practice of curating and maintaining the right information in a model's context window while it works: the system prompt, the tools it can call, retrieved documents, and the message history so far. It grew out of prompt engineering. Prompt engineering treats the instructions as one artifact to get right once. Context engineering treats the whole window as a resource to manage continuously as an agent works through a task and the window fills with tool calls, retrieved chunks, and its prior output.
The problem it solves is scarcity. A context window is finite, and every extra token in it competes with every other token for the model's attention. An agent that loads full documents, full tool outputs, and the entire conversation history degrades, because the signal drowns in what surrounds it. Context engineering exists to keep the window loaded with only what the model needs for its next step.
How does context engineering differ from the context layer?
Context engineering is different from a context layer: context engineering runs inside a single session, while a context layer feeds context across every session and every agent. Context engineering can only work with what it's given. If the underlying data is fragmented, duplicated, or out of date, no amount of trimming or summarizing inside the session fixes that. A context layer is what determines whether the material entering the window is accurate in the first place.
How does context engineering work?
A handful of techniques carry it out during a run. Just-in-time retrieval keeps lightweight references in context and loads full content only when a step needs it, instead of pre-loading everything. Compaction summarizes the conversation so far and restarts the window with the compressed version, freeing space for new work. Structured note-taking lets an agent write information to a location outside its context window and pull it back in when relevant. Sub-agent architectures hand off narrow pieces of a task to separate agents that work in smaller windows and return a condensed result.
These techniques manage the window an agent has open. None of them touch what happens between sessions: whether the source data was current, deduplicated, or governed by permissions before it reached the window. That part sits with the context repository, which keeps a company's knowledge current so whatever context engineering pulls from it starts out accurate.