Skip to content

pi-subagents

The global System 1 configuration (/system1) sets an ordered chain of Jev and native OpenAI Decisions (Jev only by default). The legacy jev settings still control this feature, including its enabled flag and timeout; provider/model overrides apply only to Jev. Decisions requires pi-system1 and its isolated API credential; it uses API billing, not subscription OAuth. Pi does not verify credit funding. Operational failures can advance to the next configured backend with a notification; valid judgments and safety refusals do not trigger failover.

  • Use it for: Delegate independent report-back work to headless Pi processes, with fresh or forked context.
  • Enable: Select packages/pi-subagents/src/index.ts with pi config.
  • Controls: subagent run/status/result/steer/stop/resume; /subagents. No global shortcut; fleet and conversation controls below.
  • Settings: pi-subagents.json: 8 tasks, concurrency 4, depth 2; async off, fresh context, short child cache retention; FleetView on.
  • Requirements, cost & privacy: Runnable Pi and provider access; Git only for worktrees, created directly without a helper CLI. Each child uses model tokens; optional classifier selection sends task text externally. Transcripts/results and native Pi child sessions are stored locally. Optional sessionFile in run details names the actual native session, separate from the compact viewer transcript; it does not imply full tracking by external clients. See remote client compatibility.
  • Integrations & limits: Optional /tasks, consumed result waits, notebooks, planners and Herdr-child pills. Shared cwd is not isolation; headless workers cannot approve dialogs.

pi-subagents gives the agent a subagent tool for work that should return a result to the main conversation. Each child is a separate pi --mode rpc process with its own context window. Parallel execution does not imply separate files: children share the selected working directory unless you explicitly request checkout isolation.

Select packages/pi-subagents/src/index.ts using the suite installation guide. The suite enables every entry by default and uses one Git pin for every selected component.

Children need a working Pi runtime and access to their selected model providers. The component documents Pi 0.99 or newer for classifier support; consult the installation guide for the suite’s tested host version. Optional worktree: true requires Git and a suitable repository; it calls Git directly, not an external worktree helper.

Costs: each child consumes model tokens independently. Usage and model cost are included in tool results and session totals. When agent, model, or effort choices remain open, optional selection can make a billable classifier request per task through Pi’s model registry. Missing classifier access uses role fallback baselines and then balanced/medium; with no usable model mapping it retains the parent with a visible notice. This does not make child model execution free. Disable selection with jev.enabled: false if you do not want those classifier calls.

action: "run" is the default. Choose one task shape:

  • task: one self-contained assignment, with optional label, agent, model, and thinking.
  • tasks: parallel task objects, each accepting task, label, agent, cwd, model, and thinking. Defaults allow eight tasks with four executing concurrently. Boundary quota snapshots affect automatic model and effort picks, not configured concurrency.
  • chain: sequential task objects. {previous} inserts the preceding output; the chain stops on its first failed step.

Example arguments for independent read-only reconnaissance:

{
"action": "run",
"tasks": [
{
"agent": "general",
"task": "Read the authentication code and report its entry points. Do not edit files."
},
{
"agent": "general",
"task": "Read the authentication tests and report coverage gaps. Do not edit files."
}
],
"async": true,
"context": "fresh"
}

async defaults to false. When true, the call returns IDs immediately and later delivers subagent-result messages that start a turn; the first line names the runs and how they ended, which is what herdr-web-ui’s chat shows on the collapsed message. Ending the turn with an async call still running keeps the turn open (Herdr, tmux and Pi keep showing it working, with Waiting on …, a herdr:waiting hold and the $wait pane token); typing, a queued message or Esc ends the wait, and the result then arrives as a message. The wait has no timeout and applies in the TUI only; with pi-bg loaded, pi-bg’s single turn-end wait does it. A result already due when the turn ends goes into the same run; otherwise results due during a main-agent turn wait until it settles. Use context: "fork" to seed children from the current conversation rather than fresh context.

Control an existing run with action: "status", "result", "stop", "steer", or "resume". These take an id or unique prefix; status without an ID lists live and recorded runs. Status and result also read a run known only from its record, and result notes when a stopped or lost run’s output may be partial; steer and stop need a live run. Steering additionally requires message:

{
"action": "steer",
"id": "RUN_ID_FROM_RESULT",
"message": "Prioritize missing authorization checks; keep this read-only."
}

