intertwine/dspy-agent-skills/dspy-rlm-module
Claude Code and agent skill by intertwine/dspy-agent-skills
- community
Checking that the SKILL.md file is still in the repository.
Use dspy.RLM (Recursive Language Model) for reasoning over contexts too large to fit in an LLM's working window — entire codebases, long logs, massive documents, or multi-step data exploration that needs a sandboxed Python REPL. Use when the input is >100k tokens, needs recursive chunking, or benefits from the LLM writing and running code to probe data.
Install
npx vskill@latest install intertwine/dspy-agent-skills/dspy-rlm-moduleSKILL.md
dspy.RLM — Recursive Language Model
dspy.RLM runs the LLM in a sandboxed Python REPL (Pyodide/WASM via Deno) with access to the full context as variables. The LLM writes code to slice, grep, summarize, and recursively sub-query the data, iterating until it can answer. Use it when the context is too large to cram into a single prompt.
Prerequisites
- Deno installed (for the default
PythonInterpreter):brew install denoor see https://deno.land. The interpreter is a Pyodide-in-WASM sandbox spawned by Deno. - A sub-LM for inner calls — usually a cheaper model than the outer LM. Defaults to
dspy.settings.lm.
Canonical usage
Full constructor
When to reach for RLM vs. alternatives
| Situation | Use | |
|---|---|---|
| Context <100k, answer fits one LM call | dspy.Predict / dspy.ChainOfThought | |
| Need external tools (web, db) | dspy.ReAct(tools=[...]) | |
| Math/code that must run | dspy.ProgramOfThought | |
| Huge context, recursive chunking, or data-exploration loop | `dspy.RLM` | |
| Entire-codebase reasoning where the LM should grep/read files | dspy.RLM with file-reading tools=[...] |
Composition — RLM as a module inside a larger program
Wrap the RLM in your own dspy.Module and optimize the enclosing program with GEPA. GEPA can tune both the RLM's outer signature instruction and the surrounding predictors.
Then: dspy.GEPA(metric=..., ...).compile(student=RepoAuditor(), trainset=..., valset=...).
Practical tips
- Budget carefully. A single RLM call can issue dozens of sub-LM calls. Keep
max_llm_callstight (20–50) in production; raise for research. - The default stdout cap is smaller in DSPy 3.2.x.
max_output_charsnow defaults to10_000; raise it deliberately if your REPL tools print large tables or document slices. - Use a cheap `sub_lm`. The outer LM orchestrates; inner calls (summarize, filter, score) don't need the flagship model.
- Pass data as kwargs, not in the instruction.
rlm(context=huge_string, query="...")lets the REPL treatcontextas a Python variable. Avoid concatenating it into the prompt. - `verbose=True` while debugging. Prints every REPL step — invaluable when the RLM appears to hang or loop.
- Custom tools are regular Python callables passed via
tools=[...]; they are exposed inside the sandbox. Useful forread_file,grep,vector_search, etc. In DSPy 3.2.x they are invoked by keyword, so give them named, typed parameters rather than positional-only signatures. - Deno install is required. Missing Deno is the #1 RLM error. Check
which denobefore reporting bugs.
Security note
The default interpreter is a Deno-sandboxed Pyodide WASM runtime — no filesystem, network, or subprocess access by default. If you pass custom tools that do I/O, your tools' security posture is yours. Never hand raw subprocess.run to the RLM.
Anti-patterns
- Using RLM when a 32k-token prompt would fit — overhead is not worth it.
- Missing Deno → hard-to-diagnose failures. Install it.
max_llm_callsleft at default in a production path — runaway cost.- Passing secrets in the
contextstring — they get echoed into REPL state.
Next
- Wrap-and-optimize with GEPA →
dspy-gepa-optimizer. - Full reference → reference.md.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/dspy-rlm-module/SKILL.md
Popularity
- Repository stars
- 237
- Repository forks
- 21
- 7-day trend score
- 27
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 21 May 2026, 5 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/intertwine/dspy-agent-skills/dspy-rlm-module)