Skip to main content

Recursive Language Models with DSPy + Modal for secure long-context code execution

Project description

fleet-rlm

PyPI version Python versions License: MIT CI

Secure, cloud-sandboxed Recursive Language Models (RLM) with DSPy and Modal.

fleet-rlm provides a production-ready implementation of Recursive Language Modeling aligned with the DSPy RLM API. It gives your AI agent a secure "computer" in the cloud to read, search, and analyze massive datasets without local resource constraints.

Paper | Contributing | Docs


Architecture

User ─── CLI / API / WebSocket ─── RLMReActChatAgent (dspy.Module)
                                        │
                          ┌──────────────┼──────────────┐
                          │              │              │
                     load_document  rlm_query      edit_file
                     list_files     (recursive)    search_code
                     read_file_slice ...            ...
                          │              │
                          ▼              ▼
                   ModalInterpreter ── dspy.RLM
                          │              │
                          ▼              ▼
                   Modal Sandbox (isolated Python REPL)
                   ├── Persistent Volume (/data/)
                   ├── Execution Profiles (ROOT / DELEGATE / MAINTENANCE)
                   └── Session State (per workspace/user)

Features

  • Interactive Agent: RLMReActChatAgent (a dspy.Module) combines fast, interactive chat with deep, recursive task execution via rlm_query.
  • DSPy Aligned: Implements dspy.RLM, dspy.Module, and dspy.Tool interfaces — compatible with DSPy optimizers (BootstrapFewShot, MIPROv2).
  • Secure Sandbox: Code runs in isolated Modal containers with persistent storage volumes, execution profiles, and sensitive data redaction.
  • Recursive Delegation: Large tasks are broken down via rlm_query sub-agents with depth enforcement to prevent infinite recursion.
  • PDF Ingestion: Native document loading via MarkItDown with pypdf fallback; OCR guidance for scanned PDFs.
  • Session State: Per-workspace, per-user session persistence with manifests stored on Modal volumes.
  • MCP Server: Expose fleet-rlm capabilities as an MCP tool server via serve-mcp.
  • Observability: Real-time streaming of thoughts, tool execution, trajectory normalization, and structured logging.

Quick Start

1. Install

pip install fleet-rlm

Optional extras for server and MCP support:

pip install fleet-rlm[server]   # FastAPI server + WebSocket
pip install fleet-rlm[mcp]      # MCP server
pip install fleet-rlm[full]     # All extras

2. Configure

Set up your Modal and LLM credentials:

modal setup
modal volume create rlm-volume-dspy
modal secret create LITELLM DSPY_LM_MODEL=openai/gpt-4o DSPY_LLM_API_KEY=sk-...

3. Run

# Interactive chat (requires OpenTUI / Bun)
fleet-rlm code-chat --opentui

# One-shot task
fleet-rlm run-basic --question "What are the first 12 Fibonacci numbers?"

# Document analysis
fleet-rlm run-architecture --docs-path docs/architecture.md --query "Extract all components"

# API server (FastAPI + WebSocket)
fleet-rlm serve-api --port 8000

# MCP server
fleet-rlm serve-mcp --transport stdio

Development Setup

# Clone and install
git clone https://github.com/qredence/fleet-rlm.git
cd fleet-rlm
uv sync --extra dev

# With server/MCP support
uv sync --extra dev --extra server --extra mcp

# Copy environment template
cp .env.example .env

# Quality gate
uv run ruff check src tests && uv run ty check src && uv run pytest -q

Documentation

Contributing

We welcome contributions! Please see our Contribution Guide and run the quality gate before submitting:

uv run ruff check src tests && uv run ty check src && uv run pytest -q

License

MIT License — see LICENSE.

Based on Recursive Language Modeling research by Alex L. Zhang (MIT CSAIL), Omar Khattab (Stanford), and Tim Kraska (MIT).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fleet_rlm-0.4.3.tar.gz (161.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fleet_rlm-0.4.3-py3-none-any.whl (201.4 kB view details)

Uploaded Python 3

File details

Details for the file fleet_rlm-0.4.3.tar.gz.

File metadata

  • Download URL: fleet_rlm-0.4.3.tar.gz
  • Upload date:
  • Size: 161.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fleet_rlm-0.4.3.tar.gz
Algorithm Hash digest
SHA256 b5622d94e26cb5a10766bd5d242fb81bd0e8c43b9665e9084a767bd8c0fcfd63
MD5 4e2e72266caa82384285ffce956cf34a
BLAKE2b-256 6c402045732ef6198d14f7f0f9be26a5cee5cc566660fddaedeef727e0ab29b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for fleet_rlm-0.4.3.tar.gz:

Publisher: release.yml on Qredence/fleet-rlm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fleet_rlm-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: fleet_rlm-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 201.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fleet_rlm-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 00648361da97ff0d23513fedc166e01abbc2a8f8f9ea0a273de876d4bbc1cbff
MD5 3a2bb42bde3a5cc330b2f8545d85d4ff
BLAKE2b-256 564eef19349cc3b6ef3eec09b6778ba11985e6bae26466e2fb80f6bfe9644428

See more details on using hashes here.

Provenance

The following attestation bundles were made for fleet_rlm-0.4.3-py3-none-any.whl:

Publisher: release.yml on Qredence/fleet-rlm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page