← Catalog

@ivannovr/pi-interactive-subagents

Interactive subagents for pi - spawn, orchestrate, and manage sub-agent sessions in tmux

Package

Install

Install with PiG

pig install npm:@ivannovr/pi-interactive-subagents

Install with Pi

pi install npm:@ivannovr/pi-interactive-subagents
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./pi-extension/subagents/index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 1.1.0 (README.md). PiG does not review it.

pi-interactive-subagents

Async subagents for pi, running in tmux panes. Spawn a sub-agent, keep working in the main session, and get the result steered back when it finishes. Fully non-blocking.

tmux-only fork with enhanced model management. Pi subagents inherit the main session's model by default, with per-session, per-project, and global configuration support.

See Acknowledgements for the upstream project, which also supports cmux, zellij, and WezTerm.

Installation

Requires pi 0.65.0 (tested) and tmux (official installation guide).

pi install npm:@ivannovr/pi-interactive-subagents

Run pi inside tmux:

tmux new -A -s pi
pi

How it works

subagent() returns immediately. The sub-agent runs in its own tmux pane — a right split off the parent pi pane, so pane creation never steals keyboard focus. A live widget above the input tracks every running sub-agent, and when one finishes, its result is steered into the main session as a notification that triggers a new turn.

╭─ Subagents ──────────────────────────── 2 running ─╮
│ 00:23  scout      active · bash 7m                 │
│ 00:45  scout-2    waiting 2m                       │
╰────────────────────────────────────────────────────╯

Spawn several in parallel — they run concurrently and steer results back independently as each finishes.

Panes are kept evenly sized: the extension re-applies an even-horizontal layout after every spawn and exit (debounced). The layout is a single constant, SUBAGENT_TMUX_LAYOUT in pi-extension/subagents/tmux.ts — change it to any named tmux layout (main-vertical, tiled, …).

If your shell startup is slow and launch commands get dropped before the prompt is ready, raise the delay:

export PI_SUBAGENT_SHELL_READY_DELAY_MS=2500   # default: 500

Differences from Upstream

This fork introduces the following changes:

Model Management

  • Session-aware model inheritance: Subagents use the main session's current model by default (via /model command)
  • Three-tier configuration system: Override models at session, project, or global scope
  • Inline settings UI: /subagent-settings uses Pi's editor region, with scoped settings and the native searchable /model picker
  • No hardcoded models: Agent definitions no longer specify models in frontmatter—all agents inherit or use configured overrides

Installation & Agent Management

  • Bundled fallback: Packaged agents (scout, researcher, worker) are available without copying files into your home directory
  • Discovery priority: Parent project (ctx.cwd) → global → package-bundled; custom agents override bundled agents by name
  • Non-destructive discovery: Opening settings or discovering agents never installs or overwrites agent files

Configuration

Model configurations are stored in JSON files at three scopes:

  • Session: <sessionDir>/artifacts/<sessionId>/subagent-models.json (session-specific, survives resume)
  • Project: .pi/subagent-models.json (version-controlled, team-shared)
  • Global: ~/.pi/agent/subagent-models.json (personal, cross-project)

Priority: Explicit spawn model > Session > Project > Global > Agent frontmatter > Live parent model > pi CLI default. Session paths come from the live session manager; --no-session disables only the Session scope.

See the original project for the full-featured multi-multiplexer version with cmux, zellij, and WezTerm support.

Tools

ToolDescription
subagentSpawn a sub-agent in a dedicated tmux pane (async)
subagent_messageMessage a sub-agent by name — steers it if running, resumes its session if finished or stopped
subagent_stopCancel a named descendant and its entire subtree; preserve history for resume
subagents_listList available agent definitions
ask_question(sub-agent sessions only) Ask the orchestrator a question and wait for the reply

Commands

CommandDescription
/subagent <agent> <task>Spawn a subagent directly from command
/subagent-settingsInteractive TUI for managing subagent model configurations
/subagentsLive descendant tree: name, role, status, elapsed; select and confirm stopping a subtree

Spawning

subagent({ agent: "scout", task: "Analyze the auth module" });
subagent({ agent: "worker", name: "dark-mode", task: "Implement the dark mode toggle" });
ParameterTypeDefaultDescription
agentstringrequiredWhich agent to spawn (must be known and permitted)
taskstringrequiredTask prompt
namestringagent nameDisplay name for the pane and widget. Omitted names are auto-suffixed (scout, scout-2, …); an explicit name must be unique in this parent session
modelstringresolved modelOverride the model for this spawn (bypasses configuration system)
cwdstringagent's cwdWorking directory (see Role folders)

Messaging

subagent_message is addressed by name only. Names are unique per session and persist after a sub-agent finishes, so the same name works either way:

subagent_message({ name: "scout", message: "Also check the auth middleware" });
  • Running — the message is typed into the live pane (newlines flattened) and picked up at the next turn boundary. The call returns immediately; the eventual completion still arrives as a steer message.
  • Finished — the session is resumed with the message as the follow-up task, like a fresh spawn: fire-and-forget, always autonomous, result steered back later. The resumed run reclaims its original name.

