Skip to content

feat: add RLM (Recursive Language Model) engine#13499

Closed
ooo-mmm wants to merge 1 commit into
anomalyco:devfrom
ooo-mmm:rlm-feature
Closed

feat: add RLM (Recursive Language Model) engine#13499
ooo-mmm wants to merge 1 commit into
anomalyco:devfrom
ooo-mmm:rlm-feature

Conversation

@ooo-mmm

@ooo-mmm ooo-mmm commented Feb 13, 2026

Copy link
Copy Markdown

This PR adds a JavaScript REPL-based recursive reasoning system that enables LLMs to execute code iteratively in a sandboxed VM environment.

Disclaimer: This code was entirely AI-generated using OpenCode. I haven't had time to review it thoroughly, but I've tested it via nix package install and it works great. Context rebuilding is surprisingly fast.
What's included:

  • Sandboxed vm-based REPL with execution timeout and variable persistence
  • context_query tool for verification during RLM execution
  • Session-level toggle via TUI and rlm_toggle keybind
  • Enabled by default
  • Last summary is always sent along with compacted context, which helps preserve long context and drastically reduces hallucination
    What this enables:
    With RLM, the model can now handle session context questions that were previously impossible — things like:
  • "What was the first error we fixed in this session?"
  • "Which files did we modify 10000 messages ago?"
  • "Summarize all the changes we've made so far using context_query"
  • "What was my original request before we went down this rabbit hole?"
    If you have long sessions where the model starts forgetting earlier context, RLM can help. Let me know how it goes!

ported from: https://github.com/alexzhang13/rlm

Implements a JavaScript REPL-based recursive reasoning system that enables
LLMs to iteratively execute code in a sandboxed VM environment.

Core implementation:
- Sandboxed vm-based REPL with execution timeout (30s default)
- const/let hoisting for variable persistence across executions
- Whitelisted globals only (Math, JSON, Array, etc.)
- Injected functions: llm_query(), FINAL(), FINAL_VAR(), SHOW_VARS()

Integration:
- context_query tool for LLM verification during RLM execution
- Structured context extraction preserving message history as JSON
- Context overflow dialog prompting compact vs RLM mode
- Session-level RLM toggle via TUI and keybind (rlm_toggle)
- RLM status badge in footer
- Shared REPL architecture across agent tasks

Configuration (rlm section):
- enabled: Enable RLM globally (default: false)
- max_iterations: Iteration limit before forcing answer (default: 30)
- max_depth: Recursion depth limit (default: 1)
- sub_model: Model for sub-LLM queries inside REPL
- verbose: Enable verbose logging

Includes test suite for parsing, environment, and flow.
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #8555: feat(tool): add rlm_repl tool for recursive LLM pattern

This appears to be a related or duplicate PR that implements a similar REPL-based recursive LLM pattern. You should review this existing PR to understand:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant