Loading...
Loading...
Recursive Language Model context management for processing documents exceeding context window limits. Enables Claude to match Gemini's 2M token context capability through chunking, sub-LLM delegation, and synthesis.
npx skill4agent add starwreckntx/irp__methodologies- rlm-context-manager| Component | IRP Implementation | Model |
|---|---|---|
| Root LLM | Main Claude Code conversation | Claude Opus 4.5 |
Sub-LLM ( | | Claude Haiku |
| External Environment | Persistent Python REPL | Python 3 |
| State Persistence | | Pickle |
/rlm init <context_path> - Initialize REPL with large context file
/rlm status - Show current RLM state (chars loaded, chunks, buffers)
/rlm query <question> - Query the loaded context
/rlm chunk - Materialize context into chunk files
/rlm synthesize - Merge collected evidence into final answer
/rlm reset - Clear RLM state
/rlm export - Export buffers to file# 1. Initialize with a large context file
python3 ${SKILLS_ROOT}/rlm-context-manager/scripts/rlm_repl.py init /path/to/large_document.txt
# 2. Check status
python3 ${SKILLS_ROOT}/rlm-context-manager/scripts/rlm_repl.py status
# 3. Scout the context (peek at beginning and end)
python3 ${SKILLS_ROOT}/rlm-context-manager/scripts/rlm_repl.py exec -c "print(peek(0, 3000))"
# 4. Create chunks for sub-LLM processing
python3 ${SKILLS_ROOT}/rlm-context-manager/scripts/rlm_repl.py exec <<'PY'
paths = write_chunks('${SKILLS_ROOT}/rlm-context-manager/state/chunks', size=200000, overlap=0)
print(f"Created {len(paths)} chunks")
PYpython3 ${SKILLS_ROOT}/rlm-context-manager/scripts/rlm_repl.py init <context_path>
python3 ${SKILLS_ROOT}/rlm-context-manager/scripts/rlm_repl.py status# Peek at beginning
python3 ${SKILLS_ROOT}/rlm-context-manager/scripts/rlm_repl.py exec -c "print(peek(0, 3000))"
# Peek at end
python3 ${SKILLS_ROOT}/rlm-context-manager/scripts/rlm_repl.py exec -c "print(peek(len(content)-3000, len(content)))"
# Search for patterns
python3 ${SKILLS_ROOT}/rlm-context-manager/scripts/rlm_repl.py exec -c "print(grep('pattern', max_matches=10))"python3 ${SKILLS_ROOT}/rlm-context-manager/scripts/rlm_repl.py exec <<'PY'
paths = write_chunks('${SKILLS_ROOT}/rlm-context-manager/state/chunks', size=200000, overlap=0)
print(len(paths))
print(paths[:5])
PYTask: rlm-subcall
Prompt: "Query: <user_query>. Chunk file: <chunk_path>. Extract relevant information."
Model: haiku{
"chunk_id": "...",
"relevant": [{"point": "...", "evidence": "...", "confidence": "high|medium|low"}],
"missing": ["..."],
"suggested_next_queries": ["..."],
"answer_if_complete": "..."
}| Function | Description |
|---|---|
| Return substring of context |
| Regex search with context window |
| Calculate chunk boundaries |
| Materialize chunks to files |
| Store intermediate results |
${SKILLS_ROOT}/rlm-context-manager/state/rlm-context-manager/
├── SKILL.md # This file
├── scripts/
│ └── rlm_repl.py # Persistent Python REPL
├── agents/
│ └── rlm-subcall.md # Sub-LLM agent definition
└── state/ # Runtime state (gitignored)
├── state.pkl # Persisted REPL state
└── chunks/ # Materialized chunk files