How to use RLMs in Deep Agents

Video thumbnail: How to use RLMs in Deep Agents
Jul 1, 20266m 37s video lengthLangChain

The Signal

Recursive Language Models (RLMs) use code-based orchestration—rather than just the model's limited context window—to enable agents to call subagents recursively. While RLMs improve reliability on complex, long-context data tasks, they introduce significant tradeoffs in latency and token cost, creating a performance split that only emerges at high context volumes.

The Case

Mechanism and Motivation

  • Sydney, an engineer at LangChain—a company that builds agent frameworks—defines RLMs as models that use a code interpreter to manage persistent variables and files, effectively bypassing the limitations of a finite internal context window.0:07
  • By offloading work into a task function, the main agent can fan out sub-tasks, aggregate results, and perform deterministic data processing that plain agents fail to execute.2:06
  • The approach is best suited for complex data aggregation, such as the Oolong dataset—a benchmark containing thousands of rows of unlabeled news headlines—where agents must perform multi-stage counting and temporal reasoning.3:38

Performance and Tradeoffs

  • In side-by-side traces, researchers found no meaningful difference between plain agents and RLM-enabled agents at 64,000 tokens, but the RLM-enabled agents performed significantly better at 128,000 tokens.5:14
  • Plain agents frequently hit a performance wall, outputting non-answers or claims of being blocked, whereas RLM agents successfully used recursive workflows to maintain accuracy on harder queries like temporal comparisons.6:03
  • These gains are not free: RLM-enabled workflows consistently exhibit higher latency and token usage, and as Sydney notes, the long-term cost-efficiency of this pattern is not yet established.5:42

The 1 Minute Signal Take

Code-orchestrated recursion is a viable strategy to salvage agent reliability at extreme context lengths, though you should expect a steep cost in both performance speed and compute budget. The superior performance shown at 128k tokens suggests this approach is an effective tool for large-scale data tasks but is likely overkill for simpler, smaller-scale applications.

Pro Analysis

Why It Matters

Technical agents are currently trapped by the 'context window vs. cost' dilemma. By shifting the architecture from a single large query to a code-orchestrated decision tree, we move autonomy from the 'probabilistic layer' (the model) to the 'deterministic layer' (the code). This is the key to scaling agent utility.

Strategic Implications

Businesses deploying agents should move away from expecting a single 'god-model' to handle all data. The RLM pattern signals a shift toward modular architectures where agents function more like developers managing sub-processes rather than single-turn responders.

Evidence & Hype Audit

  • Evidence: The benchmark results at 128k context are compelling, especially regarding the 'I can't answer' failure mode of legacy agents.
  • Hype: The speaker’s claim that RLMs will scale indefinitely as context grows is speculative. The latency penalty could make these systems cost-prohibitive for real-time applications.

Counterarguments

The biggest risk is 'recursion death'—where a mistake in the orchestrating code causes an infinite loop of subagent calls, leading to a massive, unexpected API bill. Relying on the model to write its own orchestration logic introduces a new class of logic bugs that traditional unit testing struggles to catch.

Who Should Care

  • Agent Developers: Use this pattern to solve long-context bottlenecks.
  • Infrastructure Leads: Prepare for higher latency budgets when rolling out RLM-enabled workflows.

What to Do Next

  • Enable 'code mode' via middleware in agent harnesses to kickstart testing.
  • Identify long-context aggregation tasks currently failing under standard prompting.
  • Develop a standard 'task' function interface for subagent communication.
  • Implement circuit breakers to stop recursive loops before token budgets are exhausted.
  • Monitor the ratio of token growth vs. performance gain on your specific datasets.
Time saved:3m 39s

Share this

Tags