SYNTHESIS NOTE
Topics›Inference time scaling›this note

Can models treat long prompts as external code environments?

Do language models handle vastly longer inputs by offloading context to a Python REPL and querying it programmatically, rather than fitting everything into the transformer's attention window?

Synthesis note · 2026-02-23 · sourced from Inference time scaling

Context rot — quality degradation as context lengthens — affects even frontier models like GPT-5. Extending context windows is an arms race: each increase buys more capacity but doesn't solve the fundamental problem that attention-based processing degrades with length. Recursive Language Models sidestep this entirely by changing where the context lives.

The key insight: long prompts should not be fed into the transformer directly. Instead, they should be treated as part of an external environment that the model can symbolically interact with. In the RLM implementation, the prompt is stored as a variable in a Python REPL. The model reads, filters, chunks, and queries its context through code execution rather than token-space attention.

Two mechanisms make this work:

Model priors enable context filtering without seeing it. The model uses its existing knowledge to construct targeted queries — regex searches for keywords, printing specific line ranges to inspect, narrowing the search space based on task understanding. It doesn't need to attend to 100K tokens to find the relevant 500. This is analogous to how humans skim a long document: prior knowledge guides where to look.

Recursive sub-calls defer unbounded reasoning chains. When the context requires reasoning over multiple chunks, the model spawns sub-RLM calls, each operating on a manageable portion. The decomposition is dynamic — the model decides how to partition based on what it observes, not a predefined chunking strategy.

Results: RLMs handle inputs up to two orders of magnitude beyond model context windows. On shorter prompts (within context limits), RLMs still dramatically outperform base models and common long-context scaffolds including context compaction. The cost is comparable or cheaper per query because the model processes only the relevant portions of context rather than attending to everything.

This connects to Can models precompute answers before users ask questions? as a second reframing of compute allocation: sleep-time asks WHEN to compute (before vs during query); RLMs ask WHERE to keep the data (model's context vs external environment). Both reject the default of "stuff everything into the context window at query time."

Inquiring lines that read this note 28

This note is a source for these research framings, grouped by the broader line of inquiry each explores. Scan the bold lines of inquiry; follow any specific question forward.

What explains the gap between LLM semantic understanding and production? What conversational structures and patterns determine dialogue effectiveness and coherence? Does prompting inject new knowledge into models or activate existing knowledge? Do language models truly understand their encoded knowledge or merely retrieve patterns? What can prompting techniques actually accomplish in language models? How does explicit structure improve LLM reasoning on complex tasks? Does reinforcement learning create new reasoning capabilities or refine existing ones? How can language models effectively manage long-context memory without quality degradation? Do language models learn underlying linguistic structure or merely surface patterns? How should context management strategies balance efficiency with agent reliability? How do different editing strategies affect output quality and agent safety? What makes reasoning models struggle with ill-posed and unfamiliar problems? How does verifier integration affect the generation-verification gap?

Related concepts in this collection 5

This note in its neighbourhood — explore the map, then jump to a related concept in the list below.

Concept map
15 direct connections · 129 in 2-hop network ·medium cluster Open in graph ↗

Click a node to walk · click center to open · click Open in graph to see this note in the full knowledge graph

your link semantically near linked from elsewhere

Related papers in this collection 8

Papers most semantically related to this note, ranked by cosine similarity in the embedding space.

Original note title

recursive language models treat long prompts as external environment enabling programmatic interaction 100x beyond context windows