← all repositories
alexzhang13/rlm

Recursive inference for LLMs that write their own subroutines

RLM exists to let language models handle near-infinite contexts by giving them a REPL where they can recursively call themselves as functions, replacing rigid JSON tool-calling with programmable decomposition.

rlm
Velocity · 7d
+5.9
★ / day
Trend
accelerating
star history

What it does

RLM wraps standard LLM APIs in a programmable harness. Instead of a flat prompt, the model receives a REPL—local Python, IPython, Docker, or cloud sandboxes like Modal and E2B—where the input context is a code variable and the model can spawn further completions by calling functions. The repository also bundles a reinforcement-learning training environment built on verifiers and prime-rl to teach models how to wield this recursion.

The interesting bit

The authors want LLMs to abandon JSON tool-calling and treat sub-agents as ordinary functions inside a real code environment. By handing decomposition and recursive execution to the model itself, the system effectively turns the LLM into its own scheduler rather than a passive text generator.

Key highlights

  • Supports a wide range of sandboxes: local exec, IPython, Docker, Modal, Prime Intellect, Daytona, and E2B.
  • Plugs into major API providers and router platforms (OpenAI, Anthropic, OpenRouter, Portkey).
  • Includes a training environment for RLMs with a worked long-context QA example (oolong).
  • Already adopted by downstream projects like DSPy and Ax.

Caveats

  • The default local REPL runs via exec in the host process and shares its virtual environment; the README explicitly warns this is “not for production.”
  • Prime Intellect Sandboxes are currently in beta and suffer from slow runtimes.
  • The training harness deliberately avoids cloud sandboxes for simplicity, so you’ll need to wire in isolation yourself if you want safe distributed training.

Verdict

Worth a look if you’re building agentic systems and tired of shuffling JSON schemas between model calls. Skip it if you just need a standard chat completion wrapper with no appetite for sandboxing or recursive control flow.

Frequently asked

What is alexzhang13/rlm?
RLM exists to let language models handle near-infinite contexts by giving them a REPL where they can recursively call themselves as functions, replacing rigid JSON tool-calling with programmable decomposition.
Is rlm open source?
Yes — alexzhang13/rlm is open source, released under the MIT license.
What language is rlm written in?
alexzhang13/rlm is primarily written in Python.
How popular is rlm?
alexzhang13/rlm has 5.3k stars on GitHub and is currently accelerating.
Where can I find rlm?
alexzhang13/rlm is on GitHub at https://github.com/alexzhang13/rlm.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.