Recursive Language Models
Summary
Store a huge prompt as a variable in a code sandbox and let the model inspect it with code and call sub-models on pieces, instead of reading it all at once. Authors report handling 10M+ token inputs and beating compaction, retrieval and coding-agent baselines on four long-context benchmarks at similar median cost; small eval sets, cost outliers.
When to apply
- Input far larger than the context window (whole repos, document dumps, logs, long agent traces).
- Information-dense tasks where every chunk matters (aggregation, pairwise comparisons) — where summarise/compact or top-k retrieval drops needed details (§1, §4 Obs. 2).
- Not worth it for small inputs: the paper says the RLM only consistently beats GPT-5 beyond ~2^14 tokens (§4 Obs. 3).
Procedure
- Ask user for max spend / max sub-calls and permission to run code in a sandbox.
- Put the full input in a REPL variable (e.g.
context); give the root model only metadata (length, format, a short peek). - Root model writes code: inspect structure (regex, splitting), choose slices.
- For semantic work per slice, call a sub-LLM programmatically from code (loop/map over chunks) rather than verbalising each call; store outputs in variables.
- Aggregate results in code; return final answer. Depth 1 (sub-calls are plain LLMs) is what most experiments use.
- Guardrails: hard cap on number/cost of sub-calls and wall-clock; log trajectory. Reference implementation: github.com/alexzhang13/rlm.
Costs and limits
- Median run cheaper than base model, but mean is higher due to outlier trajectories (§4 Obs. 4). Risk of "exploding sub-call costs" (§7 Limitations).
- Runtime numbers depend heavily on implementation; sequential sub-calls are slow (§4 Obs. 4).
- On CodeQA with Qwen3-Coder, depth=0 (REPL, no sub-calls) beat sub-calling variants — recursion is not always helpful (§4 Obs. 2).
- Guardrails and harder natural tasks under-explored; more negatives in Appendix B (§7).
Evidence (detail)
- Median gains on GPT-5 across benchmarks: +26% vs compaction, +130% vs CodeAct with sub-calls, +13% vs Claude Code (Abstract).
- OOLONG: RLM(depth=1) beats base model by 28.4% (GPT-5) and 33.3% (Qwen3-Coder-480B) (§4 Obs. 1).
- OOLONG-Pairs (quadratic): base models F1 ≤0.1%; RLM 58.0% (GPT-5) and 23.1% (Qwen3-Coder) (§4 Obs. 1).
- BrowseComp-Plus 1K docs (6–11M tokens): RLM(GPT-5) avg cost $0.99, >29% better than compaction and retrieval baselines; extrapolated GPT-5-mini direct ingestion would be $1.50–2.75 (§4 Obs. 1, Table 1).
- LongCoT-mini: RLM with decomposition hints +69.5% over GPT-5.2 base overall (§4 Obs. 5, Table 2).
- RLM-Qwen3-8B (post-trained) beats Qwen3-8B by median 28% (Abstract; Obs. 6).
- Benchmarks: S-NIAH (50 tasks), BrowseComp-Plus (150 q), OOLONG trec_coarse (50), OOLONG-Pairs (20 q), LongBench-v2 CodeQA (§3.1) — small eval sets.
Facts
- id: F1 claim: Recursive LMs load the long input into a REPL variable and let the root model write code to slice it and recursively call sub-LLMs over chunks. confidence: medium # single source: author-reported results date: 2026-10-14 sources: [S1 Abstract] license: CC BY 4.0
- id: F2 claim: Reported to handle inputs over 10x beyond the context window (10M+ tokens). confidence: medium # single source: author-reported results date: 2026-10-14 sources: [S1 Abstract] license: CC BY 4.0
- id: F3 claim: With GPT-5, median gains reported: +26% vs compaction, +130% vs CodeAct with sub-calls, +13% vs Claude Code. confidence: medium # single source: author-reported results date: 2026-10-14 sources: [S1 Abstract] license: CC BY 4.0
- id: F4 claim: On OOLONG-Pairs, base models score F1 ≤0.1% while RLM reaches 58.0% (GPT-5) and 23.1% (Qwen3-Coder). confidence: medium # single source: author-reported results date: 2026-10-14 sources: [S1 §4 Obs. 1] license: CC BY 4.0
- id: F5 claim: A post-trained RLM-Qwen3-8B beats Qwen3-8B by a median 28%. confidence: medium # single source: author-reported results date: 2026-10-14 sources: [S1 Abstract; Obs. 6] license: CC BY 4.0
- id: F6 claim: RLM only consistently beats GPT-5 for inputs beyond about 2^14 tokens. confidence: medium # single source: author-reported results date: 2026-10-14 sources: [S1 §4 Obs. 3] license: CC BY 4.0
- id: F7 claim: Median cost is below the base model but mean cost is higher due to outlier trajectories; sub-call costs can explode. confidence: medium # single source: author-reported results date: 2026-10-14 sources: [S1 §4 Obs. 4; §7] license: CC BY 4.0
- id: F8 claim: Recursion is not always helpful: on CodeQA with Qwen3-Coder, the REPL without sub-calls beat sub-calling variants. confidence: medium # single source: author-reported results date: 2026-10-14 sources: [S1 §4 Obs. 2] license: CC BY 4.0
Related
- 2510.26493 Context Engineering 2.0 (context management framing).
- CodeAct, Claude Code, compaction baselines (compared in Table 1).
- 2610.10310 RSIGym (harness-level improvement).
Review notes
- Built from private assessment notes; social-media hype check and source-post links omitted. All content is paraphrase; no verbatim quotes.
- Figures not re-checked against the PDF in this pass beyond the original private notes.
Source: https://arxiv.org/abs/2512.24601 · License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Source: Alex L. Zhang, Tim Kraska, Omar Khattab, \"Recursive Language Models\" (CC BY 4.0).
For language models and agents: start at /llms.txt. This page in Markdown: /library/reference/arxiv/2512-24601-recursive-language-models.md.