Recursive language models (RLMs) address context rot in AI agents by having the model write code that dispatches subagents over chunks of input rather than processing everything in one context window. LangChain has implemented this pattern in Deep Agents via dynamic subagents and a lightweight QuickJS code interpreter. Instead of turn-by-turn tool calls, the orchestrator writes a script that fans out work using patterns like map/reduce, guaranteeing deterministic coverage and enabling bespoke branching pipelines. Benchmarks on the OOLONG long-context reasoning task show the approach holds up at 128k tokens where plain agents fail outright. Setup requires installing the QuickJS middleware and passing CodeInterpreterMiddleware to create_deep_agent.

7m read timeFrom langchain.com
Post cover image
Table of contents
The Case for RLMsHow RLMs work in Deep AgentsBenchmarking with OOLONGGet started in Deep AgentsConcluding thoughts