Every spawn records name → session file in artifacts/<sessionId>/subagent-registry.json, so names stay addressable across pi restarts. A nested sub-agent that spawns children gets its own registry keyed by its own session id. Resume is refused with a clear error (listing known names) if the name isn't registered, the session file is gone, or the session predates sandboxed resume.

Resume replays the original sandbox. At spawn time the fully-resolved loadout — tool allowlist, backing extensions, model, thinking level, system prompt, spawn whitelist, cwd — is snapshotted to <session>.loadout.json. Resume rebuilds the exact same restricted process from that snapshot rather than relaunching unrestricted.

Stopping and resuming

Stop a running sub-agent and all its descendants with subagent_stop. Resume it by sending a new message using its original name:

subagent_stop({ name: "dark-mode" });
subagent_message({ name: "dark-mode", message: "Continue from the saved work" });

Use /subagents to view the active descendant tree and stop a selected run interactively. Navigate with ↑/↓, select with Enter, and confirm cancellation.

Stopping preserves the agent's session history, name, and original sandbox configuration. Only your own descendants can be stopped.

Limitations:

  • Stopping does not revert file changes or guarantee cancellation of detached processes and external jobs.
  • Resume is unavailable if process cleanup could not be confirmed.
  • Sandboxed resume is supported for Pi agents only, not Claude CLI agents.
  • Process cleanup requires macOS or Linux (including WSL), tmux, and ps.
  • Resuming a parent session does not restore its previously running children.

ask_question

A sub-agent can ask its orchestrator a single freeform question when requirements are ambiguous or a decision materially affects the work. The session stays open (parked as waiting) instead of exiting; the parent is notified with the sub-agent's name, replies via subagent_message({ name, message }), and the reply arrives as the sub-agent's next turn. Parallel questions are supported — each waiting sub-agent has its own name.

If the reply arrives while the sub-agent is still mid-turn, it is absorbed into the current turn — either way the question is marked answered and the session exits normally when the work is done. If the parent never replies, the pane stays open until a human closes it. Only available inside sub-agent sessions.

Bundled agents

AgentToolsRole
scoutread, grep, find, lsFast read-only codebase recon
researcherweb_search, web_fetch, safe_bashWeb research, synthesized into a sourced brief
workerread, write, edit, bash, web_search, web_fetch + spawningGeneral implementer; may spawn scout and researcher

Note: All bundled agents inherit the main session's model by default. Use /subagent-settings to configure specific models for each agent at session, project, or global scope.

All three are autonomous (auto-exit: true) and carry their identity in the system prompt (system-prompt: append).

Custom agents

Place a .md file in .pi/agents/ (project) or ~/.pi/agent/agents/ (global). Discovery priority: project > global > package-bundled — a project-local file overrides a bundled agent with the same name.

---
name: my-agent
description: Does something specific
thinking: medium
tools: read, edit, write, safe_bash, web_search
session-mode: lineage-only
auto-exit: true
---

You are a specialized agent that does X...

Frontmatter reference

FieldTypeDescription
namestringAgent name (used in agent: "my-agent")
descriptionstringShown in subagents_list
modelstringAgent fallback model, used after scoped overrides and before the live parent model
thinkingstringminimal, low, medium, or high
toolsstringStrict tool allowlist. Built-ins: read, write, edit, bash, grep, find, ls. Extension-backed: web_search, web_fetch, safe_bash, video_extract, youtube_search, google_image_search. Only the extensions backing the listed tools are loaded into the child
subagent_agentsstringComma-separated agent names this agent may spawn. Presence of this field grants the spawning toolset (subagent, subagent_message, subagent_stop, subagents_list) and restricts spawn targets to the list. Omit it and the agent cannot spawn at all
skillsstringComma-separated skill names to auto-load
session-modestringstandalone (default), lineage-only, or fork — see below
system-promptstringappend or replace: pass the body as the child's --append-system-prompt / --system-prompt. Omit and the body is prepended to the task prompt instead
auto-exitbooleanAuto-shutdown when the agent finishes (see below)
interactivebooleanWhether stall/recovery transitions wake the parent (see below)
cwdstringDefault working directory
disable-model-invocationbooleanHide from subagents_list; still spawnable by explicit name
clistringclaude runs the agent via the Claude Code CLI instead of pi

Model Configuration

Use the /subagent-settings command to configure models for subagents interactively:

/subagent-settings

The entire flow stays inline in Pi's editor region—there are no centered overlays:

  • Three scope tabs (Session/Project/Global) — switch with Tab
  • Agent settings — navigate with arrow keys and press Enter to open that agent's actions
  • Choose model — opens Pi's native /model selector, including its search and keyboard navigation, with the agent's effective model preselected when available
  • Scoped actions — continue the inheritance cascade (inherit), explicitly follow the live parent (session), enter a custom model string, or remove the override; these are separate from the native model list
  • Remove shortcut — Delete or Backspace on the agent settings list removes the selected scope's override
  • Custom model editor — starts with the existing override and validates the model string before saving
  • Back navigation — Escape returns to the previous screen without saving; the selected agent and scope are retained
  • Immediate, scoped updates — successful edits affect only that agent in the selected scope, never the main session's model or Pi's default model settings

