Skip to content
AI-generated research idea🟡Fairly easy💡Moderate InnovationNo close match found

Enabling Deep Recursion (Depth > 1)

Extend the recursive language model environment with a runtime stack and recursion logic to support deep multi-level sub-calls.

Time

several weeks

Compute level

Single GPU or less

Resources

Standard GPU, existing RLM codebase.

Prerequisites

basic ML knowledge, Python system design.

Scope

modify existing code (runtime and prompts).

The Gap

The experiments in the paper explicitly limit the recursion depth to one level (Section 5: 'we chose to use a max recursion depth of one'). The system prompt warns models against excessive sub-calls.

Limitation

Limiting recursion to a single layer restricts the model's ability to handle truly hierarchical data structures or extremely massive datasets (e.g., >100M tokens) where a single level of chunking is insufficient to reduce data to a manageable context size.

Proposed Solution

Extend the RLM environment to support a recursion stack, allowing sub-LMs to instantiate their own REPL environments and invoke further sub-LMs. This requires implementing stack management in the runtime and refining prompts to prevent infinite recursion loops.

Why This Matters

Unlock the ability to process effectively infinite contexts using divide-and-conquer strategies (logarithmic scaling), essential for processing entire libraries or repositories rather than single documents.

How to Get Started

  1. Review the existing recursive language model execution loop and identify where the single recursion limit is enforced.
  2. Implement a stack data structure in the runtime to manage nested REPL environments and sub-LM state.
  3. Update the system prompts and execution logic to allow sub-LMs to invoke further sub-LMs safely without infinite loops.
  4. Test the deep recursion system on complex hierarchical reasoning tasks and monitor execution correctness.

Code linked to this paper on Hugging Face: github.com/alexzhang13/rlm

Suggested by AI. Adapt it to your setup.

Has This Been Done?

No close match in 10 results

The listed works do not present an RLM environment supporting a recursion stack where sub-LMs instantiate their own REPL environments. Papers like Recursive Multi-Agent Systems explore multi-agent setups, but none implement this specific recursive execution stack for language model runtimes.

We searched OpenAlex for “Extend the recursive language model environment with a runtime stack and recursion logic to support deep multi-level sub-calls.” and “Enabling Deep Recursion (Depth > 1)” and an AI compared the idea with the top 10 results. A small search can miss relevant work.

Source Paper

Recursive Language Models

Alex L. Zhang, Tim Kraska, Omar Khattab · 2025

This paper introduces Recursive Language Models (RLMs), an inference-time scaling strategy that allows Large Language Models to process arbitrarily long inputs by treating the context as an external environment within a Python REPL. Instead of ingesting the full context at once, the model writes code to programmatically access, decompose, and recursively sub-query specific chunks of the data, enabling effective processing of inputs up to 10M+ tokens with competitive costs compared to base models.

Related Ideas

Is this a good idea?

Share onXLinkedIn