Agent skill

Dspy Rlm Module

by intertwine in intertwine/dspy-agent-skills

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…

MITAuto-check passedData & Analytics

Install Dspy Rlm Module

skills CLI
$ npx skills add intertwine/dspy-agent-skills --skill dspy-rlm-module -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install intertwine/dspy-agent-skills dspy-rlm-module --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/intertwine/dspy-agent-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/dspy-rlm-module .claude/skills/dspy-rlm-module && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
dspy-rlm-module
GitHub stars
278
Token cost
~1.3k tokens
SKILL.md length
443 words
Files
3
Skills in repo
5
Repo updated
First seen
Licence
MIT

At a glance

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…

  • The input is 100k tokens
  • SKILL.md covers Prerequisites, Canonical usage, Full constructor and When to reach for RLM vs.…, plus 5 more sections
  • Runs Python scripts from its folder; calls brew
  • Needs recursive chunking

What it does

Dspy Rlm Module is an agent skill from intertwine/dspy-agent-skills. 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.

Its SKILL.md is about 1.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files (for example `example_rlm.py` and `reference.md`).

It sits in Data & Analytics, covering Data analysis. It works with Python and Deno. The repository describes itself as: Production-grade DSPy 3.2.x agent skills + validated end-to-end examples for Claude Code and Codex CLI — fundamentals, evaluation, GEPA, BetterTogether, and RLM. The licence is MIT.

When your agent uses it

  • The input is 100k tokens
  • Needs recursive chunking
  • Benefits from the LLM writing and running code to probe data

Example prompts

  • “/dspy-rlm-module”

Requirements

  • Python 3

What it can do on your machine

Read from SKILL.md and the folder at commit 623dca0. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • brew

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • deno.land

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Dspy Rlm Module loads about 1.3k tokens when it runs. Until then it costs about 93 tokens; SKILL.md has 443 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~93
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from intertwine/dspy-agent-skills at commit 623dca0, republished under its MIT licence (© intertwine). 443 words, ~1,345 tokens.

Download SKILL.mdSave it as .claude/skills/dspy-rlm-module/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
dspy-rlm-module
description
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.
when_to_use
User has a very long document/codebase/log, asks about "long context", mentions RLM or recursive reasoning, or is trying to stuff a huge context into a single…

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 deno or 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

python
import dspy

dspy.configure(lm=dspy.LM("openai/gpt-4o"))
sub_lm = dspy.LM("openai/gpt-4o-mini")    # cheap inner model

rlm = dspy.RLM(
    "context, query -> answer",
    max_iterations=20,
    max_llm_calls=50,
    max_output_chars=10_000,
    sub_lm=sub_lm,
    tools=[],
    verbose=False,
)

result = rlm(
    context=open("huge_log.txt").read(),   # can be 500k+ tokens
    query="Summarize every unique error class and how many times each appeared.",
)
print(result.answer)

Full constructor

python
dspy.RLM(
    signature: type[Signature] | str,
    max_iterations: int = 20,       # REPL loop cap
    max_llm_calls: int = 50,        # sub-LM call cap (stops runaway recursion)
    max_output_chars: int = 10_000, # truncate REPL stdout per step
    verbose: bool = False,          # print the REPL trace
    tools: list[Callable] | None = None,
    sub_lm: dspy.LM | None = None,
    interpreter: CodeInterpreter | None = None,  # custom sandbox
)

When to reach for RLM vs. alternatives

SituationUse
Context <100k, answer fits one LM calldspy.Predict / dspy.ChainOfThought
Need external tools (web, db)dspy.ReAct(tools=[...])
Math/code that must rundspy.ProgramOfThought
Huge context, recursive chunking, or data-exploration loopdspy.RLM
Entire-codebase reasoning where the LM should grep/read filesdspy.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.

python
class RepoAuditor(dspy.Module):
    def __init__(self):
        super().__init__()
        self.explore = dspy.RLM("repo_tree, question -> findings",
                                max_iterations=30, sub_lm=dspy.LM("openai/gpt-4o-mini"))
        self.synth = dspy.ChainOfThought("findings, question -> report")

    def forward(self, repo_tree, question):
        f = self.explore(repo_tree=repo_tree, question=question).findings
        return self.synth(findings=f, question=question)

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_calls tight (20–50) in production; raise for research.
  • The default stdout cap is smaller in DSPy 3.2.x. max_output_chars now defaults to 10_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 treat context as 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 for read_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 deno before reporting bugs.
Show full SKILL.md (90 more words)Show less

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_calls left at default in a production path — runaway cost.
  • Passing secrets in the context string — they get echoed into REPL state.

Next

  • Wrap-and-optimize with GEPA → dspy-gepa-optimizer.
  • Full reference → reference.md.

© intertwine, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files in skills/dspy-rlm-module of intertwine/dspy-agent-skills.

  • SKILL.md
  • example_rlm.py
  • reference.md

Open the folder on GitHubat commit 623dca0

Compare with similar skills

Dspy Rlm Module next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Dspy Rlm Module compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Dspy Rlm Module this skillintertwine/dspy-agent-skills278—~1.3kAutomated safety check: PassMIT
Excel and CSV Data Analysisbytedance/deer-flow83k4 repos~2.2kAutomated safety check: PassMIT
Python Executorcortega26/chile-hub1132 repos~1.5kAutomated safety check: PassMIT
MatlabzLanqing/codex-claude-academic-skills4.6k9 repos~2.3kAutomated safety check: NotesGPL-3.0
Raccoon DataanalysisSenseTime-Copilot/raccoon-dataanalysis-skill137—~1.9kAutomated safety check: PassNone
Meridian MMM Model Buildinggoogle/meridian1.6k—~2.5kAutomated safety check: PassApache-2.0

