Recursive Language Models Meet Uncertainty: The Surprising Effectiveness of Self-Reflective Program Search for Long Context

Keivan Alizadeh, Parshin Shojaee, Minsik Cho, Mehrdad FarajtabararXiv 2026

TL;DR

While Recursive Language Models (RLMs) successfully handle long contexts by writing programs to query text, their performance is bottlenecked by how they select these program trajectories. This paper introduces SRLM (Self-Reflective Program Search for Long Context), a framework that uses three intrinsic uncertainty signals—self-consistency, verbalized confidence, and reasoning trace length—to select optimal execution paths. The surprising takeaway? Explicit recursion isn't the primary driver of RLM success; a simple, uncertainty-guided program search without any recursive sub-calls often performs better, yielding up to a 22% accuracy boost.

What Problem Does This Paper Address?

Even as modern LLMs boast massive context windows spanning millions of tokens, they still struggle to reliably extract and reason over information across long horizons. They get distracted by irrelevant text or simply "lose track" of details in the middle of a prompt.

To combat this, recent state-of-the-art approaches like Recursive Language Models (RLMs) offload the context into an external programming environment (a REPL). Instead of reading the whole text at once, the LLM generates programs to slice, query, and recursively analyze chunks of the context. However, RLM relies on fixed, heuristic recursion schemes. If the model generates multiple potential programming paths (trajectories), it has no principled way to evaluate which path is best under uncertainty. SRLM addresses this trajectory selection bottleneck.

Methods

SRLM augments programmatic context interaction with an uncertainty-aware self-reflection mechanism. Instead of executing a single fixed path, SRLM samples $K$ candidate programs independently and uses three complementary, training-free uncertainty signals to select the best one:

  1. Sampling-based Uncertainty (Self-Consistency): It groups the candidate programs by their final answers and retains only the subset belonging to the plurality (most common) answer.
  2. Semantic Uncertainty (Verbalized Confidence): The model is prompted to output a structured confidence score (e.g., {"confidence": 95.5}) at each intermediate step. These scores are normalized and aggregated in log-space across the full trace.
  3. Behavioral Uncertainty (Reasoning Length): SRLM tracks the total token length of the generated reasoning trace. Intuitively, when a model is uncertain, it tends to overthink and generate longer, more verbose traces, whereas confident reasoning is concise.

Finally, SRLM combines verbalized confidence ($VC(p)$) and trace length ($Len(p)$) into a joint uncertainty score:
$$s(p) = VC(p) \cdot Len(p)$$
The program with the highest score (closest to zero, penalizing low confidence and excessive length) is selected for the final prediction.

Overview of the SRLM framework showing uncertainty-guided program search and REPL interaction.

Datasets

The authors evaluated SRLM across three diverse long-context benchmarks:

  • BrowseComp+ (1K): A multi-hop QA benchmark designed for deep research agents, requiring information synthesis across 1,000 offline documents (6M–11M tokens).
  • OOLONG: A synthetic benchmark requiring large-scale information aggregation and transformation, evaluated across context lengths from 1K up to 4M tokens.
  • LongBench-v2: A comprehensive multitask benchmark. While prior work only tested the CodeQA subset, this paper evaluates the full suite, including single/multi-document QA, long in-context learning, dialogue history understanding, and structured data QA.

Key Insights and Ideas

  • Recursion is a Myth: The core mechanism of RLMs—explicitly making recursive model sub-calls—is not the primary driver of performance. Programmatic interaction with the context matters most, and guiding that interaction via self-reflection is far more powerful than adding layers of recursion.
  • SRLM Without Sub-calls Wins: Disabling recursive sub-calls entirely (SRLM (no sub-calls)) often beats standard recursive RLM, especially on stronger backbone models like GPT-5, while saving significant wall-clock time and API costs.
  • Robustness Across Short and Long Contexts: Standard RLM actually degrades performance compared to a base LLM when the text fits within the model's native context window (<131K tokens) due to unnecessary recursive overhead. SRLM remains robust, delivering consistent gains across both short and long contexts.
Figure 2: Performance across context lengths on OOLONG and LongBench-v2 Full datasets: Line plots show accuracy of SRLM, RLM, and the base LLM across context from thousands to millions of tokens using GPT-5 (left) and Qwen3-Coder-480B (right) backbones. Bar plots show the average performance gain over the base model, separated into contexts within (<131K) and near/beyond (≥131K) the native context window.
  • Semantic vs. Heuristic Tasks: Heuristic program search works well for structured code repositories, but fails on semantically intensive tasks like document QA or dialogue history. SRLM's uncertainty signals provide a high-level semantic steering mechanism that helps the model adapt to these complex reasoning tasks.

Key Results

SRLM consistently outperformed all baselines across different datasets and backbone models (Qwen3-Coder-480B and GPT-5):

  • BrowseComp+ (1K): SRLM achieved a massive 22.6% absolute accuracy improvement over RLM using the Qwen3 backbone (jumping from 37.1% to 59.7%).
  • GPT-5 Enhancements: On LongBench-v2 (CodeQA), standard RLM scored 59.5%. SRLM (no sub-calls) pushed this to 74.1%, demonstrating that removing explicit recursion and focusing on self-reflective search yields superior results.
  • OOLONG (131K): SRLM achieved 65.5% accuracy with GPT-5, outperforming RLM's 53.0%.

Limitations and Future Work

While highly effective, SRLM currently relies on a relatively simple formulation of self-reflection based on three specific uncertainty proxies. The authors note that future work could explore richer, more dynamic forms of intrinsic self-reflection. Additionally, integrating these uncertainty signals directly into the model's decision-making loop could allow for early termination—stopping the program search early if a high-confidence, concise path is found, thereby optimizing token usage and inference costs.

Summary updated

BibTeX
@misc{alizadeh2026recursive,
  author = {Keivan Alizadeh and Parshin Shojaee and Minsik Cho and Mehrdad Farajtabar},
  title = {{Recursive Language Models Meet Uncertainty: The Surprising Effectiveness of Self-Reflective Program Search for Long Context}},
  year = {2026},
  eprint = {2603.15653},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.15653},
}
Figure