MIT's Open-Source RLM Library Lets AI Tackle Infinite Contexts With Recursion

MIT OASYS lab releases rlm, an open-source Python library that lets any LLM recursively call itself to process inputs of virtually unlimited length

·
·
·
MIT's Open-Source RLM Library Lets AI Tackle Infinite Contexts With RecursionPRO
  • What it is: alexzhang13/rlm is an open-source Python library from MIT OASYS that wraps any LLM in a recursive execution loop.
  • Core idea: Instead of stuffing long inputs into the context window, RLMs treat the prompt as a variable in a REPL that the model can inspect and recursively call itself over.
  • Install instantly: pip install rlms — supports OpenAI, Anthropic, local models via vLLM, and sandboxes including Docker, Modal, and e2b.
  • Benchmark results: RLM(GPT-5) scored 91.33% on BrowseComp-Plus (6–11M token inputs) while vanilla GPT-5 scored 0%; RLM-Qwen3-8B beats base Qwen3-8B by 28.3% on average.
  • Training included: The repo ships a full RL training harness so you can fine-tune your own natively recursive model and plug it into the inference engine.
  • Ecosystem traction: DSPy, Google ADK, Symbolica, and Daytona have already integrated or re-implemented the RLM pattern.

Context windows are a hard ceiling that every LLM application eventually hits. The MIT OASYS lab's answer is not a bigger window , it's a different abstraction entirely. They've released alexzhang13/rlm, an open-source Python inference library that wraps any LLM in a recursive execution loop, letting the model programmatically inspect, decompose, and delegate over arbitrarily long inputs. The repo has already crossed 5,000 stars and 840 forks, and the idea is spreading fast.

The core idea: prompts as objects, not tokens

RLMs are a task-agnostic inference paradigm that enables LMs to handle near-infinite length contexts by programmatically examining, decomposing, and recursively calling themselves over their input. They replace the canonical llm.completion(prompt, model) call with an rlm.completion(prompt, model) call, offloading the context as a variable in a REPL environment that the LM can interact with and launch sub-LM calls inside of.

The mental model shift is significant. In a normal LLM call, the prompt is text inside the model's temporary memory. In an RLM, the prompt is an object , it can be indexed, split, transformed, and passed by reference through a program. The root model is no longer asked to memorize everything; it is asked to decide how to inspect and delegate.

Frontier LLMs suffer from "context rot" where performance degrades on long inputs, and existing compaction methods lose critical details needed for information-dense tasks. The RLM library is a direct attack on that problem, and it works with models you already have access to.

Line graphs comparing GPT-5 and RLM(GPT-5) performance across long-context tasks, showing performance degradation in GPT-5 versus maintained performance with RLM

What the library actually gives you

The repository provides an extensible inference engine for using RLMs around standard API-based and local LLMs. It's installable in one line and designed to be a drop-in replacement for standard completion calls:

code
pip install rlms

From there, usage is straightforward:

Pro article

This story is for Pro members

You've reached the end of the free preview. Upgrade to AlphaSignal Pro to read the full article - and everything else behind the paywall.

Trending
  • No trending articles

Comments

avatar

Next Reads