resume continues a stopped or lost run, or one that failed on the account’s rate limit, as a new run with the same agent, model, thinking level, working directory and mode, labelled <label> (resumed). Its task is the original task, a section headed “You were interrupted before finishing. What you already did:” holding a compact transcript of the old run, and an instruction to check the working tree before redoing anything and to continue from where it left off. The new run starts from fresh context.

A run that ends on the account’s rate limit (rate_limit_error or HTTP 429, after Pi’s own retries) is recorded as failed with the error account rate limit reached; resume it after the window resets, and its result names resume. Nothing retries it automatically.

cwd changes the working directory. worktree: true runs git worktree add into <repo>/.worktrees/subagent-<slug>-<id> (branch subagent/<slug>-<id>) for isolated task checkouts. Request that deliberately; a separate context alone is not an editing boundary.

Built-in roles work without agent files. They define scope and tools; their per-provider model and effort entries are fallback baselines, not assignments or ceilings. A valid task judgment can independently choose a cheaper or stronger model and lower or higher effort for any built-in role. See Choosing subagent models for the full Google/Muse baseline table and the distinction between policy and vendor evidence.

Role For Anthropic fallback OpenAI / legacy Codex fallback Tools
general anything no other role fits balanced / medium balanced / medium read, edit, bash, codemode, bg
explorer recon, search, tracing code Sonnet 5.5 / low Luna 6 / high read-only
worker implementing a clear spec, running checks Sonnet 5.5 / medium Terra 6.1 / medium read, edit, bash, codemode, bg
reviewer independent review of changes Opus 5.5 / high Sol 6.1 / high read-only
researcher web and documentation questions Sonnet 5.5 / medium Terra 6.1 / medium default
writer docs, summaries, write-ups Sonnet 5.5 / medium Terra 6.1 / medium read, edit, bash, codemode, bg
planner design and hard analysis without edits Opus 5.5 / high Sol 6.1 / high read-only

worker, general and writer get a fixed tool list (read, bash, edit, write, grep, find, ls, codemode, bg_*); MCP tools stay reachable through codemode.

Read-only roles get read, grep, find, ls, and bash; their no-edit policies are instructions, not filesystem sandboxes. A stale built-in model can use the newest registered model in its routed family. Astra and Fable are eligible automatic premium choices when registered and the delegated task justifies them; there is no role or parent-model cap. This is routing policy, not a measured claim that a higher tier improves every answer.

