Skip to content

Hmbown/rlmagents

Repository files navigation

RLMAgents

PyPI - Version CI License: MIT Python 3.11+

rlmagents is an agent harness built on LangChain + LangGraph. It uses an RLM-style loop inspired by Recursive Language Models (Zhang, Kraska, Khattab, 2025), then adds practical agent tooling.

Forked from LangChain Deep Agents. Paper reference implementation: alexzhang13/rlm.

Install

pip install rlmagents

Usage

CLI

rlmagents                        # interactive session
rlmagents -n "Explain this repo" # one-shot
rlmagents -r                     # resume last conversation

Python

from rlmagents import create_rlm_agent

agent = create_rlm_agent()
result = agent.invoke({
    "messages": [{"role": "user", "content": "Summarize the key ideas in this paper."}]
})
# With a separate model for recursive sub-calls
agent = create_rlm_agent(
    model="deepseek/deepseek-chat",
    sub_query_model="deepseek/deepseek-reasoner",
    sub_query_timeout=300.0,
    rlm_tool_profile="full",  # full | reasoning | core
)

What Is an RLM?

An RLM (Recursive Language Model) is a way to work on big tasks without stuffing everything into one huge prompt.

In this project, that means:

  • Data can live in REPL/session state instead of only in chat context
  • The agent works in a loop by writing and running code (exec_python)
  • It can call recursive sub-queries with sub_query (llm_query alias)
  • It finishes with finalize (or optionally Final / set_final(...))

What It's Helpful For

  • Large codebase analysis where you need to inspect many files
  • Long documents that are too big for a single prompt
  • Multi-step tasks that mix search, code execution, and synthesis
  • Workflows that need citations/evidence tracking for final answers
  • Repeatable analysis pipelines via recipe tools

What RLMAgents Adds

  • Evidence tracking and citations across tool calls
  • Multi-context isolation (separate REPL sessions with context_id)
  • Recipe tools (validate_recipe, run_recipe)
  • Agent harness tools: planning, filesystem, shell, sub-agents, skills, memory
  • @file loading plus auto-loading large tool results into contexts

Monorepo Layout

Path Package Description
libs/rlmagents rlmagents Python API + bundled CLI/TUI
libs/cli rlmagents-cli Standalone CLI package (monorepo development)
libs/acp deepagents-acp Agent Context Protocol integration
libs/harbor deepagents-harbor Evaluation and benchmark tooling
libs/deepagents deepagents Upstream-compatible SDK package

Development

# check all lockfiles in the monorepo
make lock-check

# package-level checks
cd libs/rlmagents
uv sync --group test
uv run pytest tests -q
uv run ruff check rlmagents tests

Run from source:

uv run --project libs/rlmagents rlmagents

Links

About

RLM agent harness - built on Deep Agents

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages