rlmagents
Agent harness built on LangChain + LangGraph that combines:
- an RLM-aligned core loop (Algorithm 1 from the RLM paper)
- additional agent-harness features (planning, filesystem, sub-agents, recipes, etc.)
Fork of LangChain Deep Agents. No runtime dependency on upstream deepagents internals.
Design reference: Recursive Language Model paper (local PDF)
Quick start
pip install rlmagents
# or
uv add rlmagents
# Launch the CLI/TUI
rlmagents
from rlmagents import create_rlm_agent
agent = create_rlm_agent()
result = agent.invoke({
"messages": [{"role": "user", "content": "Research this topic and write a summary..."}]
})
What's included
| Category | Origin | Tools/Behavior |
|---|---|---|
| Context externalization | RLM core | load_context, load_file_context, list_contexts |
| REPL analysis loop | RLM core | exec_python, get_variable |
| Recursive decomposition | RLM core | sub_query() / llm_query() inside REPL execution |
| Root-loop history | RLM core | bounded hist artifact with per-iteration execution metadata |
| Completion handoff | RLM-aligned implementation | finalize, plus optional REPL Final/set_final(...) sentinel path |
| Query and search extensions | RLMAgents extension | peek_context, search_context, semantic_search, chunk_context, cross_context_search, rg_search |
| Planning | RLMAgents extension | write_todos, read_todos |
| Filesystem | RLMAgents extension | read_file, write_file, edit_file, ls, glob, grep |
| Shell | RLMAgents extension | execute (restricted) |
| Sub-agents | RLMAgents extension | task (delegate with isolated contexts) |
| Reasoning utilities | RLMAgents extension | think, evaluate_progress, summarize_so_far, get_evidence |
| Recipes | RLMAgents extension | validate_recipe, run_recipe, run_recipe_code |
| Memory | RLMAgents extension | AGENTS.md files loaded at startup |
| Skills | RLMAgents extension | Domain-specific capabilities from SKILL.md files |
Tool profiles control which RLM tools are available: full (all), reasoning
(no recipe/config tools), core (minimum set).
Paper alignment
The RLM-aligned core follows Algorithm 1:
- Prompt/data are treated as external REPL state instead of root-context stuffing.
- The model iterates through a code-execute-observe loop.
- Recursion is programmatic via
sub_query()/llm_query()inside REPL code. - Execution metadata is retained in bounded
histand compact metadata is auto-injected into root model context. - Completion supports explicit
finalizeand optionalFinalsentinel mode.
RLMAgents then layers additional functionality not required by the paper: evidence lifecycle, broader search/retrieval tools, session persistence (memory-pack JSON), recipe DSL, and full agent-harness middleware (planning/filesystem/shell/sub-agents/HITL).
Typical workflow
- Load files/data into isolated contexts
- Explore with
search_context,peek_context,semantic_search,rg_search - Analyze with
exec_python(100+ built-in REPL helpers) - Track evidence (provenance captured automatically)
- Reason with
think,evaluate_progress - Conclude with
finalize(orset_final(...)/Finalwhen sentinel mode is enabled)
Configuration
from rlmagents import create_rlm_agent
agent = create_rlm_agent(
model="deepseek/deepseek-chat", # Main agent model (required)
sub_query_model="minimax/minimax-01", # Optional; defaults to reusing `model`
sub_query_timeout=120.0,
rlm_auto_inject_exec_metadata=True, # Default: inject bounded per-iteration metadata
rlm_exec_metadata_max_entries=4,
rlm_exec_metadata_max_chars=1200,
rlm_hist_max_entries=64, # Bounded root-loop history artifact
rlm_enable_final_sentinel=False, # Optional paper-style `Final` completion path
skills=["/skills/analysis/"],
memory=["/memory/AGENTS.md"],
rlm_tool_profile="reasoning", # full | reasoning | core
rlm_exclude_tools=("cross_context_search",),
auto_load_threshold=5000, # Auto-load tool outputs >5KB into RLM
auto_load_preview_chars=400,
sandbox_timeout=300.0, # REPL timeout
interrupt_on={"edit_file": True}, # Human-in-the-loop
)
To keep as much as possible outside the chat window:
from pathlib import Path
agent = create_rlm_agent(
model="deepseek/deepseek-chat",
rlm_tool_profile="core",
auto_load_threshold=1500,
auto_load_preview_chars=0,
rlm_system_prompt=Path("examples/rlm_system_prompt.md").read_text(),
memory=["examples/AGENTS.md"],
)
Architecture
rlmagents/
├── _harness/ # Agent harness (planning, filesystem, skills, memory)
│ ├── backends/ # Backend protocol (State, Filesystem, etc.)
│ └── middleware/
├── middleware/
│ └── rlm.py # RLM middleware (tool profiles, auto-load)
├── repl/
│ ├── sandbox.py # Restricted execution environment
│ └── helpers.py # Built-in helper functions
├── session_manager.py # Session lifecycle
├── serialization.py # Memory-pack serialization
├── recipes.py # Recipe validation and estimation
└── graph.py # create_rlm_agent() entry point
Security note: the REPL is best-effort restricted by policy and timeouts, not a formally hardened sandbox.
Requirements
- Python 3.11+
langchain-core>=1.2.10langchain>=1.2.10langchain-anthropic>=0.3.0langgraph>=0.3.0pyyaml>=6.0wcmatch>=10.0
Development
cd libs/rlmagents
uv sync --group test
uv run pytest
uv run ruff check .
uv run ruff format .
License
MIT License -- see LICENSE for details.
Metadata
Release files for rlmagents 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rlmagents-0.0.5.tar.gz | 530.0 kB | Without provenance | Details for rlmagents-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rlmagents-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for rlmagents-0.0.5-py3-none-any.whl |
Total release size: 898.4 kB
Release files / rlmagents-0.0.5.tar.gz
| Download URL | rlmagents-0.0.5.tar.gz |
|---|---|
| Size | 530.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af87eb52949ab9b51927cdc6d0a90c4fdefbe6c79e838b428b8a2bbaf60c5cdc
|
|
BLAKE2b-256 checksum How to use checksums |
3048dc43e33256c8cb0d3fe2d81483e9c144f12cec9d0a776aa48d34c80376fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / rlmagents-0.0.5-py3-none-any.whl
| Download URL | rlmagents-0.0.5-py3-none-any.whl |
|---|---|
| Size | 368.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9e44895039811ce4078cb13cb5d51e9680b6da70bf666dca986983cd74d8d067
|
|
BLAKE2b-256 checksum How to use checksums |
4cc3642e512c40d7f5d1b1c422ade97279d71f625ee86b37ba911c71307b7902
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for rlmagents 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.