# Recursive Language Models for Large Codebases

Shashi, Superagentic AI | AI Engineer World's Fair 2026 | 17:27

Source: https://www.youtube.com/watch?v=8oyalrfwgjw
Channel: AI Engineer (https://www.youtube.com/@aiDotEngineer). Summarised by AIE Talks.
Page: https://aietalks.com/talks/recursive-language-models-for-large-codebases
Published: 2026-07-12
Tags: agents, coding-agents, context-engineering, harness-engineering, multi-agent

## TL;DR
- Recursive Language Models move repository context into a programmable execution environment where the model writes code to inspect and select evidence.
- The model can recursively ask another model focused questions through `llm_query`, then use the answers to continue its investigation.
- RLM Code is an open-source, independent harness that demonstrates this pattern with local and cloud models, sandboxed execution, and inspectable traces.

## Summary
Shashi explains how Recursive Language Models can help coding agents work with large repositories. As repository context grows, agents can lose architecture and perform worse. RLM changes the setup by loading the repository into a programmable REPL, where the model writes code to inspect files, dependencies, tests, and configuration, then passes bounded observations into its main context. When it needs specialist help, it can call another model through `llm_query` and continue the loop. The talk demonstrates RLM Code, an independent open-source harness from Superagentic AI. The demo uses a Docker sandbox and Gemini, showing generated REPL code, evidence, recursive calls, final answers, token information, and JSONL traces. Shashi also describes possible uses such as repository onboarding and root-cause analysis, and argues that similar ideas appear in several coding-agent and managed-agent systems.

## Key ideas
### Large repositories make coding-agent context harder to manage
[00:00](https://www.youtube.com/watch?v=8oyalrfwgjw&t=0s)
Shashi starts with the problem of applying coding agents to large repositories. Agents may work well on smaller repositories, but performance degrades as the context grows. Existing approaches include searching with filesystem tools such as grep, using semantic or local search to curate context, compressing long context into summaries, and storing information in memory systems. These approaches try to control what reaches the model, but the talk proposes moving that context work into a programmable environment.

### RLM externalizes context management into a programmable environment
[01:50](https://www.youtube.com/watch?v=8oyalrfwgjw&t=110s)
The core RLM idea is to treat the full repository as data that the model can operate on outside its main context window. The model writes code in a dedicated REPL to inspect the repository, slice it, and compute relevant chunks. Those bounded observations are then fed into the main context. Shashi describes this as a context-management technique that can also work as a memory layer for coding agents.

### Repository investigation follows the work of a lead engineer
[03:07](https://www.youtube.com/watch?v=8oyalrfwgjw&t=187s)
Shashi compares RLM with how a lead engineer approaches an unfamiliar monorepo. The engineer first inspects structure, dependencies, and notes about the project instead of reading every line. They may write scripts to search the repository, then ask another engineer when something remains unclear. In RLM, the programmable REPL holds the investigative code and notes, while `llm_query` asks another model or environment for a focused answer. The loop ends with a synthesized result.

### Recursive calls let the model delegate focused questions
[04:23](https://www.youtube.com/watch?v=8oyalrfwgjw&t=263s)
The recursive part begins when the model asks another specialist through `llm_query`. The request can contain one question or several questions. The main loop uses the repository as its context, writes REPL code to obtain relevant evidence, and calls another language model when more information is needed. It keeps receiving values and investigating until it can return a final result.

### Codebases require structural reasoning beyond text retrieval
[05:18](https://www.youtube.com/watch?v=8oyalrfwgjw&t=318s)
Shashi chooses codebases because they contain more than a large body of text. A repository has directories, tests, imports, dependencies, images, and configuration files. An agent must reason about how these pieces relate. RLM gives the model a way to inspect that structured data programmatically instead of placing the entire repository directly into the context window.

### RLM Code is a reference harness rather than a new RLM variant
[06:15](https://www.youtube.com/watch?v=8oyalrfwgjw&t=375s)
RLM Code is presented as an open-source research playground from Superagentic AI. Shashi distinguishes the RLM pattern from individual implementations, including the authors' repositories and the implementation in DSPy. RLM Code follows the paper's recursive calls and REPL execution, while allowing users to run local or cloud models, connect an observability framework, and use the pattern with another agent framework.

### The demo exposes the full investigation trajectory
[09:57](https://www.youtube.com/watch?v=8oyalrfwgjw&t=597s)
In the CLI demo, a repository is loaded into a Docker sandbox. The model writes REPL code, builds evidence, calls `llm_query`, and produces a final answer. The interface shows the steps, tool calls, token usage, sessions, and traces. A second experimental coding-agent interface connects to Gemini, accepts a budget and recursion depth, and displays the completed trajectory in a research-lab view.

### RLM can support repository onboarding and root-cause analysis
[15:13](https://www.youtube.com/watch?v=8oyalrfwgjw&t=913s)
Shashi suggests using the pattern when engineers need to understand unfamiliar repositories or investigate a root cause. A custom harness can capture planning, code generation, observations, subcalls, budget, and final output. He also points to reported similarities in coding-agent harnesses, managed agents, dynamic workflows, and software-factory systems, while saying that some of those uses are uncertain.

## Notable quotes
- "Core thesis of the RLM is you need to externalize the context management into programmable execution environment." (01:50)
- "So the codebase is not only just the text, it is a structured data and the model need to understand and reason over the text." (05:18)
- "RLM itself is a concept and a pattern and you can implement that concept and pattern in your own way." (06:50)
- "The good thing is that you can see all these traces in the RLM code repositories." (11:25)

## Tools & references mentioned
- Recursive Language Models (RLM) paper
- MIT
- RLM Code
- DSPy
- RLM Minimal
- Gemini
- Docker
- Superagentic AI
- Anthropic
- Codex
- Claude Code

## Who should watch
- You are building coding agents that lose repository structure as their context grows and want a programmable way to select evidence.
- You need a repository-onboarding or root-cause-analysis workflow that can inspect files and ask focused sub-questions.
- You want to study an open-source reference harness with sandboxed REPL execution, recursive model calls, and visible trajectories.

## Related talks

- [Recursive Coding Agents](https://aietalks.com/talks/recursive-coding-agents) (Raymond Weitekamp, OpenProse, 23:48)
- [Let LLMs Wander: Engineering RL Environments](https://aietalks.com/talks/let-llms-wander-engineering-rl-environments) (Stefano Fiorucci, deepset, 40:35)
- [Training Agentic Reasoners](https://aietalks.com/talks/training-agentic-reasoners) (Will Brown, Prime Intellect, 19:17)
- [RL for Autonomous Coding](https://aietalks.com/talks/rl-for-autonomous-coding) (Aakanksha Chowdhery, Reflection AI, 19:27)
- [Stop Making Models Bigger, Make Them Behave](https://aietalks.com/talks/stop-making-models-bigger-make-them-behave) (Kobie Crawford, Snorkel, 20:56)
