@ferris1225/pi-subagents
Your best model thinks, cheaper models do the legwork: lead/worker orchestration for Pi with background subagents, retained sessions, and Git worktree isolation.
Package details
Install @ferris1225/pi-subagents from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@ferris1225/pi-subagents- Package
@ferris1225/pi-subagents- Version
7.0.15- Published
- Nov 30, 2026
- Downloads
- 3,463/mo · 894/wk
- Author
- ferris1225
- License
- MIT
- Types
- extension
- Size
- 486.6 KB
- Dependencies
- 0 dependencies · 4 peers
Pi manifest JSON
{
"extensions": [
"./index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-subagents
Your best model thinks. Cheaper models do the legwork.
Lead/worker orchestration for Pi: main plans and reviews, background subagents research and build on the models you choose.
Why
A frontier model is great at judgment and expensive at typing. pi-subagents keeps your main model on planning, review, and the final answer, and hands self-contained steps to subagents running on their own models, in their own context, in parallel.
- Delegates by default. Main gets a clear contract: research and bounded implementation go to subagents; main stays on decisions and review.
- Two focused roles.
researcheris read-only with citations;workerimplements, tests, and reports evidence. - Pick models from a menu.
/subagents-setupsets each role's model and thinking level in a few keystrokes. - Parallel and safe. Up to five background runs, each worker in its own Git worktree, integrated back serially without touching your index or HEAD.
- Retained sessions. Send a completed run a focused correction instead of starting over.
[!NOTE] The aim is less main-model usage, not fewer total tokens: briefs, separate contexts, and review cost tokens too. No savings benchmark is claimed.
Quick start
pi install npm:@ferris1225/pi-subagents
- Pick a capable main model with Pi's model selector. Main always owns review.
- Run
/subagents-setupand choose models for Researcher and Worker. - Give main your task. It dispatches subagents on its own.
Requires Pi ≥ 1.7.0 and Node.js ≥ 22.19.0.
Setup menu
/subagents-setup opens a plain menu. Pick a row, change it, and you're back at
the menu. Every change saves immediately.
Subagents · models & thinking
→ Researcher model Follow main (anthropic/claude-opus)
Researcher thinking medium
Worker model openai/gpt-mini
Worker thinking low
Reset both roles to Follow main · medium
Done
- Model opens a searchable list: type to filter, ↑/↓ and PgUp/PgDn to move, Enter to pick, Esc to go back. Follow main tracks whatever model the main window uses; any other entry pins the role to that model.
- Thinking lists only the levels the role's model supports. A saved level the
model can't run is clamped and shown as
low (high saved). - A pinned model that is no longer available shows
[unavailable]and pauses that role until you pick another. Main is never used as a silent fallback.
Settings live in ~/.pi/agent/pi-subagents.json (--agent-dir or
PI_CODING_AGENT_DIR overrides the directory):
{
"version": 2,
"researcher": { "thinking": "medium" },
"worker": { "model": "provider/model-id", "thinking": "low" }
}
A malformed file pauses new dispatches and is kept for you to fix; running
/subagents-setup repairs it, keeping valid role settings.
How it works
flowchart LR
U[You] --> M["Main model<br/>plan · review · answer"]
M -- brief --> R["researcher<br/>read-only"]
M -- brief --> W1["worker<br/>worktree"]
M -- brief --> W2["worker<br/>worktree"]
R -- answer + evidence --> M
W1 -- diff + checks --> M
W2 -- diff + checks --> M
- Plan. Main resolves the decisions that shape the approach and splits the work into briefs: outcome, facts, owned paths, acceptance criteria, checks.
- Dispatch. Self-contained steps go out in the background, independent ones
together in one
subagent({ tasks })call. Main keeps working or waits. - Review. Results arrive after worktree integration. Main checks the real diff, callers, and check evidence. A worker's "done" is a handoff, not approval.
- Correct or accept. Fixes go back to the same worker via its retained session. Main owns final checks, commits, and the answer.
Main stays in charge of design decisions, direct answers, reading 1–2 known files, quick 1–2 edit tweaks, and anything you ask it to do itself — keeping tightly coupled work cohesive instead of over-splitting. Questions and review-only requests never authorize edits.
| Role | Access | Returns |
|---|---|---|
researcher |
Pi's built-in read-only retrieval tools (read, grep, find, ls) plus proven read-only extensions and git_read; no edits or arbitrary commands |
Answer, Evidence, Gaps |
worker |
Main's live tools, including codemode, plus Pi's built-in retrieval tools (grep, find, ls) |
Status, Changes, Checks, Notes |
Children never delegate, bump versions, commit, push, or release.
Tools
subagent({
agent: "worker",
task: [
"Fix cache invalidation in src/cache.ts and its regression test.",
"Acceptance: a write invalidates the matching key only.",
"Write only src/cache.ts and test/cache.test.ts. Run the cache tests.",
].join("\n"),
});
| Tool | Purpose |
|---|---|
subagent({ agent, task }) / subagent({ tasks: [...] }) |
Start one run, or a batch of up to five independent runs |
subagent_status({ id }) |
Progress, result, session, and recovery details; omit id to list |
subagent_message({ id, message }) |
Steer a running child or give a finished run its next step |
subagent_stop({ id }) / subagent_stop({ all: true }) |
Stop one run or all active runs in this session |
waitis off by default in the TUI/RPC: runs work in the background and wake main when results land. Print/JSON sessions wait.- The same task in the same directory can't be dispatched twice while a run
owns it; reuse its result or continue it with
subagent_message. Active worker write scopes also reject overlapping writers, and main tool calls against files or searches owned by an active run (or duplicated within the same turn) are blocked until the run finishes or is stopped. subagent_messageusescontext: "auto"by default (the retained session, or a summary when it expired);"session"and"summary"force one or the other.- Long answers (over 40 lines or 8,000 characters) link a full-result file.
- Press Ctrl+O on a dispatch card to read each full brief, directory, and result.
Isolation and control
- Workers run in a detached Git worktree by default, snapshotting tracked and
untracked non-ignored files (including uncommitted work). Researchers are
read-only and always use your directory (
shared). Without a committed HEAD, automatic worker isolation falls back tosharedand says so. Force a worker's mode withisolation: "worktree" | "shared". - Integration applies only each worker's delta, one at a time per repository. Failures keep recovery artifacts. Worktrees isolate Git state, not permissions.
- Escape stops unfinished workers and shows their time, usage, and worktree status; finished workers still integrate. Session switches and shutdown keep interrupted evidence for recovery.
- The task widget shows status, elapsed time, model, thinking, tokens, and worktree state in at most ten lines.
- Confirmation dialogs in children are cancelled, never auto-approved. Provider failures return to main with evidence; the worker is not retried on main's model.
Storage
Runtime data lives in your OS temp directory (<tmpdir>/ferris-pi-subagents-<scope>/,
private 0o700 on POSIX), grouped by project — keeping ~/.pi/agent/ limited to
pi-subagents.json and letting system temp cleaners sweep abandoned state too.
- Settled sessions and overflow result files are removed on session exit, and empty project directories are pruned automatically.
- During active sessions, cleanup runs on startup, settlement, user turns, and a 15-minute periodic sweep: settled sessions expire after ~30 minutes (256 MB per project, 512 MB total), overflow result files expire after 24 hours (at most 20 files / 32 MB per project), idle project folders expire after 24 hours, and interrupted or failed-integration recovery records expire after 14 days once their processes are gone.
- Live work, parked recovery, and referenced artifacts are never removed. Legacy
~/.pi/agent/ferris-pi-subagents/directories are drained automatically when no recovery manifests remain.
/subagents-cleanup dry-run reports usage; /subagents-cleanup immediately
reclaims settled sessions and unclaimed artifacts.
Development
npm ci
npm run check # tsc + knip unused-code checks, then the test suite
npm ci installs a pre-commit hook that runs the unused-code checks
(tsc + knip) on staged files (npm run check:staged for custom hooks). Native integration tests use a local
fixture provider, so they make no paid model calls. Pushes to main run CI on
Windows, macOS, and Linux; a new version on main is published to npm with a
GitHub Release.
The prompt design draws on Devin Fusion, Antigravity's orchestrator, and Anthropic's multi-agent and context engineering write-ups.