Skip to main content
Based on the paper Recursive Language Models (Alex L. Zhang, Tim Kraska, Omar Khattab - MIT CSAIL, 2025), Recursive Language Models (RLMs) resolve context window bottlenecks by storing long inputs as programmatic state inside an isolated Python REPL sandbox rather than stuffing millions of tokens into a single prompt. The orchestrator model writes Python code iteratively to filter, compute, and delegate semantic sub-tasks to worker models via llm_query(). Every reasoning step, REPL code execution, and sub-agent output streams in real time.

RLM Research Paper

Read arXiv:2512.24601 on the formal REPL-based Recursive Language Model architecture.

DSPy Integration

Configure Neosantara models with DSPy declarative modules and pipelines.

Architecture Comparison

Implementation Workflow

1

Install Sandbox Runtime

DSPy RLM executes generated Python code inside an isolated Deno runtime.
2

Configure Dual-Model Routing

Split responsibilities across two specialized models to balance capability and throughput:
  • Orchestrator (dspy.configure(lm=...)): A high-reasoning model (neosantara/deepseek-v4.1-flash) that plans investigation trajectories, generates Python code, and compiles final outputs.
  • Sub-Worker (sub_lm=...): A high-speed, cost-effective model (neosantara/gemini-3.8-flash) called inside the sandbox to process semantic text segments via llm_query().
3

Run Multi-Tenant Audit Scenario

The following production scenario aggregates transaction amounts, detects security anomalies, verifies compliance redactions, and streams the reasoning trajectory.

Code & Execution Streaming

REPL Sandbox Primitives

The orchestrator model has access to the following built-in primitives inside the execution sandbox:
Use llm_query_batched when classifying or evaluating multiple items. Sub-agent requests execute in parallel, reducing total latency.
The isolated Deno/WASM sandbox prevents arbitrary filesystem access and unauthorized outbound connections outside of the Neosantara LLM interface.