@xian0x5a/pi-durable-subagents

中文文档
0.4.6发布于 2026/11/03MITTypeScriptES Module构建来源已验证

Durable Pi agents that collaborate asynchronously under explicit Owner and Spawner supervision.

原始使用文档
文档目录12 节
  1. Features
  2. Interactive Agent switching
  3. Coordination and supervision
  4. Durable obligations
  5. Installation
  6. Usage
  7. Suggested agent templates
  8. cheap-delegate
  9. moderator
  10. Compatibility
  11. Trust and persistence
  12. Documentation

pi-durable-subagents

Durable Pi agents that collaborate asynchronously under explicit Owner and Spawner supervision.

Features

Interactive Agent switching

Run /agents from the Owner or any Agent to open the Agent switcher. Use /agents owner to return directly to the exact mounted Workflow Owner presentation without opening the switcher:

The Agent switcher overlay with an Attention Inbox Human Request above the Live Agent tree

Select a subagent to enter its complete Pi session and interact with it directly—read its transcript, type into its editor, or use its commands and tools. In fullscreen mode, a primary click on the activity dock above the editor opens the same switcher.

Coordination and supervision

  • Owner-directed Workflows: the current Pi session, in the TUI or a headless mode, becomes the durable Workflow Owner. Fork or clone it into a fresh, independent Workflow. See Owner Workflow.
  • Durable child Agents: Agents create configurable, context-isolated children with agent_spawn. See Agent spawning.
  • Messaging and Requests: agent_message sends Messages and titled Requests; agent_wait joins their Answers. See Agent messaging.
  • Visible obligations: agent_observe lists and retrieves your outstanding Requests.
  • Human decisions: in the TUI, a spawned Agent can block on one free-form Human Answer with ask_user. See Human Requests.
  • Run supervision: Owners and Direct Spawners inspect, interrupt, resume, or abort exact Runs with agent_observe and agent_control. See Run supervision.
  • Incident handling: a runtime reminder recovers forgotten Answers; isolated Moderators handle persistent stalls, deadlocks, and failures under policy bounds. See Operational Incident moderation.
  • Durable recovery: a fresh host rebuilds authority and pending Requests from Pi transcripts. See Cold host recovery.
  • Model policy: /agents models maintains a durable deny list of models children may not use. See Workflow Policy.
  • Virtual models: name an ordered fallback list of models once and use virtual/<name> in Templates and spawns; fixing the list updates every Agent. Edit them in the /agents Config tab (c). See Virtual Models.

Coordination does not override Pi's compaction, retry, or transport settings.

Durable obligations

A Request becomes an Answer obligation delivered to the Responder; only an Answer or the requester's Cancellation closes it. A Host watcher reminds a stalled Responder, then starts a Moderator that can intervene or escalate to the Workflow Owner.

A Request creates an Answer obligation that the responder owes until it commits an Answer or receives the requester's Cancellation. Stopping, resuming, or failing the Run, or a human typing into the child, leaves it open, and a plain Message creates none. When an obligated Agent stalls, the host sends one reminder (plus a free one if it stalled while a human was typing into it), then starts a Moderator that can intervene or escalate to the Workflow Owner. See Agent messaging and Operational Incident moderation.

Installation

Install from npm:

pi install npm:@xian0x5a/pi-durable-subagents

Or track the Git repository directly:

pi install git:github.com/xian0x5a/pi-durable-subagents

Attached-terminal support uses the node-pty native addon. It ships prebuilt binaries for Linux, macOS, and Windows on x64 and arm64, so those platforms need no install-time build. Other platforms compile it from source, which needs a C++ toolchain and npm permission to run its install scripts.

Usage

Start an interactive Pi TUI:

pi

The package adopts the current session as the Workflow Owner; no separate activation command is required.

Headless modes host the Owner too, with no human in the loop:

pi -p "Delegate the review to two agents and summarize their answers"
pi --mode json "..."
pi --mode rpc

