feat: Add Recursive Language Model (RLM) tools for large context processing#125
Draft
DaevMithran wants to merge 1 commit intomainfrom
Draft
feat: Add Recursive Language Model (RLM) tools for large context processing#125DaevMithran wants to merge 1 commit intomainfrom
DaevMithran wants to merge 1 commit intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@ekai/rlm, a standalone package with six tools (rlm_overview,rlm_peek,rlm_grep,rlm_slice,rlm_query,rlm_repl) that let an agent explore, search, and reason over large contexts without flooding the context windowrlmEnabled: trueconfig flag, with automatic activation when user messages exceed 50% of the token budgetMotivation
Handling large data inputs exceeding the size of context window, stuffing everything into the prompt either truncates content, degrades quality, or fails entirely. RLM solves this by keeping the full content in an efficient in-memory buffer and exposing it through purpose-built tools. The agent decides what to look at, when, and how deeply resulting in bounded token usage regardless of input size.
Based on the Recursive Language Model paper, adapted from a monolithic engine into a tools-first architecture that composes with OpenClaw's existing agent loop.
What's included
packages/rlm— Standalone reusable packagevm-based execution environment with security constraints (code validation, timeout, iteration limits)pdf-parse), Excel (xlsx), text/markdown/CSV/JSON (built-in)packages/contexto— Plugin integrationrlmEnabled: trueflag — no model selection needed (uses OpenRouter auto-routing via pi-ai)prepareSubagentSpawnmaps child sessions to pending contexts;onSubagentEndedingests results into mindmapCompletionProviderto OpenClaw's built-in LLM abstractionArchitecture
Content never enters the agent's context window directly. Token usage stays bounded regardless of input size.
Test plan
tsc --noEmitpasses in bothpackages/rlmandpackages/contextoopenclaw.plugin.jsonreflectsrlmEnabledboolean config