Offloading Context
Search documents
How Agents Use Context Engineering
LangChain· 2025-11-12 16:36
Context Engineering Principles for AI Agents - The industry recognizes the increasing task length AI agents can perform, with task length doubling approximately every seven months [2] - The industry faces challenges related to context rot, where performance degrades with longer context lengths, impacting cost and latency [3][4] - Context engineering, involving offloading, reducing, and isolating context, is crucial for managing context rot in AI agents [8][9][10] Context Offloading - Giving agents access to a file system is beneficial for saving and recalling information during long-running tasks and across different agent invocations [11][15][18] - Offloading actions from tools to scripts in a file system expands the agent's action space while minimizing the number of tools and instructions [19][22] - Progressive disclosure of actions, such as with Claude skills, saves tokens by selectively loading skill information only when needed [26][30] Context Reduction - Compaction, summarization, and filtering are techniques used to reduce context size and prevent excessively large tool results from being passed to the language model [32][33][39] - Manis compacts old tool results by saving them to a file and referencing the file in the message history [34] - Deep agents package applies summarization after a threshold of 170,000 tokens [38] Context Isolation - Context isolation, using separate context windows or sub-agents for individual tasks, helps manage context and improve performance [10][39][40] - Sub-agents can have shared context with the parent agent, such as access to the same file system [42] Tool Usage - Agent harnesses often employ a minimal number of general, atomic tools to save tokens and minimize decision-making complexity [44] - Cloud code uses around a dozen tools, Manis uses less than 20, and the deep agent CLI uses 11 [24][25][44]