pi-extensions GitHub

pi-subagents

Delegate separate pieces of work to child agents: one can explore the code while another reviews the tests. The main session assigns the tasks and brings their results together.

Off by default. Until you opt in, the subagent tool stays inactive and its instructions stay out of the model's prompt. Each child starts with fresh context, not a copy of your conversation, and cannot spawn more children. Returned text is capped; full transcripts are saved for later inspection.

Use it

/subagents on         opt in — activates the tool and the orchestrator brief
/subagents off        opt out (running children keep going; new spawns stop)
/subagents            pick a running or queued child, then steer or stop
Use scout and reviewer in parallel: have the scout trace authentication and the reviewer inspect its tests.

A status widget above the editor lists the fleet. It is display-only. While enabled, the footer status line shows a live subagents: N running · M queued count. The enabled state lasts for the pi process (survives session switches, resets on restart).

Tool

subagent({
  agent,            // scout | reviewer | oracle | worker | researcher | custom type
  task,             // full prompt — the child cannot see this conversation
  description?,     // 3–5 words for the widget
  max_turns?,       // 1–30, may only lower the resolved cap
  timeout_ms?,      // wall-clock cap in ms (up to 2h), may only lower the resolved cap
})

Unknown or disabled types error. There is no general-purpose fallback.

Built-in types

Type Job Writes
scout Fast recon. repo_map → code_search → key files → compressed start-here. read-only
reviewer Reviews the diff (not the whole file). Findings with path:line, severity, verdict. No edits. read-only
verifier Independently reproduces a change. Runs the build, tests, and artifact, and reports observed evidence. write-capable (bash unrestricted)
oracle Second opinion. Challenge assumptions. Name what is missing. read-only
worker Implements a fully-specified change: edits files, runs checks, reports a diff summary. edit/write + full bash
researcher Web/docs research with cited sources and a concise brief. read-only

reviewer and oracle default to model: cross-family: the strongest model listed in ~/.pi/agent/router.json (frontier, then mid, then base) that is authenticated and from a different family than the parent (families are read from the model id, so openai/gpt-* and openai-codex/gpt-* count as one). A reviewer on the author's own family tends to share its blind spots. With nothing eligible, they inherit the parent and the result carries a note saying so. When the parent runs router/auto, family is taken from the router's last physical model (or the configured base before the first route). The rest inherit the parent model. A per-call model parameter (provider/id or cross-family) overrides the type's default. Read-only types get bash restricted to plan-mode's fail-closed allowlist. The worker is write-capable with prompt-level guard rails only (stay in scope, never commit/push/install, stop early on ambiguity). Builtins are pre-tuned: scout (10 turns, low thinking), reviewer (15/high), verifier (25/high), oracle (8/high), worker (30/high), researcher (12/high).

Custom types

.md files with YAML frontmatter, highest wins:

  1. <cwd>/.pi/agents/*.md — only if the project is trusted
  2. ~/.pi/agent/agents/*.md
  3. shipped builtins
---
name: writer
description: Implements a small approved change
tools: read, edit, write, bash
---

You implement the task. Do not spawn other agents.

A declared tools: list is honored for every agent (builtin or custom) and defines the child's exact toolset. Files that omit tools: get an explicit read-only allowlist (read, grep, find, ls, bash, the code-search tools, and the web tools) — never a blocklist, so no future mutating tool can leak in.

Full bash is granted only to write-capable agents: those that declare edit/write in tools:. Every other agent — builtin or custom, listed or not — runs bash under the read-only allowlist, so a "read-only" agent cannot rm -rf its way around missing write tools. enabled: false hides that name (including a builtin).

Copy-paste examples live in examples/custom-agents/ — a write-capable writer and a read-only docs-auditor. Drop them into ~/.pi/agent/agents/ (or <cwd>/.pi/agents/) to use them as subagent types.

v1 frontmatter: name, description, tools, model (exact provider/id, or cross-family), thinking, max_turns (1–30), timeout_ms (ms), enabled.

Limits

Notes

TypeSafe judgments (optional)

With a TypeSafe key (see pi-typesafe) three batched Jev judgments run; without one they are skipped silently — every path fails open.

node scripts/subagent-usage-report.mjs counts spawns, fan-out, triage, tokens and lossy handoffs from local sessions (see docs/workflow-evaluation.md).