omp packages

@jadelclemens/pi-archimedes-subagent2.16.3

Subagent dispatch with live TUI streaming and cost tracking

jadelclemens Published 2 days ago ~329 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

@jadelclemens/pi-archimedes-subagent

Give your agent some backup.

Big thinking and multi-file refactors are expensive to do in the main line. Subagent lets your agent delegate that work: it dispatches child agents — singly or in parallel — with a model and tool set of your choice per role, streams their progress live, and books their tokens and costs into the same status bar. You watch the whole team at once.

Install

Standalone:

pi install npm:@jadelclemens/pi-archimedes-subagent

Or the full suite instead:

pi install npm:@jadelclemens/pi-archimedes

New to Pi? Pi itself is a one-time global install and needs Node.js ≥ 22.19.0:

npm install -g --ignore-scripts @earendil-works/pi-coding-agent

After installing Pi, choose one installation command above, then cd into your project and run pi. Inside the session, /login signs you in and /model picks a model — the setup section covers the first run. /reload picks the dispatch tool up in a running session.

Subagents parallel streaming view

Dispatching

Config-less — omit agent

The agent field is optional — omitting it is not a built-in default agent, and no agents are shipped with the package. Without an agent file, the model falls back to the per-call model override and then the parent's active model, and tools follow Pi's normal selection at spawn — except the subagent tool itself is always excluded, so a worker can't spawn workers. Prefer a dedicated named agent (list_agents shows the available names): a call with no agent is rejected with instructions for confirming an intentional generic run, and in a batch that check applies to each task and rejects the whole batch before anything launches:

{
  "task": "review the uncommitted changes and list the risks",
  "model": "openrouter/anthropic/claude-sonnet-4",  // optional per-call override
  "cwd": "/path/to/project"                        // optional working directory
}

The dispatch waits. A call — single or parallel — blocks until every task completes and returns the combined results, each optionally carrying the child's childSessionId. There is no async mode: an async parameter was deleted in #114 because the schema declared it and the implementation ignored it, and a parameter the model is told about but nothing reads is a false promise. Implementing fire-and-forget is deferred to #113; until then, batch the work into tasks and let the call block on all of it. In parallel mode each result section carries the child's final output beneath its metrics line.

Tool exclusions

excludeTools: ["ask"] denies that exact tool name in a single child or, at the top level of a batch, in every child. Each batch task may add its own excludeTools. The inherited, batch-wide, and per-task lists are combined; omission or [] never clears an inherited denial, so descendants can add exclusions but never remove them. Exclusions apply after agent frontmatter and delegation restrictions and carry through to descendants. Each list and the combined set may contain at most 64 names. Names are case-sensitive, 1–128 ASCII letters, digits, underscores, dots, or hyphens, and start with a letter, digit, or underscore. Invalid input, or an unreadable inherited policy, rejects the whole dispatch. Desktop bridge dispatch cannot carry a deny list, so it refuses a call that sets one. This controls Pi tool availability, not what shell commands or trusted extension code can do.

Trusted tool_call handlers can add to event.input.excludeTools in place before subagent executes. Preserve existing entries when adding new ones. The dispatch validates the final input even when Pi does not revalidate hook mutations.

Model and thinking resolution

