pi-rlm-runtime
Recursive language model runtime for Pi
Package details
Install pi-rlm-runtime from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-rlm-runtime- Package
pi-rlm-runtime- Version
0.1.1- Published
- Aug 8, 2026
- Downloads
- 365/mo · 17/wk
- Author
- dhusni
- License
- MIT
- Types
- extension
- Size
- 93.3 KB
- Dependencies
- 1 dependency · 2 peers
Pi manifest JSON
{
"extensions": [
"./dist/index.js"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-rlm-runtime
A recursive language-model runtime for Pi, based on the architecture behind Prime Agent.
pi-rlm-runtime lets Pi work beyond a single conversation context. It can retain a large working set, delegate independent work to nested sub-agents, and bring the useful results back into the main conversation.
Install
Requires Node.js 22.19 or newer, Pi 0.84.x, and uv.
pi install npm:pi-rlm-runtime
Run Pi with pi-rlm-runtime
pi --rlm-runtime
Then use Pi normally. Ask it to delegate when a task has independent parts:
Review this codebase. Use sub-agents to inspect the architecture, runtime,
and tests in parallel, then reconcile their findings.
The runtime gives the agent a persistent working environment and the ability to create, message, inspect, and stop sub-agents. Each sub-agent has its own Pi conversation and state, shares the project directory, and inherits the parent model unless another is selected.
Sub-agents may create further sub-agents. Set the recursion limit when starting Pi:
pi --rlm-runtime --rlm-runtime-max-depth 6
The default depth is 4. The supported range is 0–16.
View active sub-agents
Active sub-agents appear as a nested tree above the editor. Press Ctrl+Alt+A or run /subagents to expand or collapse it. Dormant sub-agents are hidden, and expanded trees are capped at 12 rows.
Agent API
The runtime preloads two Python objects for the agent:
models = await rlm.find_models("sonnet")
reviewer = await rlm(
"Review the authorization flow and report concrete findings.",
name="auth-reviewer",
model=models[0].selector,
)
agents = await agent_message.list_agents()
await agent_message.send(
"Check the regression tests next.",
receiver_role="subagent",
receiver_name=reviewer.name,
)
await rlm.delete_subagent(reviewer)
rlm() returns when the sub-agent starts. Messages and shared files carry results back without copying the sub-agent's full context into its parent. If a sub-agent exits without sending a message, its final response or error is forwarded automatically.
rlm.find_models() searches the authenticated models available to Pi. Its selectors are exact; requesting an unavailable model fails instead of choosing a fallback.
agent_message.send() accepts parent, sibling, or subagent as receiver_role. Messages to more distant agents are relayed through the tree.
Python environment
The runtime uses a cached Python 3.11 environment managed by uv. To use another interpreter:
export PI_RLM_RUNTIME_PYTHON=/absolute/path/to/python
pi --rlm-runtime
The interpreter must provide IPython and ipykernel.
Development
npm install
npm run check
License
MIT