Harness Notes

Subagents

Updated 2026-11-24,

On this page

How each harness starts and configures subagents, what they can see and change, which lifecycle hooks run, and how their transcripts are saved and read.

Worktrees: creation, setup, integration and cleanup

Starting one

Questionpichecked at 1.2.0
Is there one, and how does it start

Not supported

pi deliberately ships without subagents: its README says to build them yourself or install a package. The repo includes an example subagent extension. After you copy or symlink it into ~/.pi/agent/extensions/subagent/, the model can call a subagent tool when you ask ("Use scout to find all authentication code"), and the bundled prompt templates /implement, /scout-and-plan and /implement-and-review drive it.

Third-party packages in the pi package gallery (https://pi.dev/packages) add subagents too, for example pi-subagents and @tintinweb/pi-subagents.

Built-in subagents

Not supported

pi has no built-in subagent types. The example extension comes with four sample agent files you can install: scout (fast read-only recon on Haiku), planner (read-only implementation plans), reviewer (code review, with bash limited to read-only by instruction) and worker (general purpose, all default tools).

Define your own

Not supported

Core pi has no agent definition format. With the example extension, an agent is a Markdown file with YAML frontmatter in ~/.pi/agent/agents/*.md (user, always used) or the nearest .pi/agents/*.md (project, only used when the tool is called with agentScope: "project" or "both"). With "both", a project agent overrides a user agent of the same name. Files without a string name and description are skipped.

Agent files are re-read on every call, so you can edit them mid-session.

What a definition can set

Not supported

In the example extension, a definition sets only name, description, tools (comma list or YAML array, passed to --tools), model (passed to --model), and the Markdown body, which is appended to pi's system prompt. If you leave out model, the subagent inherits the parent's model and thinking level. There are no fields for permissions, MCP, skills or memory.

While it runs

Questionpichecked at 1.2.0
What it sees, and what comes back

Not supported

In the example extension, each subagent is a separate pi --mode json -p --no-session process. It gets pi's normal system prompt and context files, the agent's prompt appended, and Task: <task>, but none of your conversation. Only the subagent's final assistant text goes back to the parent model, capped at 50 KB per task in parallel mode. In chain mode, {previous} passes one step's output into the next step's task.

Several at once

Not supported

Core pi cannot run subagents at all. The example extension's parallel mode (tasks: [{agent, task, cwd?}]) accepts up to 8 tasks and runs at most 4 at once. Chain mode runs its steps one after another and stops at the first failure.

Keep working while it runs

Not supported

No. The example subagent tool call blocks until every subagent finishes, and its result then arrives as the tool result. Messages you type meanwhile are queued: Enter waits until the current tool calls finish, Alt+Enter waits until the whole task ends.

Gallery packages such as @tshu-w/pi-agents and pi-background-tasks advertise async/background agents.

Your checkout or its own copy

Not supported

There is no isolation. The example extension runs each subagent process directly in the parent's working directory, or in a per-task cwd you pass, so edits land straight in your checkout and nothing needs merging. pi has no worktree or sandbox support of its own.

Its permissions

Not supported

pi has no approval prompts or sandbox. Tools run with your OS user's permissions, and subagent processes are no different. A definition can only narrow the tool list (tools becomes --tools). The one prompt in the example extension is a confirmation before running project-local agents in an untrusted project, which confirmProjectAgents: false turns off.

For real containment, run all of pi inside a container or sandbox (see docs/containerization.md), or add the example permission-gate.ts or sandbox/ extensions.

Subagents of subagents

Not supported

The example extension has no depth limit or recursion guard. Each subagent is a full pi process that loads your user extensions, so an agent without a tools list (such as worker) gets the subagent tool too and can start its own subagents. An agent with an explicit tools list that leaves out subagent cannot.

Watching and handing off

Questionpichecked at 1.2.0
Watch, steer or stop one

Not supported

With the example extension, the tool row streams each subagent's live status, recent tool calls and token/cost usage. Ctrl+O expands it to show the full task, every tool call and the final Markdown output. Pressing Escape (Ctrl+C in the extension README) stops the current task and kills subagent processes (SIGTERM, then SIGKILL after 5 s). You cannot steer a running subagent.

@tintinweb/pi-subagents in the package gallery advertises mid-run steering.

Hand work to a cloud agent

Not supported

pi has no cloud or remote agent handoff. The closest options are running the whole pi process in a remote sandbox (for example NVIDIA OpenShell or Docker Sandboxes, per the containerization docs) or driving pi from your own code over --mode rpc or the SDK's createAgentSession().

Notes and sources

pi, 11 sources
Is there one, and how does it start, 4
Built-in subagents, 2
Define your own, 2
What a definition can set, 2
What it sees, and what comes back, 2
Several at once, 2
Keep working while it runs, 2
Your checkout or its own copy, 1
Its permissions, 3
Subagents of subagents, 2
Watch, steer or stop one, 3
Hand work to a cloud agent, 2

Subagent lifecycle hooks

Recorded start and stop events, with their control semantics and availability caveats. A dash means no event is recorded here. General session or tool events do not establish a dedicated subagent hook.

Which moments a hook can attach to, and what it can do there. Event names link to each harness’s documentation. “Block”, “deny” and “modify” change what the agent does; “observe only” can watch but not intervene. Where hook files live is on the Locations page.

MomentpiExtension event handlers
Hook typesExtension event handlers

Notes and sources

pi
  • In-process TypeScript extension events, run in extension load order; extensions run with full user permissions.
  • pi's documentation names its extension type definitions as the event reference.
  • Project extensions load only after the project is trusted.

Subagent transcripts

Child storage and parent links are described separately from the harness’s general session format. Internal and source-observed formats can change between versions; these records do not promise a stable external schema.

Questionpidocumented-public; checked at 1.5.2
Child transcripts and parent links

Partly

Pi has no built-in subagents. /fork, /clone and --fork write a new session file in the same project folder whose header parentSession holds the source file's path, while /tree branches stay inside the original file. The example subagent extension runs each child as pi --mode json -p --no-session, so child runs aren't saved as their own sessions.

Third-party subagent extensions can save child sessions any way they like.

Session file format

JSONL: the first line is a {"type":"session","version":3,...} header, and every later line is an entry with type, id, parentId and timestamp, forming a tree. The format is publicly documented in docs/session-format.md. Older version 1 and 2 files are migrated to version 3 automatically when loaded.

New entry types still appear (for example context_edit and usage), so parsers should skip unknown types and unknown usage kind values.

What is recorded

Version-3 JSONL stores a session header and a parentId tree of message, model/thinking changes, usage, compaction, branch summary, custom/custom_message, context_edit, label and session_info entries. Assistant content supports text, thinking, images and toolCall; toolResult messages match toolCallId. System messages record prompt/tool deltas. Optional cost.totalFromProvider distinguishes provider-billed totals from estimates, while context edits change replay without erasing original display/history entries. In 1.6.0, when showCacheMissNotices is enabled, the transcript displays the reasons OpenAI dropped reasoning items after compaction if the dropped count increased over the previous response.

The system prompt and tool list are saved too: the first request writes a full system message, and later changes are saved as deltas.

Compaction and context edits never delete the original entries; the file keeps the full history.

Read transcripts from code

The SDK (@earendil-works/pi-coding-agent) exports SessionManager with create, open, continueRecent, list, listAll, forkFrom and inMemory, plus tree and context helpers. pi --mode json -p streams a session header and then session events as JSONL on stdout. pi --mode rpc offers get_messages, get_entries (every entry, including abandoned branches and pre-compaction history, with a since cursor), get_tree, get_state (session ID and file), get_session_stats, export_html, switch_session and fork.

You can also parse the JSONL files directly; session-format.md includes a parsing example.

Session record structurepi
Envelope fieldstype, id, parentId, timestamp
Record discriminatortype
Identifiers and lineagesession header id (UUIDv7 by default, or custom via --session-id), entry id (8-char hex), parentId, parentSession (header, path of source session for /fork, /clone), targetId (label, context_edit), fromId (branch_summary), firstKeptEntryId (compaction), message.toolCallId
Orderingappend order in file; conversation structure is an id/parentId tree with the active leaf selecting the branch

Notes and sources

pi, 13 sources
  • 2026-11-15 source refresh: v1.5.2 at b4afdddf44e059c67ccf5097e5317d913521b470. Source inspection, not a harness runtime probe. Historical supplements keep their independent evidence and dates.
Child transcripts and parent links, 4
Session file format, 4
What is recorded, 5
Read transcripts from code, 5