In a headless Workflow, Agents cannot use ask_user; they escalate through their supervisor instead. When a child's Run suspends, its supervisor is notified. The Agents selector, Agent views, and activity dock need the TUI. Reports are stored in the session, so reopen it interactively (pi --session <file>) to read them. See Headless Workflows.

Suggested agent templates

Templates are creation presets: edits apply to future spawns only. See Agent Templates for configuration details.

Both templates below use one Virtual Model, so a retired or banned model is fixed in one place. thinking: preset runs each entry on its own level. Add it in the /agents Config tab (c), or in ~/.pi/agent/config/pi-durable-subagents.json:

{
  "virtualModels": {
    "cheap": [
      { "id": "openai-codex/gpt-6-luna", "thinking": "high" },
      { "id": "deepseek/deepseek-v4-flash", "thinking": "high" }
    ]
  }
}

cheap-delegate

A cost-efficient default for bounded implementation, routine execution, and targeted fact-finding.

Save as ~/.agents/agents/cheap-delegate.md:

---
name: cheap-delegate
useWhen: >-
  Use as a cost-efficient default delegate for tasks with clear goals and
  verifiable outcomes, such as implementation with explicit requirements or
  instructions and bounded scope, routine execution, or targeted fact-finding.
  Do not use for thorough review, open-ended investigation, high-stakes security
  or architecture work, or tasks requiring substantial ambiguity resolution.
  If its results remain inadequate after several iterations and show no obvious
  improvement, stop assigning that task to this template.
models:
  - id: virtual/cheap
    thinking: preset
---

moderator

Used automatically for incident handling; point it at a cheaper model.

Save as ~/.agents/agents/moderator.md:

---
name: moderator
useWhen: Use for moderation and incident response.
models:
  - id: virtual/cheap
    thinking: preset
---

Compatibility

Pi supplies the package's Pi peer modules; compatibility is checked structurally against the running host. Pi 0.99.0 or newer is required, the first release with native virtual models. See Development for the conformance gate and supervised test runs.

Trust and persistence

Coordination is a trust-based protocol, not a security boundary. Owners, Spawners, ordinary Agents, and Moderators are trusted participants acting through role-scoped tools.

Pi transcripts are the durable authority for identity, Messages, Requests, Deliveries, and committed results. Scheduling queues, Holds, live Run state, UI attention, and open Agent-view attachment are volatile: orderly shutdown closes them, while abrupt process loss can discard them without claiming durable completion.

Documentation

版本与发布记录

@xian0x5a/pi-durable-subagents 共发布 14 个版本,首次发布于 2026/10/06;过去 12 个月发布了 14 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.4.6latest2026/11/03今天
0.4.52026/10/313 天前
0.4.42026/10/2311 天前
0.4.32026/10/2311 天前
0.4.22026/10/1618 天前
0.4.12026/10/1321 天前

关于 @xian0x5a/pi-durable-subagents 的常见问题

@xian0x5a/pi-durable-subagents 是什么?

在显式所有者和产卵者监督下异步协作的持久Pi代理。

如何安装 @xian0x5a/pi-durable-subagents?

在项目目录运行 npm install @xian0x5a/pi-durable-subagents,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:typebox(*)、@earendil-works/pi-ai(>=0.99.0)、@earendil-works/pi-tui(>=0.99.0)、@earendil-works/pi-agent-core(>=0.99.0)、@earendil-works/pi-coding-agent(>=0.99.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@xian0x5a/pi-durable-subagents 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@xian0x5a/pi-durable-subagents 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@xian0x5a/pi-durable-subagents 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.19.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@xian0x5a/pi-durable-subagents 可以商用吗?

@xian0x5a/pi-durable-subagents 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@xian0x5a/pi-durable-subagents 还在维护吗?

最新版本 0.4.6 发布于 2026/11/03(今天);至今共发布 14 个版本,其中过去 12 个月发布了 14 个;首次发布于 2026/10/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。