Workflow
Context Engineering for Agents
LangChainยท2025-07-02 15:54

Context Engineering Overview - Context engineering is defined as the art and science of filling the context window with the right information at each step of an agent's trajectory [2][4] - The industry categorizes context engineering strategies into writing context, selecting context, compressing context, and isolating context [2][12] - Context engineering is critical for building agents because they typically handle longer contexts [10] Context Writing and Selection - Writing context involves saving information outside the context window, such as using scratch pads for note-taking or memory for retaining information across sessions [13][16][17] - Selecting context means pulling relevant context into the context window, including instructions, facts, and tools [12][19][20] - Retrieval-augmented generation (RAG) is used to augment the knowledge base of LLMs, with code agents being a large-scale application [27] Context Compression and Isolation - Compressing context involves retaining only the most relevant tokens, often through summarization or trimming [12][30] - Isolating context involves splitting up context to help an agent perform a task, with multi-agent systems being a primary example [12][35] - Sandboxing can isolate token-heavy objects from the LLM context window [39] Langraph Support for Context Engineering - Langraph, a low-level orchestration framework, supports context engineering through features like state objects for scratchpads and built-in long-term memory [44][45][48] - Langraph facilitates context selection from state or long-term memory and offers utilities for summarizing and trimming message history [50][53] - Langraph supports context isolation through multi-agent implementations and integration with sandboxes [55][56]