When you have a 500k token log file or an entire codebase that won't fit in a single prompt, this skill gives Claude a sandboxed Python REPL to explore it recursively. The LLM writes code to grep, slice, and summarize chunks, issuing sub-queries until it can answer. Requires Deno installed locally. The big gotcha is cost: one RLM call can spawn dozens of inner LLM calls, so keep max_llm_calls tight and use a cheap model like gpt-4o-mini for the inner loop. Overkill for anything under 100k tokens, but genuinely useful for log analysis, codebase audits, or any task where the model needs to write code to probe data it can't hold in working memory.

GitHub stars
250
last updated
May 25, 2026

Install

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

Installs into .claude/skills of the current project.

Files

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

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

Sponsors

Details

Repository
github.com/intertwine/dspy-agent-skills
Categories
Documentation, AI & Agent Building, Python
License
MIT
First seen
Jun 11, 2026

More from intertwine/dspy-agent-skills

All 5
1iPlug2 avatarscreenshotiPlug2/iPlug2Take a screenshot of the plugin UI using the standalone app CLI for debugging and documentation0skills.sh installs
2jdrhyne avatarlast30daysjdrhyne/agent-skillsResearch any topic from the last 30 days on Reddit + X + Web, synthesize findings, and write copy-paste-ready prompts. Use when the user wants recent social/web0skills.sh installs
3jdrhyne avatarnudocsjdrhyne/agent-skillsUpload, edit, and export documents via Nudocs.ai. Use when creating shareable document links for collaborative editing, uploading markdown/docs to Nudocs for ri0skills.sh installs
4kaelio avatarhistoric_sql_patternskaelio/ktxIdentify recurring cross-table historic-SQL analytical intents from a bounded pattern shard and emit typed pattern evidence for deterministic wiki projection.0skills.sh installs
5kaelio avatarnotion_synthesizekaelio/ktxSynthesize durable ktx wiki pages and semantic-layer sources from staged Notion pages, databases, data-source rows, and clustered Notion evidence. Load when a W0skills.sh installs
6linzzzzzz avatarvideo-clip-extractorlinzzzzzz/openclipProcesses videos to identify engaging moments, generate transcripts, and create highlight clips with artistic titles and custom cover images. Use when user need0skills.sh installs