← Catalog

pi-recursive

Pure Pi extension that lets Pi recursively call itself via a native rlm_query tool.

Extension

Install

Install with PiG

pig install npm:pi-recursive

Install with Pi

pi install npm:pi-recursive
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./extensions/recursive.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.6.1 (README.md). PiG does not review it.

pi-recursive

The pure Pi extension that lets Pi recursively call itself — a native rlm_query tool that delegates a bounded subtask to a child Pi agent with a fresh context window, down to a configurable depth.

This is the canonical recursion machinery. The ypi CLI wrapper is a convenience layer around this same extension (launcher defaults, a shell-compatible rlm_query with pipes/async, cost/session helpers). If you just want recursion inside plain Pi, install this.

Install

pi install npm:pi-recursive
# or try it for one session without installing:
pi -e npm:pi-recursive "Use rlm_query to ask a child what 2 + 2 is."

What you get

  • A native rlm_query Pi tool — no shell helper, no launcher, no jj required.
  • Recursive children share the active provider/model, bounded by depth, call count, timeout, and budget guardrails.
  • jj workspace isolation is used automatically when available; recursion still works without it.

The shell-compatible rlm_query command, async jobs, and CLI ergonomics live in the ypi wrapper package and are opt-in via YPI_SHELL_HELPER=1.

Configuration

Behavior is controlled through RLM_* environment variables. The pure extension honors:

VariableExampleWhat it does
RLM_MAX_DEPTHRLM_MAX_DEPTH=3How deep recursion can go (default 3).
RLM_CHILD_MODELRLM_CHILD_MODEL=haikuUse a cheaper model for sub-calls at depth > 0.
RLM_CHILD_PROVIDERRLM_CHILD_PROVIDER=anthropicProvider for sub-calls at depth > 0.
RLM_BUDGETRLM_BUDGET=0.50Max dollar spend for the recursive tree (requires RLM_JSON=1, the default).
RLM_TIMEOUTRLM_TIMEOUT=60Wall-clock limit (seconds) for the entire recursive tree.
RLM_MAX_CALLSRLM_MAX_CALLS=20Max total rlm_query invocations.
RLM_JJRLM_JJ=0Disable jj workspace isolation (used automatically when available).

The shell-helper guardrails and cost/session CLI commands (e.g. rlm_cost) documented in the ypi README apply only to the ypi wrapper package, not to this pure extension.

Compatibility

This extension is verified against @earendil-works/pi-coding-agent 0.79.4. The peer dependency is declared as ^0.79.4, so forward patch/minor Pi releases are accepted; the extension API surface used (ExtensionAPI/ExtensionContext/defineTool type imports) is stable across patches.

Source

Developed in the rawwerks/ypi monorepo; pi-recursive is the extension-only publish view of the same source.