Skip to content

Commit c2d3adc

Browse files
committed
Improve the RLM environmrnt
1 parent 51445ed commit c2d3adc

41 files changed

Lines changed: 5627 additions & 481 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/deploy-docs.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,14 @@ jobs:
2929
with:
3030
python-version: '3.12'
3131

32-
- name: Cache dependencies
33-
uses: actions/cache@v4
32+
- name: Install uv
33+
uses: astral-sh/setup-uv@v4
3434
with:
35-
path: ~/.cache/pip
36-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
37-
restore-keys: |
38-
${{ runner.os }}-pip-
35+
version: "latest"
3936

4037
- name: Install MkDocs and dependencies
4138
run: |
42-
pip install mkdocs-material mkdocs-minify-plugin
39+
uv pip install --system mkdocs-material mkdocs-minify-plugin
4340
4441
- name: Build and deploy documentation
4542
run: |
@@ -49,5 +46,5 @@ jobs:
4946

5047
- name: Summary
5148
run: |
52-
echo "Documentation deployed successfully!" >> $GITHUB_STEP_SUMMARY
53-
echo "📚 View at: https://superagenticai.github.io/dspy-code/" >> $GITHUB_STEP_SUMMARY
49+
echo "Documentation deployed successfully!" >> $GITHUB_STEP_SUMMARY
50+
echo "View at: https://superagenticai.github.io/rlm-code/" >> $GITHUB_STEP_SUMMARY

.github/workflows/pre-commit.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ jobs:
1717
with:
1818
python-version: "3.12"
1919

20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v4
22+
with:
23+
version: "latest"
24+
2025
- name: Install pre-commit
21-
run: pip install pre-commit
26+
run: uv pip install --system pre-commit
2227

2328
- name: Cache pre-commit environments
2429
uses: actions/cache@v4

README.md

Lines changed: 156 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,174 +1,218 @@
11
# RLM Code
22

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.**
44

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

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

9-
## North Star
9+
## Install
1010

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+
```
1214

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).
1716

18-
## Positioning
17+
Don't have uv? Install it first:
1918

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+
```
2122

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>
2330

24-
**Research fast. Evaluate rigorously. Ship reliable agents.**
31+
## Quick Start
2532

26-
## What RLM Code Is
33+
### 1. Launch
2734

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+
```
3239

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

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
3843

39-
## Who It Is For
44+
Type one of these in the chat input:
4045

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+
```
4549

46-
## Problems It Solves
50+
or
4751

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+
```
5255

53-
## Product Pillars
56+
or
5457

55-
### 1) RLM Code Core
58+
```
59+
/connect gemini gemini-2.5-flash
60+
```
5661

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/):
5863

59-
### 2) RLM Code Bench
64+
```
65+
/connect ollama llama3.2
66+
```
6067

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.
6269
63-
### 3) RLM Code Labs
70+
Check it worked:
6471

65-
Pluggable experimentation for reward shaping, memory policies, and algorithmic research.
72+
```
73+
/status
74+
```
6675

67-
### 4) RLM Code Ops
76+
### 3. Run your first RLM task
6877

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+
```
7081

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

73-
Shareable benchmark packs, policies, and reproducible runs.
84+
### 4. Run a benchmark
7485

75-
## Interoperability
86+
Benchmarks let you measure how well a model performs on a set of tasks:
7687

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+
```
7891

79-
### Agent Frameworks
92+
This runs 3 test cases through the RLM loop and scores the results.
8093

81-
Use framework adapters for DSPy, Pydantic AI, Google ADK, and others so you can:
94+
See all available benchmarks:
8295

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+
```
8699

87-
### Coding Agents and Model Providers
100+
### 5. View results
88101

89-
Use ACP/BYOK/local providers and route work to specialized models while RLM Code keeps control of:
102+
```
103+
/leaderboard
104+
```
90105

91-
- execution safety,
92-
- verification,
93-
- benchmark gating,
94-
- observability.
106+
Shows a table of all your benchmark runs ranked by reward score.
95107

96-
## Quick Start
108+
### 6. Replay a session step-by-step
97109

98-
```bash
99-
pip install --upgrade rlm-code
100-
rlm-code
110+
```
111+
/rlm replay
101112
```
102113

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

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
114117

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

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:
127121

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")`
129127

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

134-
## Research and Production Packaging
130+
## Key Commands
135131

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 |
137144

138-
- research-facing adapters and experiments,
139-
- production-facing runtime, CLI, and CI interfaces.
145+
## What You Can Do With It
140146

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
142152

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
153154

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` |
155161

156-
Most tools optimize prompting or orchestration in isolation. RLM Code focuses on the full behavior loop:
162+
## Configuration
157163

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:
162165

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
164171

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:
166182
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
168213

169-
- `CONTRIBUTING.md`
170-
- docs: `docs/`
214+
See `CONTRIBUTING.md`.
171215

172216
## License
173217

174-
MIT License. See `LICENSE`.
218+
MIT

0 commit comments

Comments
 (0)