@pi-kaush/pi-simple-subagents
extensionmaintainedDelegate bounded tasks to isolated Pi subagent processes, with execution profiles, bounded delegation, process-tree cleanup, and resumable child sessions.
by — · v0.1.2 · published 2d ago
$ pi install npm:@pi-kaush/pi-simple-subagentsSignals
Download trend
No downloads in the last 12 weeks.
README
pi-simple-subagents
Delegate bounded tasks to isolated Pi subagent processes. Each invocation spawns
a separate pi process with its own context window; the parent collects
structured output and keeps its own context lean.
Despite the name, this is the full-featured subagent tool — "simple" refers to the contract: bounded tasks in, structured result out.
What it adds
subagent, an LLM-callable tool with three modes:- single — one agent, one task
- parallel — a
tasks[]batch with an optional shared immutablecontext - chain — sequential steps where
{previous}placeholders receive the prior step's output
- Execution profiles (
quick,coder,default,thinker,deep-thinker): ordered model-candidate ladders from the shared machine-local~/.pi/agent/profiles.yaml, shared with@pi-kaush/pi-agent-modeand@pi-kaush/pi-model-profiles. Profiles reload on file change — ladder edits apply to long-running sessions without a restart. - Model-facing discovery: user agents are read from
~/.pi/agent/agents/*.mdwhen the extension loads and listed alongside the execution profiles in the tool guidance. Agent names select behavior and tools; profile names select compute. When both appear in a request, their order does not matter:thinker redteamandredteam thinkerselect the same pair. - Bounded delegation: depth 2, five children per call, five active children per Pi session, at most thirty simultaneously active descendants. Completed children release their slots.
- Subtree-safe lifecycle: depth-1 children lead POSIX process groups; abort,
timeout, and session shutdown terminate the whole subtree (graceful then
forced). Windows uses
taskkill /T. - Child watchdogs: two hours total runtime and fifteen minutes without
output by default; either configurable in
src/limits.json,0disables. The orchestrator is never watchdogged. - Resumable child sessions: children persist real Pi sessions, named
subagent(<agent>): <task preview>. Expanded tool output shows the full session ID with api --session <id>resume hint and the session file path for livetail -fviewing. Disable withpersistChildSessions: false. - Transcript artifacts: every child's complete stdout/stderr streams to a
private JSONL artifact under
~/.pi/agent/subagent-runs/; tool details keep bounded previews and artifact paths. - Structured yield: delegated children finish through a terminating
yieldtool (completed,blocked,failed), with artifact paths; ordinary final assistant output remains a fallback. - Model resolution: before delegation, refresh Pi's authenticated model catalog
locally; select profile candidates and bare model overrides from that catalog, not
the parent's
enabledModels/scopedModelscycling list. An explicit model overrides an invocation profile, which overrides the agent'sprofilefrontmatter, then its legacymodelfield. Bare ids resolve family-scoped by nearest version; qualified refs pass through to the child for validation.
Agents
Agent definitions are Markdown files with optional frontmatter (emoji,
profile, model, tools, confirmProjectAgents). Declare either profile
or model, not both. Discovery:
- user:
~/.pi/agent/agents/*.md - project: nearest
.pi/agents/*.md, withagentScope: "project" | "both"
User agents are advertised to the parent model at extension load. Additions or
renames need /reload to refresh that catalog. Project agents remain dynamically
discoverable by exact name without being embedded in the global catalog.
Project-controlled agents prompt for confirmation before first use.
Configuration
src/limits.json bounds delegation (validated against hard ceilings):
{
"maxDepth": 2,
"maxChildrenPerCall": 5,
"maxConcurrency": 5,
"maxRuntimeMs": 7200000,
"maxInactivityMs": 900000,
"persistChildSessions": true
}
The model-profiles schema lives in
@pi-kaush/pi-model-profiles.