|
1 | 1 | # RLM Code |
2 | 2 |
|
3 | | -**RLM Code is a research playground and evaluation OS for recursive language-model (RLM) agentic systems.** |
| 3 | +**Run LLM-powered agents in a REPL loop, benchmark them, and compare results.** |
4 | 4 |
|
5 | | -It helps researchers and engineers build, benchmark, debug, and harden coding and non-coding agents across frameworks, providers, and environments. |
| 5 | +RLM Code implements the [Recursive Language Models](https://arxiv.org/abs/2502.07503) (RLM) paper by Zhang, Kraska & Khattab. Instead of stuffing your entire document into the LLM's context window, RLM stores it as a Python variable and lets the LLM write code to analyze it — chunk by chunk, iteration by iteration. This is dramatically more token-efficient for large inputs. |
6 | 6 |
|
7 | | -- Documentation: https://superagenticai.github.io/rlm-code/ |
| 7 | +RLM Code wraps this algorithm in an interactive terminal UI with built-in benchmarks, trajectory replay, and observability. |
8 | 8 |
|
9 | | -## North Star |
| 9 | +## Install |
10 | 10 |
|
11 | | -RLM Code becomes the default development and evaluation operating system for agentic AI: |
| 11 | +```bash |
| 12 | +uv tool install "rlm-code[tui,llm-all]" |
| 13 | +``` |
12 | 14 |
|
13 | | -- build recursive agents, |
14 | | -- evaluate behavior with reproducible benchmarks, |
15 | | -- improve policies with feedback loops, |
16 | | -- ship safely with observability and governance. |
| 15 | +This installs `rlm-code` as a globally available command with its own isolated environment. You get the TUI and all LLM provider clients (OpenAI, Anthropic, Gemini). |
17 | 16 |
|
18 | | -## Positioning |
| 17 | +Don't have uv? Install it first: |
19 | 18 |
|
20 | | -RLM Code gives researchers and applied teams a unified runtime, benchmark harness, and replayable trajectory system to design, compare, and improve RLM-based agents with evidence. |
| 19 | +```bash |
| 20 | +curl -LsSf https://astral.sh/uv/install.sh | sh |
| 21 | +``` |
21 | 22 |
|
22 | | -Tagline: |
| 23 | +<details> |
| 24 | +<summary>Alternative: install with pip</summary> |
| 25 | + |
| 26 | +```bash |
| 27 | +pip install rlm-code[tui,llm-all] |
| 28 | +``` |
| 29 | +</details> |
23 | 30 |
|
24 | | -**Research fast. Evaluate rigorously. Ship reliable agents.** |
| 31 | +## Quick Start |
25 | 32 |
|
26 | | -## What RLM Code Is |
| 33 | +### 1. Launch |
27 | 34 |
|
28 | | -- A runtime + eval + policy loop platform. |
29 | | -- A CLI/TUI wedge for fast local iteration. |
30 | | -- A framework-agnostic control plane. |
31 | | -- A research-to-production bridge. |
| 35 | +```bash |
| 36 | +mkdir -p ~/my-project && cd ~/my-project |
| 37 | +rlm-code |
| 38 | +``` |
32 | 39 |
|
33 | | -## What RLM Code Is Not |
| 40 | +This opens the terminal UI. You'll see a chat input at the bottom and tabs across the top. |
34 | 41 |
|
35 | | -- Not another monolithic agent framework. |
36 | | -- Not tied to one provider, one model, or one orchestration stack. |
37 | | -- Not limited to coding-only agents. |
| 42 | +### 2. Connect to an LLM |
38 | 43 |
|
39 | | -## Who It Is For |
| 44 | +Type one of these in the chat input: |
40 | 45 |
|
41 | | -- Agent researchers developing reward/memory/policy improvements. |
42 | | -- Applied AI engineers shipping coding/support/ops agents. |
43 | | -- Platform teams enforcing reliability and regression gates. |
44 | | -- Open-source builders creating framework and benchmark plugins. |
| 46 | +``` |
| 47 | +/connect anthropic claude-opus-4-6 |
| 48 | +``` |
45 | 49 |
|
46 | | -## Problems It Solves |
| 50 | +or |
47 | 51 |
|
48 | | -- Agent evaluation is fragmented across frameworks/providers. |
49 | | -- Failures are hard to diagnose without replayable trajectories. |
50 | | -- Agent regressions are easy to ship without CI-style gates. |
51 | | -- Research ideas are hard to compare in reproducible conditions. |
| 52 | +``` |
| 53 | +/connect openai gpt-5.3-codex |
| 54 | +``` |
52 | 55 |
|
53 | | -## Product Pillars |
| 56 | +or |
54 | 57 |
|
55 | | -### 1) RLM Code Core |
| 58 | +``` |
| 59 | +/connect gemini gemini-2.5-flash |
| 60 | +``` |
56 | 61 |
|
57 | | -Model-agnostic recursive runtime (`plan -> act -> observe -> reward -> memory`) with safe execution primitives. |
| 62 | +or for a free local model via [Ollama](https://ollama.com/): |
58 | 63 |
|
59 | | -### 2) RLM Code Bench |
| 64 | +``` |
| 65 | +/connect ollama llama3.2 |
| 66 | +``` |
60 | 67 |
|
61 | | -Standard benchmark packs, replayable trajectories, and CI regression gates (`run`, `compare`, `validate`). |
| 68 | +> You need the matching API key in your environment (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`) or in a `.env` file in your project directory. Ollama needs no key — just a running Ollama server. |
62 | 69 |
|
63 | | -### 3) RLM Code Labs |
| 70 | +Check it worked: |
64 | 71 |
|
65 | | -Pluggable experimentation for reward shaping, memory policies, and algorithmic research. |
| 72 | +``` |
| 73 | +/status |
| 74 | +``` |
66 | 75 |
|
67 | | -### 4) RLM Code Ops |
| 76 | +### 3. Run your first RLM task |
68 | 77 |
|
69 | | -Tracing, artifacts, model routing, rollout checks, and integration points for tools like MLflow. |
| 78 | +``` |
| 79 | +/rlm run "Write a Python function that finds the longest common subsequence of two strings" |
| 80 | +``` |
70 | 81 |
|
71 | | -### 5) RLM Code Hub (Roadmap) |
| 82 | +This starts the RLM loop: the LLM writes code in a sandboxed REPL, executes it, sees the output, writes more code, and iterates until it calls `FINAL(answer)` with the result. |
72 | 83 |
|
73 | | -Shareable benchmark packs, policies, and reproducible runs. |
| 84 | +### 4. Run a benchmark |
74 | 85 |
|
75 | | -## Interoperability |
| 86 | +Benchmarks let you measure how well a model performs on a set of tasks: |
76 | 87 |
|
77 | | -RLM Code is designed to sit around existing frameworks and coding agents, not replace them. |
| 88 | +``` |
| 89 | +/rlm bench preset=pure_rlm_smoke |
| 90 | +``` |
78 | 91 |
|
79 | | -### Agent Frameworks |
| 92 | +This runs 3 test cases through the RLM loop and scores the results. |
80 | 93 |
|
81 | | -Use framework adapters for DSPy, Pydantic AI, Google ADK, and others so you can: |
| 94 | +See all available benchmarks: |
82 | 95 |
|
83 | | -- run consistent benchmarks across frameworks, |
84 | | -- replay trajectories for debugging, |
85 | | -- apply the same reward/eval pipeline without rewriting framework code. |
| 96 | +``` |
| 97 | +/rlm bench list |
| 98 | +``` |
86 | 99 |
|
87 | | -### Coding Agents and Model Providers |
| 100 | +### 5. View results |
88 | 101 |
|
89 | | -Use ACP/BYOK/local providers and route work to specialized models while RLM Code keeps control of: |
| 102 | +``` |
| 103 | +/leaderboard |
| 104 | +``` |
90 | 105 |
|
91 | | -- execution safety, |
92 | | -- verification, |
93 | | -- benchmark gating, |
94 | | -- observability. |
| 106 | +Shows a table of all your benchmark runs ranked by reward score. |
95 | 107 |
|
96 | | -## Quick Start |
| 108 | +### 6. Replay a session step-by-step |
97 | 109 |
|
98 | | -```bash |
99 | | -pip install --upgrade rlm-code |
100 | | -rlm-code |
| 110 | +``` |
| 111 | +/rlm replay |
101 | 112 | ``` |
102 | 113 |
|
103 | | -Inside TUI mode: |
| 114 | +Walk through the last run one step at a time — see what code the LLM wrote, what output it got, and what it did next. |
104 | 115 |
|
105 | | -```text |
106 | | -/model # Interactive model selection |
107 | | -/connect <provider> <model> # Direct model connection |
108 | | -/init # Initialize project context |
109 | | -/examples # Browse/generate templates |
110 | | -/validate # Validate generated or existing code |
111 | | -/optimize # Run optimization workflows |
112 | | -/status # Session state |
113 | | -``` |
| 116 | +## How the RLM Loop Works |
114 | 117 |
|
115 | | -Evaluation-first workflow: |
| 118 | +Traditional LLM usage: paste your document into the prompt, ask a question, hope the model doesn't lose details in the middle. |
116 | 119 |
|
117 | | -```text |
118 | | -/rlm import-evals pack=pydantic_time_range_v1 |
119 | | -/rlm run "<task>" framework=dspy steps=4 |
120 | | -/rlm run "<task>" framework=pydantic-ai steps=4 |
121 | | -/rlm run "<task>" framework=google-adk steps=4 |
122 | | -/rlm bench list |
123 | | -/rlm bench preset=dspy_quick framework=dspy |
124 | | -/rlm bench validate candidate=latest baseline=previous --json |
125 | | -/rlm bench compare candidate=latest baseline=previous |
126 | | -``` |
| 120 | +RLM approach: |
127 | 121 |
|
128 | | -Recursive controls: |
| 122 | +1. Your document is stored as a Python variable `context` in a REPL |
| 123 | +2. The LLM writes code to process it (e.g., `len(context)`, `context[:5000]`, `context.split('\n')`) |
| 124 | +3. The code runs, and the LLM sees the output |
| 125 | +4. The LLM writes more code based on what it learned |
| 126 | +5. Repeat until the LLM calls `FINAL("here is my answer")` |
129 | 127 |
|
130 | | -```text |
131 | | -/rlm run "<task>" depth=3 children=4 parallel=2 budget=120 |
132 | | -``` |
| 128 | +This means the LLM can handle documents much larger than its context window, because it reads them in chunks through code rather than all at once through the prompt. |
133 | 129 |
|
134 | | -## Research and Production Packaging |
| 130 | +## Key Commands |
135 | 131 |
|
136 | | -The repository is organized to support two audiences without mixing concerns: |
| 132 | +| Command | What it does | |
| 133 | +|---------|-------------| |
| 134 | +| `/connect <provider> <model>` | Connect to an LLM | |
| 135 | +| `/model` | Interactive model picker | |
| 136 | +| `/status` | Show connection status | |
| 137 | +| `/rlm run "<task>"` | Run a task through the RLM loop | |
| 138 | +| `/rlm bench preset=<name>` | Run a benchmark preset | |
| 139 | +| `/rlm bench list` | List available benchmarks | |
| 140 | +| `/leaderboard` | View benchmark results | |
| 141 | +| `/rlm replay` | Step through the last run | |
| 142 | +| `/rlm chat "<question>"` | Ask the LLM a question about your project | |
| 143 | +| `/help` | Show all available commands | |
137 | 144 |
|
138 | | -- research-facing adapters and experiments, |
139 | | -- production-facing runtime, CLI, and CI interfaces. |
| 145 | +## What You Can Do With It |
140 | 146 |
|
141 | | -## Execution Roadmap |
| 147 | +- **Analyze large documents**: Feed in a 500-page PDF and ask questions — the LLM reads it in chunks via code |
| 148 | +- **Compare models**: Run the same benchmark with different providers and see who scores higher |
| 149 | +- **Compare paradigms**: Test Pure RLM vs CodeAct vs Traditional approaches on the same task |
| 150 | +- **Debug agent behavior**: Replay any run step-by-step to see exactly what the agent did |
| 151 | +- **Track experiments**: Every run is logged with metrics, tokens used, and trajectory |
142 | 152 |
|
143 | | -1. Eval dataset adapters (P0): ADK + Pydantic eval imports into `/rlm bench`. |
144 | | -2. Trajectory visualizer (P0): local viewer for runs, child calls, tool traces, rewards, and failures. |
145 | | -3. Runtime backends for sandbox (P0): pluggable runtimes beyond local. |
146 | | -4. Policy/reward lab plugins (P0): hot-swappable reward, memory, and action policies. |
147 | | -5. Framework event parity (P1): normalized event schema across DSPy, Pydantic AI, and ADK. |
148 | | -6. Durable/replayable sessions (P1): deterministic restore/replay and branch compare. |
149 | | -7. Observability upgrade (P1): OTel span linkage + MLflow/OTel export. |
150 | | -8. Benchmark packs + leaderboard mode (P1): pinned baselines + reproducibility metadata. |
151 | | -9. Tool approval / HITL gates (P2): optional approvals for risky actions. |
152 | | -10. Research-focused TUI mode (P2): experiment dashboard with traces/errors and result matrices. |
| 153 | +## Supported LLM Providers |
153 | 154 |
|
154 | | -## Why This Can Win |
| 155 | +| Provider | Latest Models | Setup | |
| 156 | +|----------|--------------|-------| |
| 157 | +| **Anthropic** | `claude-opus-4-6`, `claude-sonnet-4-5-20250929` | `ANTHROPIC_API_KEY` env var | |
| 158 | +| **OpenAI** | `gpt-5.3-codex`, `gpt-5.2-pro` | `OPENAI_API_KEY` env var | |
| 159 | +| **Google** | `gemini-2.5-pro`, `gemini-2.5-flash` | `GEMINI_API_KEY` or `GOOGLE_API_KEY` env var | |
| 160 | +| **Ollama** | `llama3.2`, `qwen2.5-coder:7b` | Running Ollama server at `localhost:11434` | |
155 | 161 |
|
156 | | -Most tools optimize prompting or orchestration in isolation. RLM Code focuses on the full behavior loop: |
| 162 | +## Configuration |
157 | 163 |
|
158 | | -- comparable benchmark corpora, |
159 | | -- replayable agent trajectories, |
160 | | -- robust gating and reproducibility, |
161 | | -- cross-framework portability. |
| 164 | +Create an `rlm_config.yaml` in your project directory to customize settings: |
162 | 165 |
|
163 | | -The moat is evaluation quality and reproducibility, not UI alone. |
| 166 | +```yaml |
| 167 | +rlm: |
| 168 | + paradigm: pure_rlm # pure_rlm, codeact, or traditional |
| 169 | + max_steps: 30 # max REPL iterations per run |
| 170 | + timeout: 60 # seconds |
164 | 171 |
|
165 | | -## Contributing |
| 172 | + sandbox: |
| 173 | + runtime: local # local, docker, modal, e2b, daytona |
| 174 | + |
| 175 | + mcp_server: |
| 176 | + enabled: false |
| 177 | + transport: stdio |
| 178 | + port: 8765 |
| 179 | +``` |
| 180 | +
|
| 181 | +Or generate a full sample config: |
166 | 182 |
|
167 | | -Contributions are welcome. Start with: |
| 183 | +``` |
| 184 | +/init |
| 185 | +``` |
| 186 | + |
| 187 | +## Development Setup |
| 188 | + |
| 189 | +```bash |
| 190 | +git clone https://github.com/SuperagenticAI/rlm-code.git |
| 191 | +cd rlm-code |
| 192 | +uv sync --all-extras |
| 193 | +uv run pytest |
| 194 | +``` |
| 195 | + |
| 196 | +## Project Structure |
| 197 | + |
| 198 | +``` |
| 199 | +rlm_code/ |
| 200 | + rlm/ # Core RLM engine (runner, environments, policies) |
| 201 | + ui/ # Terminal UI (Textual-based TUI) |
| 202 | + mcp/ # MCP server for tool integration |
| 203 | + models/ # LLM provider adapters |
| 204 | + sandbox/ # Sandboxed code execution |
| 205 | + observability/ # MLflow, OpenTelemetry, LangSmith, LangFuse |
| 206 | +``` |
| 207 | + |
| 208 | +## Documentation |
| 209 | + |
| 210 | +Full docs: https://superagenticai.github.io/rlm-code/ |
| 211 | + |
| 212 | +## Contributing |
168 | 213 |
|
169 | | -- `CONTRIBUTING.md` |
170 | | -- docs: `docs/` |
| 214 | +See `CONTRIBUTING.md`. |
171 | 215 |
|
172 | 216 | ## License |
173 | 217 |
|
174 | | -MIT License. See `LICENSE`. |
| 218 | +MIT |
0 commit comments