LangChain explains how Deep Agents use five techniques to manage context
A LangChain blog post explains how its open-source agent harness Deep Agents addresses "context rot," where instructions, tool results and files accumulate during long tasks until they exceed the model's context window and degrade accuracy and reasoning. It describes five techniques: offloading large tool results to the filesystem, summarizing older messages as usage nears the limit, loading skills on demand, isolating noisy work in subagents, and storing long-term memory as a plain file. LangChain says that memory lives in storage the user controls, so the agent can switch models or providers while keeping what it has learned, and that thresholds and middleware behavior are configurable.
The post details concrete mechanisms — file offloading, summarization thresholds, subagents and file-based memory — that agent builders can reuse even outside Deep Agents.
Key Takeaways
- "Context rot" happens as long-running agents build up more context than the model can hold, resulting in accuracy drops.
- Deep Agents, LangChain's open source agent harness, uses five techniques to move context out of the active window (without deleting it) to prevent context rot.
- An agent's memory in Deep Agents is stored as plain files in storage you control, so you can switch models or providers while keeping everything it has learned.
If you've ever crammed for an exam the night before, you know the feeling: the more you study, the more the early chapters start to slip.
Agents have the same problem. As they take on longer tasks, they take on more and more information (instructions, tool results, files etc.); eventually this becomes far too much context to comfortably fit in a model's context window. The more history, noise, and tool output a model carries, the worse its accuracy and reasoning tend to get.
In the world of agent engineering, we call this context rot. This blog covers techniques to manage your agent’s context window and how the Deep Agents harness uses a concept called middleware to inject them into your agent’s run.