The native selector lists the models available through Pi's model registry. Use the custom editor for a model identifier not listed there. Cancelling either picker or editor leaves existing overrides unchanged.

Resolution priority:

  1. Explicit model parameter in subagent() call
  2. Session configuration (persistent for this session, including resume)
  3. Project configuration (<parent cwd>/.pi/subagent-models.json)
  4. Global configuration (~/.pi/agent/subagent-models.json)
  5. Agent frontmatter model
  6. Main session's current model (ctx.model, including later /model changes)
  7. No --model argument: let pi choose its CLI default

Automatic live-parent model inheritance applies to Pi agents. Agents using cli: claude retain the Claude CLI default unless an explicit, scoped, or frontmatter model is configured; session deliberately selects the Pi parent's model even for those agents.

A configuration value of inherit continues to the next scope. A value of session explicitly selects the live parent model, bypassing lower scopes and frontmatter. Removing an override also resumes normal cascading. Global paths respect PI_CODING_AGENT_DIR when set.

Opening settings does not create configuration directories. Session configuration is unavailable with --no-session; Project and Global remain editable. Malformed JSON, invalid model values, and read/write failures are reported rather than silently replaced. Updates use an atomic file replacement.

Example configuration file (.pi/subagent-models.json):

{
  "scout": "anthropic/claude-3.5-haiku",
  "researcher": "openrouter/google/gemini-2.0-flash-exp",
  "worker": "anthropic/claude-3.5-sonnet"
}

session-mode

  • standalone — fresh session, no lineage link to the caller (default)
  • lineage-only — fresh session with parentSession linkage for discovery/fork UX, but no copied turns
  • fork — child session seeded with the caller's conversation context

auto-exit

With auto-exit: true, the session shuts down when the agent's turn ends — the agent just writes its final message and stops (there is no "done" tool). The last assistant message becomes the summary returned to the parent. Recommended for all autonomous agents.

Notes:

  • Manual input does not strand an auto-exit sub-agent. If a human types into the pane, the session still closes once that turn completes normally — only an escape/abort leaves it open.
  • Auto-exit is suppressed while work is in flight: the session parks as waiting instead of exiting when an ask_question is still unanswered, or when the agent's own child sub-agents are still running (a worker can stop after dispatching children and stays open until the last result returns).

interactive

Controls whether stalled/recovered status transitions send a steer message to the parent session. Defaults to the inverse of auto-exit: autonomous agents get stall pings; user-driven agents stay quiet (the user is already working in that pane — the widget still updates). Set explicitly to override.

Tool access control

Access is whitelist-only. Every sub-agent process is launched with --no-extensions (extension discovery disabled) and --tools <allowlist>; only the extensions backing the listed tools are loaded back in explicitly. There is no default toolset and no deny-list — an agent gets exactly what its frontmatter lists. The restriction survives resume via the loadout snapshot.

Spawns must name a known agent at every depth. A top-level session may spawn anything discoverable; a sub-agent may only spawn the agents in its subagent_agents list (enforced via PI_SUBAGENT_ALLOWED). There is no agentless spawn route, so a child can never escalate to a full-toolset profile by omitting its agent.

Extensions can register additional tools for sub-agents at runtime via registerToolExtension(name, path) on the __pi_interactive_subagents process global.

Role folders

cwd starts a sub-agent in a directory with its own config, so role-specific setups (CLAUDE.md, skills, extensions) apply:

project/
└── agents/
    ├── game-designer/   ← CLAUDE.md, .pi/…
    └── sre/             ← CLAUDE.md, .pi/…
subagent({ agent: "worker", cwd: "agents/sre", task: "Review the deployment pipeline" });

Set a per-agent default with cwd: in frontmatter.

Status widget & configuration

The widget tracks each sub-agent from a runtime activity snapshot written by the child: starting, active (turn/provider/tool work), waiting (open for input or another stage), stalled (no valid snapshot for too long), or running (fallback). Sub-agent sessions also show their own tools widget — toggle it with Ctrl+Alt+O. Completion messages expand with Ctrl+O.

Status display is configured via config.json in the extension directory (copy config.json.example; it's gitignored):

{
  "status": { "enabled": true }
}

Development and releases

Requires Node.js 24.21.0 and npm 11.19.0.

Install dependencies and run validation checks:

npm ci
npm test
npm run check:package
npm run check:commits

The default tests and package checks run without model providers or live Pi/tmux sessions. To run integration tests explicitly:

npm run test:integration

Commits and PR titles follow Conventional Commits. Releases and versioning are managed automatically by release-please.

See RELEASING.md for the release workflow and publishing instructions.

Requirements

  • pi, tested with @mariozechner/pi-coding-agent and @mariozechner/pi-tui 0.65.0
  • tmux (this fork does not support other multiplexers)

Acknowledgements

Forked from HazAT/pi-interactive-subagents, which originated the subagent architecture, the multi-multiplexer surface layer, and the status widget; its supervision features were inspired by RepoPrompt.

License

MIT