Similar skills

  • Excel and CSV Data Analysis

    bytedance/deer-flow

    Analyzes uploaded Excel and CSV files with SQL through DuckDB, producing schema inspections, statistical summaries and exports to CSV, JSON or Markdown.

    83k GitHub starsUsed in 4 repos~2.2k tokens
    Data & AnalyticsAuto-check passed
  • Python Executor

    cortega26/chile-hub

    Execute Python code in a safe sandboxed environment via [inference.sh](https://inference.sh).

    113 GitHub starsUsed in 2 repos~1.5k tokens
    Data & AnalyticsAuto-check passed
  • Matlab

    zLanqing/codex-claude-academic-skills

    MATLAB and GNU Octave numerical computing for matrix operations, data analysis, visualization, and scientific computing.

    4.6k GitHub starsUsed in 9 repos~2.3k tokens
    Data & AnalyticsAuto-check: notes
  • Raccoon Dataanalysis

    SenseTime-Copilot/raccoon-dataanalysis-skill

    Raccoon (小浣熊) Data Analysis - Remote code interpreter and data visualization service powered by SenseTime.

    137 GitHub stars~1.9k tokensUpdated 6 mo ago
    Data & AnalyticsAuto-check passed
  • Official

    Takes a user through building a Meridian marketing mix model, from loading CSV data and mapping columns to running EDA, fitting and saving the model.

    1.6k GitHub stars~2.5k tokensUpdated today
    Data & AnalyticsAuto-check passed
  • Pandas Pro

    Jeffallan/claude-skills

    Handles pandas DataFrame work: cleaning, merging, groupby aggregation, pivots, time-series resampling and memory tuning, with checks on dtypes, shapes and nulls.

    12k GitHub starsUsed in 1 repo~1.5k tokens
    Data & AnalyticsAuto-check passed

More from intertwine/dspy-agent-skills

  • Dspy Advanced Workflow

    intertwine/dspy-agent-skills

    Build DSPy 3.2.x programs through spec, program, metric and baseline; extend to optimization and export when requested and justified by task budget.

    278 GitHub stars~1.7k tokensUpdated 1 mo ago
    Auto-check passed
  • Dspy Evaluation Harness

    intertwine/dspy-agent-skills

    Build DSPy evaluation harnesses with rich-feedback metrics that are essential for GEPA optimization.

    278 GitHub stars~1.5k tokensUpdated 1 mo ago
    Auto-check passed
  • Dspy Fundamentals

    intertwine/dspy-agent-skills

    Write idiomatic DSPy 3.2.x programs — typed Signatures, dspy.Module subclasses, Predict/ChainOfThought/ReAct/ProgramOfThought, and save/load.

    278 GitHub stars~1.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Dspy Gepa Optimizer

    intertwine/dspy-agent-skills

    Optimize DSPy programs with dspy.GEPA — a reflective/evolutionary optimizer to consider against task-specific baselines within an authorized evaluation budget.

    278 GitHub stars~2.6k tokensUpdated 1 mo ago
    Auto-check passed

Works with

Questions about Dspy Rlm Module

What does Dspy Rlm Module do?

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…. Dspy Rlm Module is an agent skill from intertwine/dspy-agent-skills.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.

When should I use Dspy Rlm Module?

Dspy Rlm Module fits situations like: the input is 100k tokens; needs recursive chunking; benefits from the LLM writing and running code to probe data.

How do I install Dspy Rlm Module in Claude Code?

Run `npx skills add intertwine/dspy-agent-skills --skill dspy-rlm-module -a claude-code`. Or copy the skill folder (skills/dspy-rlm-module in intertwine/dspy-agent-skills) into .claude/skills/dspy-rlm-module in your project. Claude Code loads it when a task matches its description.

How do I install Dspy Rlm Module in Codex?

Run `npx skills add intertwine/dspy-agent-skills --skill dspy-rlm-module -a codex`. Or copy the skill folder (skills/dspy-rlm-module in intertwine/dspy-agent-skills) into .agents/skills/dspy-rlm-module in your project. Codex loads it when a task matches its description.

Can I use Dspy Rlm Module in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add intertwine/dspy-agent-skills --skill dspy-rlm-module -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/dspy-rlm-module, .gemini/skills/dspy-rlm-module, .github/skills/dspy-rlm-module and .opencode/skills/dspy-rlm-module in your project.

What does Dspy Rlm Module need to run?

Going by SKILL.md and its folder, Dspy Rlm Module needs Python for the scripts in its folder and the command-line tools its instructions call (brew). Our summary lists: Python 3.

Does Dspy Rlm Module access the network?

SKILL.md names 1 domain. As links in the text: deno.land. This is read from the text; nothing was executed.

Is Dspy Rlm Module safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Dspy Rlm Module use?

Dspy Rlm Module is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Dspy Rlm Module use?

About 1.3k tokens (SKILL.md is roughly 5.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Dspy Rlm Module?

Skills that share tags, products or a category with Dspy Rlm Module: Excel and CSV Data Analysis (bytedance/deer-flow, 83k stars), Python Executor (cortega26/chile-hub, 113 stars), Matlab (zLanqing/codex-claude-academic-skills, 4.6k stars) and Raccoon Dataanalysis (SenseTime-Copilot/raccoon-dataanalysis-skill, 137 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Dspy Rlm Module?

intertwine (a GitHub user) maintains it in intertwine/dspy-agent-skills, which has 278 GitHub stars. The repository holds 5 skills in this directory. The repository was last updated on September 6, 2026.

Source: intertwine/dspy-agent-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.