Agent definitions live in ~/.pi/agent/agents/*.md and the nearest project’s .pi/agents/*.md; project definitions win, and a definition replaces a built-in of the same name whole. Frontmatter takes name, description, optional tools, models, model, thinking, and maxTurns (also max_turns); the body extends the child’s system prompt. models maps providers to provider/id, optionally suffixed with a thinking level:

models:
anthropic: anthropic/claude-sonnet-5-5:low
openai-codex: openai-codex/gpt-6-luna:high

Each field resolves independently: explicit call argument > fixed user/project agent-file default > valid classifier task judgment > built-in role baseline > balanced model / medium effort > parent model when no mapping exists. User/project agent definitions replace built-ins whole; their model/effort pins stay fixed and suppress only that field’s question. A named built-in still gets task-specific model and effort questions when choices are open. The selected classifier judges only the delegated task; parent_request gives context, not extra work. A role name, lengthy specification, many files, tests or a critical parent project alone is no reason to escalate, but substantial unresolved difficulty can warrant premium capability or xhigh effort. Implicit models stay on the parent’s provider, and explicit model may cross it. One classifier request carries the remaining questions for each task.

At a turn limit, the child is asked to finish without further tools. If it continues calling tools, it is stopped with potentially partial output. A role description calling an agent read-only is not an operating-system sandbox.

Global settings are ~/.pi/agent/pi-subagents.json, overlaid by .pi/pi-subagents.json in the working directory. This example disables classifier selection and reduces concurrency:

{
"jev": { "enabled": false },
"maxParallel": 8,
"concurrency": 2,
"widget": "off",
"fleetView": true,
"maxDepth": 2,
"childCacheRetention": "short"
}

Optional providerTiers maps provider names to fast, balanced, strong, and optional premium model IDs; the legacy tiers map remains supported. Provider-specific entries win over matching legacy entries, then registered presets. Only same-provider, physical-chat candidates on the selected route enter automatic tier questions; absent tiers are not offered, and a sole usable candidate needs no tier classifier question. Tiers can share a physical model when no verified intermediate is registered. Newest uses numeric-aware IDs, with an undated alias ahead of dated snapshots; OpenAI Luna/Terra/Sol prefer the parent’s generation when registered. An explicit call model can cross providers.

Route (parent provider and ID family) fast balanced strong premium if registered
anthropic Haiku Sonnet Opus Fable
openai, openai-codex (retain provider ID) Luna Terra Sol Astra
google/gemini-* stable versioned Flash-Lite stable versioned Hydrogen/Flash stable versioned Argon/Pro stable versioned Carbon
google/antigravity-gemini-* stable versioned Hydrogen/Flash stable versioned Hydrogen/Flash stable versioned Argon/Pro stable versioned Carbon
google/antigravity-claude-* Sonnet Sonnet Opus —
muse-code versioned Standard Spark versioned Standard Spark versioned Standard Wonder —

The families come from one shared table that pi-plan-mode also carries, with an optional user file (see Model families); built-in roles name a tier and an effort, and a family the table does not rank yet is placed provisionally by registry price (never premium). Google plain Gemini, Antigravity Gemini and Antigravity Claude remain separate routes even though the last two share provider google. Automatic Google/Muse matches exclude preview, experimental, specialized/media and contributor variants; Muse’s bare muse-spark alias can resolve to the catalog default (currently Wonder), so use versioned Standard IDs for deterministic routing. No verified registered Muse premium ID is assumed; deliberate explicit overrides remain available. Unknown/local providers such as MTPLX and LM Studio have no invented hierarchy. For built-ins without a usable classifier answer, use the role fallback (or balanced/medium); if the model ultimately remains the parent due to no mapping, (parent) appears beside it and parent fallback: ... appears in plain results and the run note. The same marker is not attached to a deliberate premium selection equal to the parent. A missing model tier does not prevent effort classification. Haiku’s fast pick is guarded when context forks or exceeds 100,000 tokens (not Haiku: forked context). tierDescriptions customizes capability descriptions. Jev defaults to typesafe / jev-latest and a 3000 ms timeout.

The classifier answers only the offered tier choices (fast, balanced, strong, premium when registered) and effort (low, medium, high, xhigh) as separate probability distributions. Each uses the highest option whose cumulative probability at that level or above reaches theta, else the lowest. theta = relaxed + (tight - relaxed) * p, configured by jev.threshold (default 0.5 and 0.85). Selection reads quota for the execution target: shared windows for automatic tier selection, target-specific windows for fixed-model effort. Unavailable, disabled or unsupported pressure is neutral, not healthy. Higher pressure raises the bar for stronger automatic choices; explicit fields win. See Choosing effort.

delegation sets the tool’s first prompt guideline. economical (the default) recommends task-calibrated delegation with a precise spec and review; conservative prefers direct work and delegates only clear wins. Both add a one-line guide to choosing a role. The setting applies at extension load and session start, not per call.

widget accepts off, background, or all; fleetView: false disables the list below the prompt. maxDepth: 2 allows children to delegate once more, but removes the tool from grandchildren. childCacheRetention sets each child’s PI_CACHE_RETENTION: short (the default; 5 minutes on Anthropic), long (1 hour), or inherit to keep the parent’s. Children run quick turns and are discarded when done, so the 1-hour tier’s higher cache-write price rarely pays off for them even when the main session uses it.

In a prompt, @subagent:<name> names an agent role. Where the running Pi supports autocomplete providers, the TUI lists discovered agents after @subagent:. A mention adds a hidden message describing that agent (description, tools, model, thinking level) and asking the model to delegate the relevant part with the subagent tool. An unknown name is reported with the agents that exist. A mention never starts a run by itself.

@run:<label-or-id> references one of this session’s earlier runs, live or known only from its recorded run entry after a reload or /resume. Autocomplete after @run: lists runs newest first, filtered by id, task label or agent role. Completion inserts the label as a slug (@run:audit-cache-invalidation, example) when no other run shares it, otherwise the id. A token resolves by id, unique id prefix, or case-insensitive label slug.

A referenced run is delivered as a hidden message, not shown in the conversation: its label, agent, id, status, model and thinking level; its task; its final output (from memory or output.md); and a compact transcript rebuilt from messages.jsonl, with thinking dropped and tool calls on one line. A still-running run says it has no result yet. The message marks the content as untrusted background and tells the model not to repeat the run unless asked. Unknown tokens list the runs that exist; a label shared by several runs lists their ids instead.

Sizes are capped per run at 4,000 characters of task, 12,000 of output and 8,000 of transcript (400 per transcript line; a longer transcript keeps its start and end), and at 48,000 characters for all references in one prompt, after which further runs are named as left out. These characters do enter the model context of that prompt. A reference never starts or repeats a run, and only subagent runs can be referenced, not other Pi sessions.

/subagents lists live and recorded runs. /subagents <id> opens a run’s session, /subagents stop <id> stops a run, and /subagents stop all stops running children.

/subagents stats summarizes this session’s delegation; /subagents stats all covers every session under ~/.pi/agent/sessions ($PI_CODING_AGENT_DIR/sessions), using the latest record of each run. It shows the run count, the share of runs by where the model came from (explicit, profile, tier, default, or unknown for records from before the source was kept), runs with median and total cost per role, runs and median cost per turn per model, failed and rate-limited runs, and total cost. The tool tells the main agent to pass a role and leave model and thinking empty unless you pin one or need a deliberate override; provenance shows which choices were classified, fixed or inherited. Each run record carries source: { model, thinking }.

With pi-select-nav, Tab selects the fleet panel when no next-prompt is accepted, then cycles runs, hosted pills and main while preserving drafts. Once the panel is selected, Ctrl+J and Ctrl+K cycle the same rows, forward and back; from the prompt they stay the editor’s. Esc returns to the editor. In the TUI fleet list, Enter opens a child, x twice stops it, and b moves a foreground run to the background. In fullscreen mode, where Pi passes mouse events to widgets, clicking a row does the same as Enter on it, both below the prompt and in a subagent’s session list.

When exactly one worker is running and main is idle, waiting on its foreground subagent call, or holding a pi-bg wait, its conversation opens automatically. Queued future steps and finished history do not count; a sequential chain follows each active step. Main’s prompt must be focused and empty, with no dialog, autocomplete or unfinished modal command. Two active workers keep main visible. Main’s model request takes priority from preparation through its last token, even if a nested background wait remains alive briefly after its parent tool returns.

An automatic view returns to main when the worker finishes, another worker becomes active, or main resumes. Scrolling, typing and steering do not pin it; unsent drafts stay with the worker. Esc returns to main and suppresses reopening that worker until it ends. Explicitly opening a worker or switching to another worker is manual and stays open on completion. Main’s questions and approvals take priority: a manual viewer temporarily yields the screen and keyboard, then restores its draft and scroll position.

A child opens as a session of its own, drawn the way Pi draws main: Pi’s own message and tool components, Pi’s working row, queued steers, your editor (pi-vim’s when loaded), the same subagent list with that session marked ◉, and your footer. With pi-status-footer, the footer and the editor’s context gauge describe the child. Pi runs one live session per process and children are separate processes, so, as in Claude Code and Codex, this is main’s screen drawn for another thread. Type and press Enter to steer it; Tab and Shift+Tab, or Ctrl+J and Ctrl+K, switch to the next or previous session (past the ends is main); Esc goes back to main (with pi-vim and a draft, Esc first leaves Insert mode), as a dim line over the list reminds you; ↓ at the editor’s end enters the list, where Enter switches; Ctrl+C clears the editor and, on an empty one, twice stops the child. Your scroll keys, the mouse wheel, app.tools.expand and app.thinking.toggle work as in main. An ended run has no editor; a line says how it ended. Optional label names a task in lists and headings; when omitted, a short label is derived from the task text. Headless workers cannot use planning, user-question, or interactive-child tools. Extension dialogs are cancelled and returned as blockers, never forwarded to your UI or automatically approved.

Worker events carry tool data, not extension renderer functions. The viewer retains Pi’s native built-in tool cards and gives unknown tools compact humanized names with labeled argument previews. Expansion shows bounded nested fields and literal multiline values. Results preserve literal text and images; when no text is available, structured details are shown readably, with working, error and empty states kept distinct. These are local display fallbacks, not a reconstruction of the worker’s extension UI, and do not change tool arguments, JSON result content, stored messages or routing IDs.

Session-switch keys yield to autocomplete and Vim EX, pending-command and Visual states. Ctrl+U/Ctrl+D remain composer controls outside idle Normal mode, and viewport bindings respect rebinding or disabling. Hosted-view paging scrolls the worker rather than main. List selection and two-press stop confirmation track the row and live worker identity, not its position; questions, notes, approval messages and diff comments never become Fleet navigation targets.

Returned replies are capped at 2000 lines or 50 KB. Full output is saved under ~/.pi/agent/subagents/<id>/output.md, alongside messages.jsonl. Recorded transcripts remain inspectable after reload or resume.

/reload keeps running children. The old runtime parks every call whose result is still owed in a process-wide registry keyed by the session file, and the reloaded extension adopts them: they are listed, steerable and stoppable again, bg_wait subagent:<id> works on them, and each call’s result is delivered once, as a message, by the new runtime, including a result that came due during the reload. A foreground call in flight at the reload returns at once; its runs continue in the background and their results arrive as messages. Queued parallel tasks and later chain steps do not start after a reload, and the result says how many never started. Parked runs that no runtime adopts within 30 seconds are stopped.

Any other session end (/new, /resume, /fork, quitting) stops running children, after recording each as stopped with the reason, such as stopped: session replaced (/new). A record that still says running while no runtime owns the run, for example after a crash, reads as lost. Either can be continued with resume.

With pi-bg, /tasks includes children and bg_wait accepts subagent:<id> for async work. Waiting returns the bounded worker output and consumes it, suppressing a duplicate completion message. Each async call is also published to pi-bg as one subagent-call:<n> outside work with settle: true whose result is the result message; pi-bg’s turn-end wait takes it and acknowledges it with bg:external-consumed. Reading a completed run with subagent result also consumes it; running snapshots do not. pi-marimo, pi-plan-mode and pi-herdr can contribute notebook, planner/scout and interactive-child activities. /tasks lists all enabled sources; FleetView hosts their pills. Stop is owner-specific: a Herdr-child stop interrupts an awaited turn, never closes its pane; /stop remains shell-only. pi-herdr can display pending async work through $bg; no Herdr pane is needed for ordinary subagents. status and result calls are declared reads on the pi-plugins.read-only-call.v1 channel, so pi-tool-gate’s chat workflow lets them run. Before each child starts, pi-subagents asks the pi-plugins.subagent-env.v1 event channel for extra environment; pi-sidebar uses it so the subagents Sidebar starts run under its read-only guard. pi-plan-mode can ask which model and effort a role gets by emitting subagents:role-model with { role, parent, thinking? } (parent is provider/id); pi-subagents answers synchronously in reply: { model, thinking, source }, with no classifier call (the role baseline, else balanced/medium, else the parent’s model with fallback provenance); without a task it cannot classify task difficulty. Plan mode uses it to pick the explorer model for planner scouts when no scoutModelMap entry applies.

By default (delegation: "economical"), delegate parallel, larger-than-one-context, or routine long-tail work to a subagent with a precise spec and no model or thinking, then review the result; keep the rest in the main session. With delegation: "conservative", prefer direct work for routine investigation, diagnosis, and verification, and delegate only genuinely independent tasks with a clear payoff or when requested. Either way, avoid redundant audits, and prefer these headless children for report-back tasks. Choose pi-herdr’s interactive children when a person needs an ongoing session to take over. See background work, activity integration, and troubleshooting.

Source and tests cover RPC children, turn limits, result delivery, reload handoff, and the TUI views. The routing eval is an optional, paid classifier-only fixture check: 24 archetype/provider cases, three repeats by default (72 calls), with a planned one-repeat full-matrix follow-up (24 calls) only after a bounded correction and consumption check; the plan caps that sequence at 96, and authorization at 100 Jev calls total. Run npm run -s eval -- routing --dry to inspect planned calls without spending. It measures tier/effort agreement and over-/under-escalation, not coding success or cost savings. The first live 72-call Jev fixture run recorded 68/72 joint matches (94.4%), 68/72 tier matches, 72/72 effort matches, 24/24 hard-task matches, no call failures, and no defined over-/under-escalations. All four misses were specified implementation tasks routed fast rather than balanced/strong. Reported spend was $0.0000, which does not establish that calls were free. These are observed Jev fixture-routing results, not evidence of equivalent Decisions calibration, model quality or coding-task outcomes; the acceptance threshold passed, so the reserved follow-up was not run.