@agwab/pi-subagent
Minimal subagent runtime for Pi.
Package details
Install @agwab/pi-subagent from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@agwab/pi-subagent- Package
@agwab/pi-subagent- Version
0.3.3- Published
- Jun 12, 2026
- Downloads
- not available
- Author
- toby_kim
- License
- MIT
- Types
- extension
- Size
- 679.7 KB
- Dependencies
- 3 dependencies · 3 peers
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
],
"image": "https://raw.githubusercontent.com/AgwaB/pi-subagent/main/assets/subagent-panel.png"
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-subagent
Minimal subagent runtime for Pi.
pi-subagent adds one focused tool: subagent. It gives Pi the essentials for isolated worker runs — parallel fan-out, sandbox/worktree controls, durable artifacts, and async status.
It is intentionally small, so you can add it to a project when you need subagents and remove it when you do not.
npm package: @agwab/pi-subagent
Installation
pi install npm:@agwab/pi-subagent
Then reload Pi.
Requires Node.js >=22.19.0 on macOS or Linux. Native Windows is not supported (POSIX process groups, tmux, and which-based Pi discovery); use WSL2.
For local development, add this package as a Pi extension source and reload Pi.
Quick usage
Use it when you want Pi to spin up a separate worker instead of doing everything in the parent session:
Run three reviewers in parallel for this change.
Run this check in a sandboxed worker and report the artifact paths.
Start a background audit and let me inspect it in /subagent panel.
What it does
Tool: subagent
Sandbox
Run workers in an isolated local execution boundary.
{
"sandbox": true,
"agent": "checker",
"task": "Run a local check and report the artifact paths."
}
sandbox: true denies all network access. Model-backed sandboxed runs must allow their provider endpoint explicitly:
{
"sandbox": { "allowedDomains": ["api.anthropic.com"] },
"agent": "implementer",
"task": "Make the requested local change and run the checks."
}
Worktree
Isolate parallel or mutating tasks in managed git worktrees. Workspaces default to shared; request worktree: true explicitly for tasks that mutate files in parallel.
{
"worktree": true,
"agent": "implementer",
"task": "Make the requested local change in an isolated worktree."
}
Agent
Inject Pi subagent markdown definitions from global or project agent directories.
{
"agent": "reviewer-security",
"task": "Review the current diff for security risks."
}
Agent markdown can live in ~/.pi/agent/agents/*.md or .pi/agents/*.md. Agent-level tools declarations are an authority ceiling; call-level tools can narrow them but not expand them. A systemPrompt override replaces the agent prompt body, not the agent's frontmatter policy.
Type
Use one structured schema for single, parallel, async, and existing-run calls. action defaults to run. Each execution is a run; each launch is an attempt.
Single:
{
"agent": "reviewer",
"task": "Review the current diff and summarize the highest-risk issues."
}
Parallel launches independent runs concurrently:
{
"tasks": [
{ "agent": "reviewer-security", "task": "Review the current diff for security risks." },
{ "agent": "reviewer-performance", "task": "Review the current diff for performance risks." },
{ "agent": "reviewer-test-coverage", "task": "Review the current diff for missing tests." }
]
}
Existing run:
{ "action": "status", "runId": "run_..." }
Panel
Inspect runs, attempts, artifacts, and log tails in a live TUI.
Open the run monitor:
/subagent panel

Code API
Orchestrators can use the same runtime directly:
import { runSubagent, getSubagentStatus } from "@agwab/pi-subagent/api";
const run = await runSubagent({ agent: "reviewer", task: "Review this diff.", async: true });
const status = await getSubagentStatus({ runId: run.runId });
Detailed docs
docs/usage.md— full argument reference, code API,actionbehavior, backend selection, sandbox/worktree behavior, artifacts, and validation notes.
