Inference-Time Scaling via Prompt Design
The Recursive Language Models paper demonstrates that inference-time compute scaling (previously achieved via architectural changes like reasoning models, or scaffolding like CodeAct) can be achieved purely through prompt design — by giving an LLM a REPL environment and a recursion primitive.
The Insight
Traditional inference-time scaling methods:
- Reasoning models (o1, DeepSeek-R1): Train-time modification, hidden chain-of-thought
- CodeAct / ReAct agents: Scaffold with tools, but prompt stays in context window
- Compaction agents: Scaffold with summarization, lose information
RLMs achieve scaling via a system prompt alone. The prompt:
- Establishes a REPL environment (external memory)
- Provides a
sub_RLM()function (recursion primitive) - Instructs the LLM to write code instead of text (symbolic manipulation)
No model modification. No specialized scaffolding code. The prompt is the architecture.
Prompt as Architecture Definition
| Traditional Architecture | RLM Prompt-Defined Architecture |
|---|---|
| Fixed context window | Unbounded via REPL variable |
| Single forward pass | Iterative REPL loop |
| Verbalized reasoning | Code execution + recursive calls |
| Human-designed tools | LLM writes its own tools (Python) |
| Sub-agents as separate prompts | sub_RLM() as recursive self-call |
The RLM system prompt defines a computational model: a universal Turing machine where the LLM is the control unit, the REPL is the tape, and sub_RLM is the subroutine instruction.
Scaling Laws from Paper
| Scaling Dimension | RLM Behavior |
|---|---|
| Input length | 10M+ tokens (100× context window) |
| Output length | Unbounded (built in REPL variables) |
| Semantic work | Ω(|P|) to Ω(|P|²) via recursive loops |
| Cost | Sublinear in input length; comparable to baselines |
| Model size | Works on 8B after fine-tuning; stronger on frontier models |
Prompt Engineering Principles Demonstrated
-
Externalize context, don’t compress it — Give the LLM a handle (
promptvariable) to arbitrarily large data. Let it decide what to read. -
Recursion > Iteration —
sub_RLMenables the LLM to spawn unbounded parallel/sequential sub-processes. A fixed tool set (Search, Read, Write) caps parallelism. -
Code as the action space — Python is more expressive than any fixed tool schema. The LLM can write loops, conditionals, data structures, algorithms.
-
State in the environment, not the context — REPL variables persist across turns. The LLM’s context only needs metadata (lengths, prefixes). This is context engineering via prompt.
-
Explicit termination —
Finalvariable is a clean contract. No “stop token” heuristics needed.
Comparison to Other Prompt-Level Scaling
| Approach | Mechanism | Limitation |
|---|---|---|
| Chain-of-Thought | Verbalize reasoning steps | Output length bounded |
| Tree-of-Thoughts | Search over reasoning paths | Exponential prompt growth |
| Prompt Chaining | Fixed pipeline of prompts | Rigid, human-designed |
| Recursive Prompting (RLM) | LLM writes code that calls itself | Unbounded, adaptive |
Implications for Prompt Engineering
We may be underestimating what prompts can do. The RLM prompt is ~800 tokens but defines a system that processes 10M+ tokens. The leverage ratio is >10,000×.
Prompt design is architecture design. Choosing between:
- Monolithic prompt
- Multi-file agent architecture (multi-file-agent-architecture)
- REPL-based recursive prompt (RLM)
…is choosing a computational model. This is context engineering at the prompt level.
Fine-tuning can internalize prompt patterns. RLM-Qwen3-8B (1,000 samples) learns to be a better RLM without the full prompt — the pattern transfers. This suggests prompt patterns can become model capabilities.
Open Research Questions
-
Minimal prompt for RLM behavior — Can the 800-token prompt be compressed? What’s the irreducible core?
-
Cross-task transfer — Does an RLM prompt tuned for code repos work for legal docs? Scientific literature?
-
Guardrail prompts — How to add cost/safety bounds in the prompt (e.g., “max 50 sub_RLM calls”, “max $5”)?
-
Prompt caching interaction — The
promptvariable changes each REPL turn. Does this defeat prompt caching? -
Non-code RLMs — Can the pattern work with a DSL instead of Python? With a restricted sandbox?
Related Pages
- recursive-language-model-prompt — The system prompt entity
- recursive-language-model — The paradigm concept
- longcot-mini-decomposition-prompt — Reasoning variant
- summary-agent-baseline-prompt — Compaction baseline
- context-engineering-pattern — Related five-type framework
- monolithic-prompt-limits — Problem space
- multi-file-agent-architecture — Alternative architecture
- task-state-machine — Pattern in RLM loop
- code-generation — Enabling capability
Sources
Footnotes
-
raw/prompts/articles/recursive-language-models-arxiv-2512-24601v3.md ↩