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:

  1. Establishes a REPL environment (external memory)
  2. Provides a sub_RLM() function (recursion primitive)
  3. 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 ArchitectureRLM Prompt-Defined Architecture
Fixed context windowUnbounded via REPL variable
Single forward passIterative REPL loop
Verbalized reasoningCode execution + recursive calls
Human-designed toolsLLM writes its own tools (Python)
Sub-agents as separate promptssub_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 DimensionRLM Behavior
Input length10M+ tokens (100× context window)
Output lengthUnbounded (built in REPL variables)
Semantic workΩ(|P|) to Ω(|P|²) via recursive loops
CostSublinear in input length; comparable to baselines
Model sizeWorks on 8B after fine-tuning; stronger on frontier models

Prompt Engineering Principles Demonstrated

  1. Externalize context, don’t compress it — Give the LLM a handle (prompt variable) to arbitrarily large data. Let it decide what to read.

  2. Recursion > Iteration — sub_RLM enables the LLM to spawn unbounded parallel/sequential sub-processes. A fixed tool set (Search, Read, Write) caps parallelism.

  3. Code as the action space — Python is more expressive than any fixed tool schema. The LLM can write loops, conditionals, data structures, algorithms.

  4. 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.

  5. Explicit termination — Final variable is a clean contract. No “stop token” heuristics needed.

Comparison to Other Prompt-Level Scaling

ApproachMechanismLimitation
Chain-of-ThoughtVerbalize reasoning stepsOutput length bounded
Tree-of-ThoughtsSearch over reasoning pathsExponential prompt growth
Prompt ChainingFixed pipeline of promptsRigid, human-designed
Recursive Prompting (RLM)LLM writes code that calls itselfUnbounded, 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:

…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

  1. Minimal prompt for RLM behavior — Can the 800-token prompt be compressed? What’s the irreducible core?

  2. Cross-task transfer — Does an RLM prompt tuned for code repos work for legal docs? Scientific literature?

  3. Guardrail prompts — How to add cost/safety bounds in the prompt (e.g., “max 50 sub_RLM calls”, “max $5”)?

  4. Prompt caching interaction — The prompt variable changes each REPL turn. Does this defeat prompt caching?

  5. Non-code RLMs — Can the pattern work with a DSL instead of Python? With a restricted sandbox?

Sources

1

Footnotes

  1. raw/prompts/articles/recursive-language-models-arxiv-2512-24601v3.md ↩