Per dispatch, the model resolves in order: the agent config's model, then the per-call model, then the parent's active model (the first entry doesn't apply to config-less dispatch).

The thinking level is not inherited from the parent session's active thinking. It comes from the agent file's explicit thinking when present; otherwise Pi works out its own (the selected model, its configuration, or the model's default).

Sync vs async: When you cannot continue until every child has finished, omit async (the default). A parallel tasks dispatch blocks until all children complete and returns each summary inline — do not poll with bash or Await. Use async: true only when you have independent work to run in parallel.

Event-driven delivery: Set notifyOnComplete: true on each root-launched async child that should wake the root session when done. Opted-in children from the same dispatch are batched into one sendMessage (not a user message) once they have all finished. Nested delegators cannot receive these notifications, so they must omit async whenever they need a child result. Omit notifyOnComplete to skip auto-delivery and use subagent_fleet({ action: "result" }) instead.

{
  "async": true,
  "tasks": [
    { "agent": "researcher", "task": "find usages", "notifyOnComplete": true },
    { "agent": "reviewer", "task": "review plan", "notifyOnComplete": true }
  ]
}

Agent files

Named agents are .md files with YAML frontmatter — a complete definition:

---
name: reviewer
description: Reviews diffs and flags risks before code lands
model: openrouter/anthropic/claude-sonnet-4
tools: read, bash
thinking: medium
---
You are a meticulous code reviewer. Read the diff, flag real risks,
and name the lines you checked.
  • name and description are required — a file without them is skipped. tools is a comma-separated string. The markdown body is the agent's system prompt.
  • Scopes, in precedence order: project (<repo>/.pi/agents/), user (~/.pi/agent/agents/), and global — the repository's .agents/agents/ or, falling back, ~/.agents/agents/.
  • Unknown frontmatter fields are preserved on edit, not interpreted.
  • Model and thinking picked in the /agents TUI are saved to ~/.pi/agent/agents.local.json (machine-local, not committed), take precedence over the frontmatter, and are stripped from the .md on save. Hand-written model:/thinking: in frontmatter remain the fallback.

Named agents

With an agent name, the dispatch runs under that defined agent file — no agents are bundled, so the name must exist in one of these files. Unknown names are refused and list the available agents, so a typo fails cheap:

{
  "agent": "reviewer",
  "task": "review the PR diff"
}

Parallel work

Independent tasks go in a tasks array — mix defined agents and config-less tasks, distinct models, one call:

{
  "tasks": [
    { "agent": "reviewer", "task": "review the proposed migration plan" },
    { "task": "find all usages of the deprecated API" }   // config-less — the model/tools fall back as above
  ]
}

The /agents command

Available with the suite (and subagent enabled), /agents opens the interactive manager: a searchable list, model and tool pickers, cross-scope collision warnings, and dirty-tracking on save.

Subagents agent details view

Model selection Tool selection

Delegating agents

Subagents cannot delegate by default. To make an agent an explicit delegator, give it the relevant tools and set allowSubagents: true:

---
name: delegator
description: Breaks a bounded task into child tasks
tools: subagent, subagent_fleet, list_agents
allowSubagents: true
maxSubagentDepth: 2 # optional: at most 2 layers of descendants below this agent
---

tools is a strict allowlist. For delegating agents (allowSubagents: true and subagent in tools), the spawner automatically appends request_depth_grant and request_depth_exception so they are reachable; non-delegators have subagent and both depth tools excluded.

The delegation tree cap is seeded at the root from the maxDelegationDepth setting (default 5). A subagent at depth d may delegate while d <= cap, so the deepest subagent a cap of M allows sits at depth M + 1 and cannot delegate further.

maxSubagentDepth frontmatter is optional tightening only and is relative to the agent it is set on: maxSubagentDepth: N means this agent may have at most N layers of descendants below it ("layers below this agent"), not an absolute tree depth. It can only lower the effective cap for the agent's subtree, never raise it — when the agent's position plus N reaches past the inherited cap, the inherited cap wins. Leave it unset to pass the inherited cap through unchanged.

This is a semantics change: earlier versions treated maxSubagentDepth as an absolute tree-depth cap with an implicit default of 2 for an opted-in delegator. That implicit default is gone.

The root FleetView shows descendant runs and can steer or stop them. Stopping an agent also stops its descendant subtree, and session shutdown stops idle follow-up sessions too. Nested children use their delegator's worktree by default, so the delegator owns one branch; explicitly request isolation: "worktree" only when a nested branch is required. Once a completed child needs no follow-up, call subagent_fleet with action: "stop" to tear down its process and remove it from FleetView.

Requesting more depth

Delegating subagents can ask the human at the root for more depth instead of every intermediate agent having to pre-opt-in. Both tools show a plain yes/no confirm in the root TUI. The prompt identifies the requester from the root's FleetView (#<n> <agent>) and labels depth, cap, and reason as agent-reported. Any confirmation-channel failure — no bridge, disconnect, timeout, root not in interactive TUI mode, or a malformed request — fails closed as a denial, never an implicit approval.

request_depth_grant

Top-level subagents (depth 1) only. Asks the root user to set this subagent's subtree cap. The requested value is clamped to the depthGrantCeiling setting (default 10) before the prompt; the user approves the clamped value. The prompt shows current → granted (requested X, ceiling Y) and warns explicitly if the grant lowers the current cap. On approval the granted value becomes the caller's subtree cap (per-agent maxSubagentDepth tightening still applies below). On decline nothing changes.

request_depth_exception

Any subagent. On approval, exactly one subagent tool call may exceed the current cap. That call may be a parallel tasks batch and therefore spawn multiple children — the agent reports the intended count and the prompt shows it. The approval expires after 5 minutes if unused and is only spent when the call actually dispatches (a call rejected for an unknown agent or model does not consume it). Spawned children inherit the normal cap and need their own exception to go deeper. Tokens do not stack: arming twice still allows one call.

Retrieving async results

After subagent({ async: true, ... }) without notifyOnComplete, the initial tool result only confirms launch. Poll for conclusions with the fleet tool:

// 1. See fleet numbers and status
{ "action": "list" }

// 2. Retrieve a child's summary once completed (repeat while still running)
{ "action": "result", "target": "2" }

With notifyOnComplete: true, opted-in root-launched children from the same dispatch deliver a batched sendMessage to the root session when they all finish — no polling required. Nested delegators must dispatch synchronously when they need child results.

Worktree lifecycle

Local children share the checkout by default. Use isolation: "worktree" for code changes in a Git repository with a committed HEAD. An isolated child receives a fresh checkout under <repo>/.pi/subagent-worktrees/<id> and a retained branch named pi-archimedes/subagent/<id>; its result reports both. The package creates .pi and an ignore-all .gitignore there as needed, so the retained worktrees stay out of Git status and staging. Root children can also opt in via agent frontmatter; nested children require a task-level opt-in.

Settings

Setting Type Default Description
maxDelegationDepth number 5 Root-seeded delegation cap: a subagent at depth d may delegate while d <= cap (deepest subagent at cap + 1); agents can only tighten it
depthGrantCeiling number 10 Hard upper bound for user-approved request_depth_grant caps (same depth semantics)
cleanupSessionOnStop bool true Delete the child's persisted Pi session from /resume when it is explicitly stopped

Settings live in the archimedes.subagent namespace of ~/.pi/agent/settings.json (also editable via /archimedes).

Part of the suite

The full suite is the supported connected setup. With the relevant components loaded together, a subagent's tokens and cost ride its own tool result into the footer's totals, subagent tasks get their own columns on the todo board, and subagent ask questions surface in your terminal. On/off is managed by the suite: toggle via /plugins (archimedes.subagent.enabled, default on).

← Back to pi-archimedes