Repository navigation
feat(core): implement Recursive Language Model (RLM) support - #6795
Closed
soya-miruku wants to merge 4 commits into
Closed
soya-miruku wants to merge 4 commits into
soya-miruku wants to merge 4 commits into
Conversation
Add experimental RLM infrastructure based on the paper "Recursive Language Models" (Zhang et al., 2025). This allows processing arbitrarily long contexts by treating prompts as part of an external Python REPL environment. Key additions: - repl tool: Persistent Python REPL with llm_query() for recursive sub-calls - rlm agent: Specialized subagent for long-context processing - rlm-sub agent: Hidden subagent for handling recursive LLM queries - FINAL()/FINAL_VAR() response patterns for returning answers The RLM approach enables: - Processing contexts 10-100x beyond normal context windows - Programmatic examination and decomposition of long inputs - Recursive self-invocation over context snippets - Code-based filtering before semantic analysis Enable via: experimental.repl_tool = true in config
- Add llm_query_parallel() for concurrent sub-agent execution - Add llm_map() for mapping prompts over items with auto-batching - Add probe_context() for analyzing context metadata - Add smart_chunk() for semantic-aware text splitting - Add plan_decomposition() for LLM-assisted strategy planning - Update TypeScript handler to execute batch queries in parallel - Enhance prompts with comprehensive documentation of new features The model now decides parallelism based on data characteristics, spawning multiple sub-agents simultaneously via Promise.all().
- Add RLM system prompt instructions for primary agent - Create rlm-auto.txt with guidance on when/how to use REPL tool - Add SystemPrompt.rlm() to conditionally include RLM instructions - Instructions included when experimental.repl_tool is enabled - Primary agent can now automatically use REPL for large contexts
- Create RLM module for context analysis and detection - Auto-detect when input context exceeds 100KB threshold - Inject RLM activation prompt when large context detected - Emit 'rlm.activated' event for TUI visibility - Model now receives explicit guidance to use REPL tool When large context is detected, the model sees: <rlm-context-loaded> A large context (XXkb) has been loaded... Use the REPL tool - do NOT try to process directly. </rlm-context-loaded>
|
@soya-miruku I was just about to post this as a feature request. Do you have any info on why this was closed? |
1 task done
|
Has anyone successfully adopted RLMs to opencode ? |
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.
Add experimental RLM infrastructure based on the paper "Recursive Language Models" (Zhang et al., 2025). This allows processing arbitrarily long contexts by treating prompts as part of an external Python REPL environment.
Key additions:
The RLM approach enables:
Enable via: experimental.repl_tool = true in config