@narumitw/pi-subagents 2.1.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +181 -1250
- package/dist/child-communication-bridge.ts +136 -0
- package/dist/child-communication-bridge.ts.map +7 -0
- package/dist/chunks/chunk-UKTWUQRM.js +667 -0
- package/dist/chunks/chunk-UKTWUQRM.js.map +7 -0
- package/dist/index.ts +1448 -1598
- package/dist/index.ts.map +4 -4
- package/docs/design-principles.md +31 -0
- package/docs/ipc-transport-idea.md +103 -0
- package/docs/tools.md +109 -0
- package/package.json +11 -19
- package/src/broker-credentials.ts +71 -0
- package/src/child-communication-bridge.ts +153 -0
- package/src/child-communication-tools.ts +147 -0
- package/src/completion-renderer.ts +60 -0
- package/src/index.ts +1 -1
- package/src/message-broker.ts +628 -0
- package/src/model-output.ts +42 -0
- package/src/process.ts +688 -0
- package/src/runtime.ts +538 -0
- package/src/subagents.ts +33 -34
- package/src/tools.ts +416 -0
- package/src/types.ts +85 -0
- package/src/widget.ts +130 -0
- package/dist/chunks/auto-transport-FUUKFDIG.ts +0 -109
- package/dist/chunks/auto-transport-FUUKFDIG.ts.map +0 -7
- package/dist/chunks/capability-grant-PR72SWWS.ts +0 -19
- package/dist/chunks/capability-grant-PR72SWWS.ts.map +0 -7
- package/dist/chunks/child-peer-bridge.ts +0 -108
- package/dist/chunks/child-peer-bridge.ts.map +0 -7
- package/dist/chunks/chunk-2LMJU25E.ts +0 -1641
- package/dist/chunks/chunk-2LMJU25E.ts.map +0 -7
- package/dist/chunks/chunk-47SK2QYC.ts +0 -56
- package/dist/chunks/chunk-47SK2QYC.ts.map +0 -7
- package/dist/chunks/chunk-4AQSF7AS.ts +0 -29
- package/dist/chunks/chunk-4AQSF7AS.ts.map +0 -7
- package/dist/chunks/chunk-5DGRMKNV.ts +0 -126
- package/dist/chunks/chunk-5DGRMKNV.ts.map +0 -7
- package/dist/chunks/chunk-6H6TBBED.ts +0 -108
- package/dist/chunks/chunk-6H6TBBED.ts.map +0 -7
- package/dist/chunks/chunk-6KJ34M6S.ts +0 -159
- package/dist/chunks/chunk-6KJ34M6S.ts.map +0 -7
- package/dist/chunks/chunk-6NSJVPXX.ts +0 -480
- package/dist/chunks/chunk-6NSJVPXX.ts.map +0 -7
- package/dist/chunks/chunk-7AAJEUSL.ts +0 -238
- package/dist/chunks/chunk-7AAJEUSL.ts.map +0 -7
- package/dist/chunks/chunk-BFK2Z4ZF.ts +0 -189
- package/dist/chunks/chunk-BFK2Z4ZF.ts.map +0 -7
- package/dist/chunks/chunk-BOAXY55Y.ts +0 -153
- package/dist/chunks/chunk-BOAXY55Y.ts.map +0 -7
- package/dist/chunks/chunk-D4CR7T73.ts +0 -353
- package/dist/chunks/chunk-D4CR7T73.ts.map +0 -7
- package/dist/chunks/chunk-FEVPWRMU.ts +0 -300
- package/dist/chunks/chunk-FEVPWRMU.ts.map +0 -7
- package/dist/chunks/chunk-G6VZTCFH.ts +0 -70
- package/dist/chunks/chunk-G6VZTCFH.ts.map +0 -7
- package/dist/chunks/chunk-H3FP6DLR.ts +0 -160
- package/dist/chunks/chunk-H3FP6DLR.ts.map +0 -7
- package/dist/chunks/chunk-HA36LPCO.ts +0 -130
- package/dist/chunks/chunk-HA36LPCO.ts.map +0 -7
- package/dist/chunks/chunk-HOP5FXDT.ts +0 -27
- package/dist/chunks/chunk-HOP5FXDT.ts.map +0 -7
- package/dist/chunks/chunk-IGAMVWFN.ts +0 -139
- package/dist/chunks/chunk-IGAMVWFN.ts.map +0 -7
- package/dist/chunks/chunk-ILEQ27AL.ts +0 -45
- package/dist/chunks/chunk-ILEQ27AL.ts.map +0 -7
- package/dist/chunks/chunk-ITVWPNU4.ts +0 -819
- package/dist/chunks/chunk-ITVWPNU4.ts.map +0 -7
- package/dist/chunks/chunk-IWC32VPY.ts +0 -172
- package/dist/chunks/chunk-IWC32VPY.ts.map +0 -7
- package/dist/chunks/chunk-JSZIP73U.ts +0 -362
- package/dist/chunks/chunk-JSZIP73U.ts.map +0 -7
- package/dist/chunks/chunk-JU6LUNLP.ts +0 -380
- package/dist/chunks/chunk-JU6LUNLP.ts.map +0 -7
- package/dist/chunks/chunk-KMGKCEO4.ts +0 -38
- package/dist/chunks/chunk-KMGKCEO4.ts.map +0 -7
- package/dist/chunks/chunk-LASD73CM.ts +0 -339
- package/dist/chunks/chunk-LASD73CM.ts.map +0 -7
- package/dist/chunks/chunk-LEOYDZI3.ts +0 -22
- package/dist/chunks/chunk-LEOYDZI3.ts.map +0 -7
- package/dist/chunks/chunk-LL4LP2T7.ts +0 -737
- package/dist/chunks/chunk-LL4LP2T7.ts.map +0 -7
- package/dist/chunks/chunk-N2T5IN4X.ts +0 -18
- package/dist/chunks/chunk-N2T5IN4X.ts.map +0 -7
- package/dist/chunks/chunk-N7BLVXKK.ts +0 -73
- package/dist/chunks/chunk-N7BLVXKK.ts.map +0 -7
- package/dist/chunks/chunk-NLT67IZS.ts +0 -322
- package/dist/chunks/chunk-NLT67IZS.ts.map +0 -7
- package/dist/chunks/chunk-NTRPLF46.ts +0 -63
- package/dist/chunks/chunk-NTRPLF46.ts.map +0 -7
- package/dist/chunks/chunk-ONDTY4EL.ts +0 -91
- package/dist/chunks/chunk-ONDTY4EL.ts.map +0 -7
- package/dist/chunks/chunk-OVPHFGKO.ts +0 -1769
- package/dist/chunks/chunk-OVPHFGKO.ts.map +0 -7
- package/dist/chunks/chunk-P7OH4XMF.ts +0 -60
- package/dist/chunks/chunk-P7OH4XMF.ts.map +0 -7
- package/dist/chunks/chunk-PBZMBTNJ.ts +0 -422
- package/dist/chunks/chunk-PBZMBTNJ.ts.map +0 -7
- package/dist/chunks/chunk-PGLSFLYW.ts +0 -52
- package/dist/chunks/chunk-PGLSFLYW.ts.map +0 -7
- package/dist/chunks/chunk-RRR66UWR.ts +0 -28
- package/dist/chunks/chunk-RRR66UWR.ts.map +0 -7
- package/dist/chunks/chunk-RSUXZD6S.ts +0 -275
- package/dist/chunks/chunk-RSUXZD6S.ts.map +0 -7
- package/dist/chunks/chunk-RTCVYIZA.ts +0 -221
- package/dist/chunks/chunk-RTCVYIZA.ts.map +0 -7
- package/dist/chunks/chunk-RY2AEGMZ.ts +0 -34
- package/dist/chunks/chunk-RY2AEGMZ.ts.map +0 -7
- package/dist/chunks/chunk-SWGQLFSD.ts +0 -60
- package/dist/chunks/chunk-SWGQLFSD.ts.map +0 -7
- package/dist/chunks/chunk-TM2R67J3.ts +0 -52
- package/dist/chunks/chunk-TM2R67J3.ts.map +0 -7
- package/dist/chunks/chunk-TMZRHIIK.ts +0 -497
- package/dist/chunks/chunk-TMZRHIIK.ts.map +0 -7
- package/dist/chunks/chunk-TZ34IQ3M.ts +0 -59
- package/dist/chunks/chunk-TZ34IQ3M.ts.map +0 -7
- package/dist/chunks/chunk-UMBPMVJW.ts +0 -22
- package/dist/chunks/chunk-UMBPMVJW.ts.map +0 -7
- package/dist/chunks/chunk-VDG7LTYE.ts +0 -80
- package/dist/chunks/chunk-VDG7LTYE.ts.map +0 -7
- package/dist/chunks/chunk-X4NMONPE.ts +0 -73
- package/dist/chunks/chunk-X4NMONPE.ts.map +0 -7
- package/dist/chunks/chunk-YPJEN6NU.ts +0 -65
- package/dist/chunks/chunk-YPJEN6NU.ts.map +0 -7
- package/dist/chunks/chunk-YU53SHA7.ts +0 -328
- package/dist/chunks/chunk-YU53SHA7.ts.map +0 -7
- package/dist/chunks/completion-delivery-RSJU6BXL.ts +0 -17
- package/dist/chunks/completion-delivery-RSJU6BXL.ts.map +0 -7
- package/dist/chunks/config-status-FKGDECZ3.ts +0 -35
- package/dist/chunks/config-status-FKGDECZ3.ts.map +0 -7
- package/dist/chunks/config-ui-ABHYNGQ7.ts +0 -1212
- package/dist/chunks/config-ui-ABHYNGQ7.ts.map +0 -7
- package/dist/chunks/consult-LJU3IQY5.ts +0 -519
- package/dist/chunks/consult-LJU3IQY5.ts.map +0 -7
- package/dist/chunks/context-QDKLVQXE.ts +0 -11
- package/dist/chunks/context-QDKLVQXE.ts.map +0 -7
- package/dist/chunks/create-stateful-transport-JWC2EFYL.ts +0 -130
- package/dist/chunks/create-stateful-transport-JWC2EFYL.ts.map +0 -7
- package/dist/chunks/cwd-policy-NB6XZ5GF.ts +0 -17
- package/dist/chunks/cwd-policy-NB6XZ5GF.ts.map +0 -7
- package/dist/chunks/delegation-contract-LA56I5DT.ts +0 -24
- package/dist/chunks/delegation-contract-LA56I5DT.ts.map +0 -7
- package/dist/chunks/discovery-MIFB2U4Y.ts +0 -12
- package/dist/chunks/discovery-MIFB2U4Y.ts.map +0 -7
- package/dist/chunks/execution-Q2JZLKJA.ts +0 -4037
- package/dist/chunks/execution-Q2JZLKJA.ts.map +0 -7
- package/dist/chunks/in-process-transport-HJ6TZXC3.ts +0 -39
- package/dist/chunks/in-process-transport-HJ6TZXC3.ts.map +0 -7
- package/dist/chunks/inspect-UH2TKH6E.ts +0 -634
- package/dist/chunks/inspect-UH2TKH6E.ts.map +0 -7
- package/dist/chunks/peer-communication-KL36Z6CO.ts +0 -294
- package/dist/chunks/peer-communication-KL36Z6CO.ts.map +0 -7
- package/dist/chunks/persistence-UY3PY6E5.ts +0 -348
- package/dist/chunks/persistence-UY3PY6E5.ts.map +0 -7
- package/dist/chunks/registry-BT54L6CY.ts +0 -1445
- package/dist/chunks/registry-BT54L6CY.ts.map +0 -7
- package/dist/chunks/retained-semantic-state-GM75FZGE.ts +0 -81
- package/dist/chunks/retained-semantic-state-GM75FZGE.ts.map +0 -7
- package/dist/chunks/rpc-transport-7R7DVCEB.ts +0 -1222
- package/dist/chunks/rpc-transport-7R7DVCEB.ts.map +0 -7
- package/dist/chunks/runtime-policy-5YELCOVC.ts +0 -15
- package/dist/chunks/runtime-policy-5YELCOVC.ts.map +0 -7
- package/dist/chunks/semantic-snapshot-WPJ3UAFW.ts +0 -19
- package/dist/chunks/semantic-snapshot-WPJ3UAFW.ts.map +0 -7
- package/dist/chunks/spawn-idempotency-BNHOSMZW.ts +0 -13
- package/dist/chunks/spawn-idempotency-BNHOSMZW.ts.map +0 -7
- package/dist/chunks/stateful-lifecycle-JAR6K55H.ts +0 -15
- package/dist/chunks/stateful-lifecycle-JAR6K55H.ts.map +0 -7
- package/dist/chunks/subprocess-transport-VHZJRBTW.ts +0 -160
- package/dist/chunks/subprocess-transport-VHZJRBTW.ts.map +0 -7
- package/dist/chunks/usage-recording-store-CW3EH2SZ.ts +0 -164
- package/dist/chunks/usage-recording-store-CW3EH2SZ.ts.map +0 -7
- package/dist/chunks/workspace-WDKLN72J.ts +0 -11
- package/dist/chunks/workspace-WDKLN72J.ts.map +0 -7
- package/docs/async-runtime-protocol.md +0 -84
- package/docs/implementation-notes/pi-subagents-capability-matrix.md +0 -62
- package/docs/implementation-notes/pi-subagents-current-direction.md +0 -99
- package/docs/implementation-notes/pi-subagents-rpc-v1.md +0 -153
- package/docs/pi-subagents-diagrams.md +0 -183
- package/src/adaptive-scheduler.ts +0 -224
- package/src/admission-benchmark.ts +0 -95
- package/src/admission-policy.ts +0 -78
- package/src/agent-projection.ts +0 -53
- package/src/agents/built-ins.ts +0 -71
- package/src/agents/catalog.ts +0 -241
- package/src/agents/discovery.ts +0 -265
- package/src/agents/types.ts +0 -100
- package/src/agents.ts +0 -51
- package/src/async-subagent-benchmark.ts +0 -532
- package/src/auto-transport.ts +0 -121
- package/src/blocking-status.ts +0 -63
- package/src/cached-module-loader.ts +0 -18
- package/src/capabilities.ts +0 -145
- package/src/capability-grant.ts +0 -115
- package/src/capability-router.ts +0 -107
- package/src/child-peer-bridge.ts +0 -124
- package/src/child-peer-tools.ts +0 -132
- package/src/completion-delivery.ts +0 -409
- package/src/completion-render.ts +0 -190
- package/src/completion-requirement.ts +0 -479
- package/src/completion-routing.ts +0 -24
- package/src/config-registration.ts +0 -114
- package/src/config-status.ts +0 -217
- package/src/config-ui.ts +0 -983
- package/src/consult-policy.ts +0 -15
- package/src/consult-registration.ts +0 -125
- package/src/consult-render.ts +0 -194
- package/src/consult-resources.ts +0 -51
- package/src/consult-tool.ts +0 -95
- package/src/consult.ts +0 -566
- package/src/context.ts +0 -126
- package/src/create-stateful-transport.ts +0 -157
- package/src/cwd-policy.ts +0 -183
- package/src/delegation-contract.ts +0 -463
- package/src/execution/budget.ts +0 -56
- package/src/execution/runtime-policy.ts +0 -19
- package/src/execution-plan.ts +0 -322
- package/src/execution-ui.ts +0 -259
- package/src/execution.ts +0 -1679
- package/src/in-process-transport.ts +0 -941
- package/src/inspect-registration.ts +0 -64
- package/src/inspect-render.ts +0 -334
- package/src/inspect-tool.ts +0 -45
- package/src/inspect.ts +0 -769
- package/src/integration-controller.ts +0 -98
- package/src/limits.ts +0 -75
- package/src/orchestration-metrics.ts +0 -116
- package/src/outcome.ts +0 -61
- package/src/panel-child-group.ts +0 -35
- package/src/panel-contract.ts +0 -343
- package/src/panel-evidence.ts +0 -59
- package/src/panel-execution.ts +0 -769
- package/src/panel-failure.ts +0 -56
- package/src/panel-planning.ts +0 -175
- package/src/panel-presets.ts +0 -3
- package/src/panel-prompts.ts +0 -132
- package/src/panel-reconciliation.ts +0 -57
- package/src/panel-render.ts +0 -103
- package/src/parallel-limit-ui.ts +0 -113
- package/src/params.ts +0 -278
- package/src/peer-communication.ts +0 -352
- package/src/peer-transport.ts +0 -49
- package/src/persistence.ts +0 -522
- package/src/pi-args.ts +0 -43
- package/src/pi-invocation.ts +0 -168
- package/src/process-control.ts +0 -43
- package/src/prompt-resources.ts +0 -38
- package/src/prompt-source-safety.ts +0 -48
- package/src/protocol.ts +0 -76
- package/src/registry-types.ts +0 -204
- package/src/registry.ts +0 -1698
- package/src/render-common.ts +0 -252
- package/src/render.ts +0 -704
- package/src/result-contract.ts +0 -431
- package/src/retained-semantic-state.ts +0 -100
- package/src/rpc-timeout-finalization.ts +0 -207
- package/src/rpc-transport-metadata.ts +0 -65
- package/src/rpc-transport.ts +0 -1035
- package/src/rpc-turn-capture.ts +0 -217
- package/src/runner-outcome.ts +0 -31
- package/src/runner-result.ts +0 -55
- package/src/runner-types.ts +0 -102
- package/src/runner-usage.ts +0 -48
- package/src/runner.ts +0 -866
- package/src/safe-text.ts +0 -67
- package/src/semantic-snapshot.ts +0 -214
- package/src/session-guidance-contract.ts +0 -399
- package/src/settings/inspection.ts +0 -302
- package/src/settings/schema.ts +0 -195
- package/src/settings-reader.ts +0 -215
- package/src/settings.ts +0 -452
- package/src/spawn-idempotency.ts +0 -68
- package/src/stateful-agent-view.ts +0 -85
- package/src/stateful-config.ts +0 -13
- package/src/stateful-guidance.ts +0 -29
- package/src/stateful-lifecycle.ts +0 -74
- package/src/stateful-limit-ui.ts +0 -249
- package/src/stateful-limits.ts +0 -96
- package/src/stateful-prompt.ts +0 -49
- package/src/stateful-registration.ts +0 -1320
- package/src/stateful-render.ts +0 -318
- package/src/stateful-safety.ts +0 -47
- package/src/stateful-tool-params.ts +0 -215
- package/src/stateful.ts +0 -12
- package/src/subagent-details.ts +0 -43
- package/src/subagents-extension.ts +0 -355
- package/src/subprocess-transport.ts +0 -145
- package/src/supervision.ts +0 -104
- package/src/task-path.ts +0 -65
- package/src/timeout-checkpoint.ts +0 -305
- package/src/timeout-finalization.ts +0 -75
- package/src/tool-schema-compatibility.ts +0 -73
- package/src/transport-types.ts +0 -74
- package/src/transport-ui.ts +0 -135
- package/src/transport.ts +0 -43
- package/src/turn-budget.ts +0 -109
- package/src/usage-format.ts +0 -42
- package/src/usage-recording-config.ts +0 -13
- package/src/usage-recording-store.ts +0 -183
- package/src/usage-recording.ts +0 -478
- package/src/verification-harness.ts +0 -516
- package/src/verification-policy.ts +0 -67
- package/src/verification-receipt.ts +0 -275
- package/src/verified-execution-benchmark.ts +0 -86
- package/src/verified-execution-contract.ts +0 -191
- package/src/verified-execution-schema.ts +0 -32
- package/src/work-item-ledger.ts +0 -1404
- package/src/work-item-persistence.ts +0 -254
- package/src/workflow-completion-controller.ts +0 -397
- package/src/workflow-planning.ts +0 -172
- package/src/workflow-tree-identity.ts +0 -289
- package/src/workflow-ui.ts +0 -69
- package/src/workflow-verification.ts +0 -296
- package/src/workspace.ts +0 -174
package/README.md
CHANGED
|
@@ -1,1374 +1,305 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 🧩 Pi Subagents — Subagent Jobs with Main-Agent Messaging
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@narumitw/pi-subagents) [](https://pi.dev) [](./LICENSE)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Use the built-in `explorer` for read-only evidence and `worker` for a clearly owned implementation slice.
|
|
8
|
-
|
|
9
|
-
The compatibility default exposes background and blocking methods, while **Keep Pi available (async)** is an optional smaller background-only surface.
|
|
5
|
+
Pi Subagents runs Pi jobs in separate child processes and supports authenticated request-response messaging in both directions while each job is active.
|
|
10
6
|
|
|
11
7
|
## ✨ Features
|
|
12
8
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
- Loads a generated split runtime while preserving lazy execution, UI, inspection, and transport chunks.
|
|
9
|
+
- Runs each job in an isolated Pi child process and returns its job ID immediately.
|
|
10
|
+
- Uses the task to define the child's specialization and the tool list to limit its capabilities.
|
|
11
|
+
- Defaults work tools to `read`, `grep`, `find`, and `ls`.
|
|
12
|
+
- Inherits the main agent's effective model and uses its thinking level by default.
|
|
13
|
+
- Gives the main agent and every child a context-specific `subagent_send` contract for bidirectional requests and responses.
|
|
14
|
+
- Gives every child `subagent_wait` for an answer to a child-originated request.
|
|
15
|
+
- Lets the main agent question a queued or running job through Pi RPC steering without retaining the child after completion.
|
|
16
|
+
- Publishes one asynchronous terminal completion and shows active-job progress above the editor.
|
|
17
|
+
- Exposes privacy-filtered metadata without task text, output, prompts, selected tools, or broker credentials.
|
|
18
|
+
- Cancels session-owned work and closes the broker during replacement, reload, or shutdown.
|
|
24
19
|
|
|
25
20
|
## 📦 Install
|
|
26
21
|
|
|
22
|
+
The version 3 runtime documented here is not yet published to npm.
|
|
23
|
+
|
|
24
|
+
The npm package still contains the legacy 2.x runtime and does not provide the tools below.
|
|
25
|
+
|
|
26
|
+
Install the repository source as one Pi package:
|
|
27
|
+
|
|
27
28
|
```bash
|
|
28
|
-
pi install
|
|
29
|
+
pi install git:github.com/narumiruna/pi-extensions
|
|
29
30
|
```
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
This Git installation enables every extension listed in the repository root manifest, including Pi Subagents.
|
|
33
|
+
|
|
34
|
+
To install only Pi Subagents, clone the repository, install dependencies, build its generated runtime, and install its package directory:
|
|
32
35
|
|
|
33
36
|
```bash
|
|
34
|
-
|
|
37
|
+
git clone https://github.com/narumiruna/pi-extensions.git
|
|
38
|
+
cd pi-extensions
|
|
39
|
+
npm install
|
|
40
|
+
npm --workspace @narumitw/pi-subagents run build
|
|
41
|
+
pi install ./packages/pi-subagents
|
|
35
42
|
```
|
|
36
43
|
|
|
37
|
-
Build
|
|
44
|
+
Build before trying the extension from a local checkout:
|
|
38
45
|
|
|
39
46
|
```bash
|
|
40
47
|
npm --workspace @narumitw/pi-subagents run build
|
|
41
|
-
pi -e ./packages/pi-subagents
|
|
48
|
+
pi --no-extensions -e ./packages/pi-subagents
|
|
42
49
|
```
|
|
43
50
|
|
|
44
|
-
The
|
|
45
|
-
An unbuilt checkout intentionally has no declared generated entrypoint.
|
|
46
|
-
|
|
47
|
-
## 🚀 Quick start
|
|
51
|
+
The package entry is generated at `dist/index.ts` and loaded through Pi's Jiti runtime.
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
An unbuilt local package directory cannot load its declared extension entry.
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
Pi extensions and children with `bash`, `powershell`, `edit`, or `write` execute with your user permissions.
|
|
52
56
|
|
|
53
|
-
|
|
57
|
+
Review the source before installing or invoking the extension.
|
|
54
58
|
|
|
55
|
-
|
|
59
|
+
## 🚀 Quick start
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
When the final answer depends on background work, use `/subagents settings` → **Completion and privacy** to select **Continue automatically when work finishes**.
|
|
59
|
-
That mode steers completions into active parent work before its next model call, or wakes an idle parent once when no user or extension input is pending.
|
|
61
|
+
Call `subagent_spawn` with a self-contained task and only the work tools that task needs.
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
The blocking `subagent` tool is deprecated for new work.
|
|
63
|
+
The package intentionally does not register or publish a skill.
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
Create a project skill under `.pi/skills/<your-skill>/SKILL.md` or a global skill under `~/.pi/agent/skills/<your-skill>/SKILL.md` when you want reusable delegation policy.
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
Choose a name, trigger description, tool policy, task format, and verification workflow for your own use case.
|
|
67
68
|
|
|
68
|
-
-
|
|
69
|
-
- `/subagents settings` opens the same grouped settings hub used by the main menu.
|
|
70
|
-
- `/subagents status` shows detailed current-session and configured diagnostics with their sources.
|
|
71
|
-
- `/subagents help` explains first steps, settings behavior, commands, and safety limits.
|
|
69
|
+
The repository-only [`using-pi-subagents` example](https://github.com/narumiruna/pi-extensions/tree/main/packages/pi-subagents/skills/using-pi-subagents) demonstrates one possible design without imposing it on installed users.
|
|
72
70
|
|
|
73
|
-
|
|
71
|
+
The call returns a `jobId` immediately, and the job continues in the background.
|
|
74
72
|
|
|
75
|
-
|
|
76
|
-
Use `/subagents` → **How subagents run** to change the registered delegation tools.
|
|
77
|
-
Settings are stored in `~/.pi/agent/pi-subagents.json`; the detailed sections below document precedence, reload requirements, and safety behavior.
|
|
73
|
+
Continue useful main-agent work until the result is required or a completion arrives.
|
|
78
74
|
|
|
79
|
-
|
|
75
|
+
Call `subagent_send` with `recipient: jobId` to ask an active child a question.
|
|
80
76
|
|
|
81
|
-
|
|
82
|
-
The setting applies immediately and persists as `usageRecording.enabled` in the user settings file.
|
|
83
|
-
No network connection, upload, remote identifier, or project attribution is used.
|
|
77
|
+
If `subagent_wait` returns `reason: "subagent_message"`, handle the visible request or response and wait for the job again only when needed.
|
|
84
78
|
|
|
85
|
-
|
|
86
|
-
Directories use mode `0700` and files use mode `0600` on POSIX systems.
|
|
87
|
-
Each event is versioned, bounded to 8 KiB, and ends with a newline so a crash-truncated final frame can be distinguished from completed records.
|
|
88
|
-
Concurrent Pi processes use separate opaque writer files and never append to one shared file.
|
|
89
|
-
Validated writer files older than 30 days are removed after recording starts.
|
|
90
|
-
Disabling recording stops new events immediately; existing files remain until the retention window expires or the user removes the directory while Pi is stopped.
|
|
79
|
+
Answer a child-originated request by calling `subagent_send` with its `requestId`.
|
|
91
80
|
|
|
92
|
-
|
|
93
|
-
The recorder does not store prompts, delegated tasks, responses, thinking, tool arguments or results, code, paths, commands, mailbox or steering content, raw errors, provider/model identity, credentials, Pi session identifiers, or a persistent device identifier.
|
|
94
|
-
Raw child, run, completion, and provider tool-call identifiers are replaced with runtime-local ordinals before publication.
|
|
81
|
+
Completion messages follow Pi's global tool-output expansion state and the `app.tools.expand` binding (`Ctrl+O` by default).
|
|
95
82
|
|
|
96
|
-
|
|
97
|
-
They cannot establish semantic task success, whether delegation was appropriate, whether parent work was useful, or whether a completion was understood by the model.
|
|
98
|
-
Opt-in field data describes only users who enabled recording and does not prove causal effects between tool surfaces.
|
|
99
|
-
Use a controlled benchmark before interpreting future `subagent_await` immediate-join or blocking-choice hypotheses causally.
|
|
83
|
+
In TUI mode, the above-editor widget shows each queued or running job's ID, state, elapsed time, timeout, and selected work tools.
|
|
100
84
|
|
|
101
|
-
|
|
102
|
-
A failed write drops that event, reports one bounded warning, and retries on later events without exposing filesystem details.
|
|
85
|
+
The widget omits the fixed communication tools, disappears when no jobs remain active, and clears when the session ends.
|
|
103
86
|
|
|
104
87
|
## 🛠️ Tools
|
|
105
88
|
|
|
106
|
-
|
|
107
|
-
Run `/subagents`, choose **How subagents run**, review the concrete tool changes, then select **Save and reload** to apply one of these workflows:
|
|
89
|
+
The main Pi session exposes five fixed tools:
|
|
108
90
|
|
|
109
|
-
|
|
|
110
|
-
| --- | --- |
|
|
111
|
-
| **Background plus compatibility methods (async + sync)** (compatibility default) | `subagent`, `subagent_spawn`, `subagent_send`, `subagent_await`, `subagent_manage`, `subagent_mailbox`, `subagent_inspect`, and `subagent_consult` |
|
|
112
|
-
| **Keep Pi available (async)** | `subagent_spawn`, `subagent_send`, `subagent_manage`, `subagent_mailbox`, and `subagent_inspect` |
|
|
113
|
-
| **Compatibility blocking methods (sync)** | `subagent`, `subagent_inspect`, and `subagent_consult` |
|
|
114
|
-
| **Subagents disabled** | `subagent_inspect` only; delegation is disabled |
|
|
115
|
-
|
|
116
|
-
`subagent` is deprecated for new work but remains registered in compatibility workflows with its existing schema and execution behavior.
|
|
117
|
-
No removal release or date is currently set because chain, fan-in, panel, and explicit workflow callers do not yet have one-for-one detached replacements.
|
|
118
|
-
`subagent_consult` and `subagent_await` remain supported and are not deprecated.
|
|
119
|
-
The four async lifecycle tools stay separate because starting work, sending follow-ups, managing lifecycle, and queueing mailbox messages have different contracts.
|
|
120
|
-
`subagent_await` is a separate blocking join and is omitted from **Keep Pi available (async)**.
|
|
121
|
-
Any default change, tool removal, or lifecycle consolidation requires a separately approved compatibility migration.
|
|
122
|
-
|
|
123
|
-
The preview compares the selection with the tools registered in the current session, even when a manual settings edit is pending, and remains read-only until confirmation.
|
|
124
|
-
Escape or **Cancel** leaves settings unchanged.
|
|
125
|
-
Tool removal requires an extension reload because Pi does not expose extension tool unregistration.
|
|
126
|
-
To avoid aborting work or removing isolated worktrees during `session_shutdown`, workflow changes are blocked while background agents are saved for follow-up; finish or clear them through **Current subagents** first.
|
|
127
|
-
Pi owns reload-error reporting and does not return a success result to extensions, so the save notification also tells users to run `/reload` if the tool surface does not refresh.
|
|
128
|
-
|
|
129
|
-
The available tools are:
|
|
130
|
-
|
|
131
|
-
- `subagent` — deprecated compatibility tool for blocking single, parallel, fan-in, chained, panel-review, or explicit dependency-workflow calls.
|
|
132
|
-
Existing callers remain supported, but new work should prefer the main agent, detached lifecycle tools, or `subagent_consult` according to the task.
|
|
133
|
-
The main agent cannot process queued steering until the call returns.
|
|
134
|
-
- `subagent_spawn` and related lifecycle tools — when enabled, start reusable detached work, return immediately, and receive bounded completion messages automatically.
|
|
135
|
-
- `subagent_await` — intentionally block until one retained turn settles or its independent wait timeout expires; timeout and cancellation never interrupt the child.
|
|
136
|
-
- `subagent_inspect` — inspect agent/model/run/runtime metadata without launching work or changing state.
|
|
137
|
-
- `subagent_consult` — run one ephemeral read-only consultation and wait for its answer.
|
|
138
|
-
|
|
139
|
-
### Interactive tool rows
|
|
140
|
-
|
|
141
|
-
In Pi's interactive TUI, every registered tool uses Pi's native tool shell and theme.
|
|
142
|
-
Call rows identify the action, agent or retained id, scope, and a bounded task/message preview.
|
|
143
|
-
Result rows use explicit `Starting`, `Running`, `Completed`, `Failed`, `Cancelled`, `Interrupted`, or `Closed` text in addition to icons and color.
|
|
144
|
-
|
|
145
|
-
Collapsed rows stay scan-friendly: consultation and blocking calls show recent activity while running, completed answers show up to three lines, and list actions show up to five items.
|
|
146
|
-
Use Pi's configured `app.tools.expand` keybinding (Ctrl+O by default) for the additional bounded task, policy, activity, answer, usage, inspection, or mailbox details available to that tool.
|
|
147
|
-
The hint follows the user's keybinding rather than assuming Ctrl+O.
|
|
148
|
-
|
|
149
|
-
`subagent_consult` emits an initial starting update before launching its child and then reports the actual provider/model, thinking request, usage, and a safe projection of recent `read`, `grep`, `find`, and `ls` activity.
|
|
150
|
-
Progress never includes full child messages, prompts, credentials, headers, or environment values.
|
|
151
|
-
Tool-row previews remove terminal controls and redact private text.
|
|
152
|
-
|
|
153
|
-
`subagent_spawn` remains deliberately detached and non-polling: its tool row ends after returning the new `agentId` and initial retained state.
|
|
154
|
-
It does not pretend to stream the background child after the tool call has completed; the existing completion message and configured delivery policy report eventual completion.
|
|
155
|
-
|
|
156
|
-
Custom transcript rendering is TUI presentation only.
|
|
157
|
-
Tool names, parameter schemas, model-facing final content/details, errors, completion delivery, and print/JSON/RPC final output remain unchanged; JSON/RPC observers may see additive bounded consultation partial-progress details.
|
|
158
|
-
|
|
159
|
-
After each session starts, one hidden versioned `pi-subagents` session-guidance message publishes the bounded parent-facing catalog and effective non-secret delegation policies.
|
|
160
|
-
Entries show the source (`built-in`, `user`, or `project`), required `agentScope`, declared capability identifiers, configured tools, filesystem authority, and supported result formats; the `agent` parameters remain unconstrained strings for cwd and scope flexibility.
|
|
161
|
-
The catalog also warns that enforced path, network, and secret guarantees are unsupported.
|
|
162
|
-
It is rebuilt on `/reload` or the next session start, and omitted entries are reported explicitly when the catalog exceeds its metadata bounds.
|
|
163
|
-
The registered tool descriptions, schemas, and prompt metadata remain stable until a reload changes the configured tool surface.
|
|
164
|
-
|
|
165
|
-
Choose the API by lifecycle:
|
|
166
|
-
|
|
167
|
-
| Need | Use |
|
|
168
|
-
| --- | --- |
|
|
169
|
-
| One simple, tightly coupled, or immediate critical-path task | Keep it in the main agent |
|
|
170
|
-
| Ordinary planning or review | Use the main agent with applicable skills and deterministic checks |
|
|
171
|
-
| One bounded implementation slice can run beside named main-agent work | Use async `subagent_spawn` with `worker`, clear ownership, and a supported delivery and integration path |
|
|
172
|
-
| Two or more independent implementation slices | Use workers with disjoint write ownership while the main agent coordinates and integrates |
|
|
173
|
-
| Broad read-only evidence that can run beside main-agent work | Use async `subagent_spawn` with `explorer` |
|
|
174
|
-
| Final-answer-dependent detached work | Enable `completionDelivery: "auto-resume"` so active work receives completion by steering and an idle parent can start a synthesis turn |
|
|
175
|
-
| Bounded synchronous read-only evidence whose independent perspective justifies waiting | Use `subagent_consult` when blocking delegation is enabled |
|
|
176
|
-
| Existing synchronous workflow, panel, chain, or fan-in caller without a detached replacement | Keep deprecated `subagent` as a compatibility route |
|
|
177
|
-
| Reusable history, follow-ups, or mailboxes | Use `subagent_spawn` and lifecycle tools when enabled |
|
|
178
|
-
| One retained result is now required and useful overlapping parent work is complete | Use `subagent_await` when blocking delegation is enabled |
|
|
179
|
-
| Side-effect-free agent/model/run diagnostics | Use `subagent_inspect` |
|
|
180
|
-
|
|
181
|
-
Execution modes:
|
|
182
|
-
|
|
183
|
-
- **single** — run one `{ agent, task }` job.
|
|
184
|
-
- **parallel** — run multiple `{ agent, task }` jobs independently.
|
|
185
|
-
- **parallel + aggregator** — run parallel jobs, then pass all outputs into one fan-in agent.
|
|
186
|
-
- **chain** — run sequential steps, passing prior output with `{previous}`.
|
|
187
|
-
- **workflow** — run named tasks only after declared `dependsOn` tasks and required `inputArtifacts` are ready; independent conflict-free tasks may run concurrently.
|
|
188
|
-
- **panel** — run at least two independent reviewers over one shared task and snapshot, then run one synthesizer only when `minValidReviews` valid evidence artifacts remain.
|
|
189
|
-
|
|
190
|
-
Common controls:
|
|
191
|
-
|
|
192
|
-
- `cwd` — choose a launch directory subject to the user-owned trust-aware target policy described below.
|
|
193
|
-
- `timeoutMs` — choose the per-turn work deadline for the task difficulty.
|
|
194
|
-
- `totalTimeoutMs` — cap an entire blocking single, parallel, chain, panel, or fan-in workflow, including queued work and reserved panel phases.
|
|
195
|
-
- `idleTimeoutMs` — stop work that produces no completed assistant turn or tool result within the selected interval.
|
|
196
|
-
- `maxTurns` / `maxToolCalls` — stop unfinished repeated work after bounded assistant turns or tool calls.
|
|
197
|
-
- `thinkingLevel` — request `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max` thinking for the spawned Pi process or retained child.
|
|
198
|
-
- `idempotencyKey` — make an exact `subagent_spawn` retry return the existing retained `agentId`; reuse with different parameters fails before confirmation, worktree creation, or child launch.
|
|
199
|
-
- `resultFormat` — keep bounded text by default, request legacy `structured-v1`, or request `structured-v2` with explicit outcome status, reason code, claims, artifacts, verification, limitations, and unresolved dependencies.
|
|
200
|
-
- `completionRequirement` — mark one detached spawn or follow-up as `background` (default) or `required` for the parent final answer; required mode tracks the accepted run ID and generation until its exact completion is visible or terminal.
|
|
201
|
-
- `totalTimeoutMs` — bound a whole explicit blocking workflow; no new task starts after the budget is exhausted.
|
|
202
|
-
|
|
203
|
-
For `subagent_spawn`, the root agent selects the lowest thinking level and shortest realistic work deadline sufficient for the delegated task.
|
|
204
|
-
These are tool-argument decisions made from the task already in context; `pi-subagents` does not run a string heuristic or an extra classifier model call.
|
|
205
|
-
|
|
206
|
-
## 🔐 Working-directory trust policy
|
|
207
|
-
|
|
208
|
-
Pi records saved project trust in `~/.pi/agent/trust.json`.
|
|
209
|
-
The closest saved decision for the canonical target or one of its parents wins, so trusting a worktree parent covers worktrees below it while a nearer `false` overrides a trusted parent.
|
|
210
|
-
`pi-subagents` reads this through Pi's public `ProjectTrustStore`; it never parses, writes, or migrates the file.
|
|
211
|
-
Open Pi in a folder and use `/trust` to manage trust, then restart Pi before expecting retained-runtime behavior to change.
|
|
212
|
-
|
|
213
|
-
The default target policies are:
|
|
214
|
-
|
|
215
|
-
| Setting | Values | Default behavior |
|
|
91
|
+
| Tool | Parameters | Purpose |
|
|
216
92
|
| --- | --- | --- |
|
|
217
|
-
| `
|
|
218
|
-
| `
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
Blocking parallel, chain, panel, and fan-in calls preflight every target before any child starts.
|
|
223
|
-
A generated `workspaceMode: "worktree"` inherits the resolved trust of its approved base cwd.
|
|
224
|
-
|
|
225
|
-
`"anywhere"` for general delegation restores the previous external-target flexibility.
|
|
226
|
-
An external target without effective trust starts with `projectTrusted: false`, so Pi-protected project settings, packages, extensions, skills, prompts, and system resources stay disabled.
|
|
227
|
-
General agents still have their configured tools and ordinary Pi/OS permissions, and Pi may still load `AGENTS.md` or `CLAUDE.md` because those context files are not protected by project trust.
|
|
228
|
-
Resource-free consultation is stricter: it also passes `--no-context-files`, `--no-skills`, `--no-prompt-templates`, `--no-approve`, and `--no-extensions`.
|
|
229
|
-
|
|
230
|
-
These controls govern child starting directories and automatically loaded resources.
|
|
231
|
-
They do **not** restrict absolute paths, shell commands, custom tools, network access, extension code, or filesystem access available to the Pi process.
|
|
232
|
-
For real isolation, run Pi in a container, VM, micro-VM, or OS sandbox with only the required paths and credentials mounted.
|
|
233
|
-
|
|
234
|
-
## 🧭 Proactive use
|
|
235
|
-
|
|
236
|
-
When registered, deprecated `subagent` advertises its migration paths and limits compatibility use to existing callers or explicit requests whose orchestration semantics lack a detached replacement.
|
|
237
|
-
When stateful lifecycle tools are registered, stable `subagent_spawn` metadata explains both delivery modes and the session-guidance message identifies the active completion policy.
|
|
238
|
-
Changing a live policy through `/subagents settings` appends a superseding session-guidance message for the next turn without starting a model turn.
|
|
239
|
-
|
|
240
|
-
The current session-guidance message advertises the agent catalog automatically, so no preliminary list call is needed.
|
|
241
|
-
Each entry exposes the exact declared capability and tool identifiers needed by an enforced contract, plus filesystem authority and result formats.
|
|
242
|
-
Agents without a valid capability manifest are labeled `undeclared` instead of implying support.
|
|
243
|
-
Built-ins and user agents appear under the default `agentScope: "user"`.
|
|
244
|
-
Trusted project agents appear separately and explicitly require `agentScope: "project"` or `"both"`; project-authored names and descriptions are not read into metadata for untrusted projects.
|
|
245
|
-
If a project definition shares a name with a user or built-in definition, the user version is the default and the project version is used only for `"project"`/`"both"`.
|
|
246
|
-
A user override of a built-in also shows the built-in fallback available with `agentScope: "project"`; `"both"` keeps the user definition.
|
|
247
|
-
The catalog is bounded and reports its omission count; metadata discovery also caps files and bytes read per scope.
|
|
248
|
-
Each newer session-guidance message explicitly supersedes earlier guidance while preserving the existing conversation prefix.
|
|
249
|
-
|
|
250
|
-
Delegation guidance:
|
|
251
|
-
|
|
252
|
-
- The main agent owns overall planning, immediate critical-path work, integration, final verification, and the final answer.
|
|
253
|
-
- Use **no subagent** for simple answers, quick targeted edits, latency-sensitive one-step work, tightly coupled work, or the main agent's immediate blocker.
|
|
254
|
-
- Before one ordinary `subagent_spawn`, identify useful non-overlapping main-agent work that can start immediately and decide how completion will be integrated.
|
|
255
|
-
- A single async `worker` may implement a bounded slice with clear ownership while the main agent advances its named local task.
|
|
256
|
-
- If no useful main-agent work exists, perform the single-lane task directly instead of spawning one ordinary worker.
|
|
257
|
-
- A single worker without concurrent main-agent work remains available when the user explicitly requests a specialist model, tool profile, or isolation boundary.
|
|
258
|
-
- With default `completionDelivery: "next-turn"`, use detached work only when the current response does not depend on its result because an idle root is not awakened.
|
|
259
|
-
- With `completionDelivery: "auto-resume"`, detached work may affect the final answer because completion steers into active work or requests a later synthesis turn from idle.
|
|
260
|
-
- Mark every final-answer-dependent spawn with `completionRequirement: "required"`, retain its returned ID or path, treat interim output as progress, and synthesize only after every corresponding completion is visible or terminal.
|
|
261
|
-
- After `subagent_spawn` returns, immediately continue the identified local task instead of merely announcing the spawn, waiting, polling, duplicating the child task, or ending while useful local work remains.
|
|
262
|
-
- Do not duplicate a running child's assigned work; use a bounded parent fallback only after completion reports failure or insufficient evidence.
|
|
263
|
-
- Use multiple workers only for truly independent slices with disjoint write ownership and safe workspace concurrency, and keep integration in the main agent.
|
|
264
|
-
- Keep ordinary planning in the main agent or express a genuine dependency graph through an explicit caller-authored `workflow` payload.
|
|
265
|
-
- Keep ordinary review in the main agent with a review skill and deterministic checks; reserve custom verifier agents or panels for consequential independent verification.
|
|
266
|
-
- Do not choose deprecated `subagent` for new work; retain it only for an existing caller or an explicit request whose chain, fan-in, panel, or workflow semantics lack a detached replacement.
|
|
267
|
-
- Do not use project-local agents unless the user explicitly opts into them with `agentScope: "project"` or `"both"`; keep confirmation enabled for untrusted repositories.
|
|
268
|
-
|
|
269
|
-
Examples where the main agent chooses the topology:
|
|
270
|
-
|
|
271
|
-
No subagent for a known-file edit:
|
|
272
|
-
|
|
273
|
-
```txt
|
|
274
|
-
Rename one symbol in src/foo.ts.
|
|
275
|
-
```
|
|
93
|
+
| `subagent_spawn` | `task`, optional `tools`, `thinkingLevel`, `timeout` | Start one subagent job and return its `jobId`. |
|
|
94
|
+
| `subagent_inspect` | none | List privacy-filtered retained-job metadata. |
|
|
95
|
+
| `subagent_cancel` | `jobId` | Idempotently cancel one queued or running job. |
|
|
96
|
+
| `subagent_wait` | `jobId`, optional `timeout` | Wait for a job or return early for an incoming child message. |
|
|
97
|
+
| `subagent_send` | `recipient` or `requestId`, plus `message` | Send a new request to an active child or answer one pending child request. |
|
|
276
98
|
|
|
277
|
-
|
|
99
|
+
Every child exposes these communication tools in addition to its selected work tools:
|
|
278
100
|
|
|
279
|
-
|
|
280
|
-
|
|
101
|
+
| Tool | Parameters | Purpose |
|
|
102
|
+
| --- | --- | --- |
|
|
103
|
+
| `subagent_send` | optional `requestId`, plus `message` | Omit `requestId` to send a new request to main, or provide it to answer one pending main-agent request. |
|
|
104
|
+
| `subagent_wait` | `requestId`, optional `timeout` | Wait for the main agent's plain-text response to a child-originated request. |
|
|
281
105
|
|
|
282
|
-
|
|
283
|
-
{
|
|
284
|
-
"agent": "worker",
|
|
285
|
-
"task": "Implement the approved formatter slice only in src/formatter.ts and test/formatter.test.ts. Do not edit src/parser.ts. Report changed paths, checks, and remaining risks.",
|
|
286
|
-
"completionRequirement": "required"
|
|
287
|
-
}
|
|
288
|
-
```
|
|
106
|
+
Main and child processes receive separate provider-visible `subagent_send` definitions for their own context.
|
|
289
107
|
|
|
290
|
-
|
|
291
|
-
Shared-workspace agents may write concurrently by default; use isolated worktrees when repository-write isolation is required.
|
|
292
|
-
|
|
293
|
-
A blocking fan-out is reserved for output that must be synthesized before the main agent continues:
|
|
294
|
-
|
|
295
|
-
```json
|
|
296
|
-
{
|
|
297
|
-
"tasks": [
|
|
298
|
-
{
|
|
299
|
-
"agent": "explorer",
|
|
300
|
-
"task": "Research auth-related source files. Report paths and open questions. Do not edit files."
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
"agent": "explorer",
|
|
304
|
-
"task": "Research auth-related tests. Report coverage gaps. Do not edit files."
|
|
305
|
-
}
|
|
306
|
-
],
|
|
307
|
-
"aggregator": {
|
|
308
|
-
"agent": "explorer",
|
|
309
|
-
"task": "Merge these findings into a concise implementation-risk summary. Use {previous}."
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
```
|
|
108
|
+
The main agent starts a request with an active job ID as `recipient` and omits `requestId`.
|
|
313
109
|
|
|
314
|
-
|
|
110
|
+
The main agent answers a child request with `requestId` and omits `recipient`.
|
|
315
111
|
|
|
316
|
-
|
|
317
|
-
It never starts a child, sends or acknowledges mailbox messages, interrupts or closes a run, changes settings, refreshes providers, resolves credentials, or modifies files.
|
|
112
|
+
A child starts a request to main by omitting `requestId`.
|
|
318
113
|
|
|
319
|
-
|
|
320
|
-
| --- | --- | --- |
|
|
321
|
-
| `list_agents` | Optional `agentScope` (default `user`) and `limit` (default 32, maximum 100) | Bounded agent metadata and omission counts |
|
|
322
|
-
| `get_agent` | Required `agent`; optional `agentScope` | One resolved definition, safe source path, configured tools, and consultation-effective tools; never the system prompt |
|
|
323
|
-
| `list_runs` | Optional `includeClosed` and `limit` (default 50, maximum 100) | Metadata-only retained-run summaries, turn generation, pending-completion count, and unread counts |
|
|
324
|
-
| `get_run` | Required `agentId` | Safe `cwd`, current run and turn generation, current-task/error summaries, thinking level, context footprint, protocol, effective transport, bounded timing/usage telemetry, structured result when valid, policy, history count, pending-completion count, and unread count |
|
|
325
|
-
| `list_workflows` | Optional `limit` (default 50, maximum 100) | Metadata-only persisted blocking-workflow summaries for the current session |
|
|
326
|
-
| `get_workflow` | Required `workflowId` | Bounded task states, generations, dependencies, plan identities, artifact metadata, verification state, and outcome reasons without artifact contents |
|
|
327
|
-
| `list_models` | Optional `limit` (default 50, maximum 100) | Session-scoped models, or the already-loaded available snapshot |
|
|
328
|
-
| `preview_context` | Optional `context` and `contextEntryIds` | Selected mode, user turns, source count, UTF-8 bytes, and truncation without returning context text |
|
|
329
|
-
| `status` | No additional fields | Effective workflow, runtime counts/transport, detached limit values, completion delivery, local usage-recording state, consultation resources, and configured/runtime settings with per-field sources |
|
|
330
|
-
| `diagnose` | No additional fields | Structured `pass`, `warning`, and `fail` checks; failed checks are report data rather than a tool error |
|
|
331
|
-
|
|
332
|
-
The schema rejects fields that do not belong to the selected action.
|
|
333
|
-
Explicit `project` or `both` scope fails before project-agent discovery unless Pi already trusts the project.
|
|
334
|
-
Run inspection never returns history output, stored context, or mailbox content; unread counts come from a metadata-only snapshot and do not acknowledge messages.
|
|
335
|
-
Workflow inspection reads validated, redacted snapshots without quarantining or rewriting invalid files.
|
|
336
|
-
Paths beneath the Pi agent directory use `~`, project paths are workspace-relative, model objects are projected through an allow-list, and model-facing text is bounded to 50 KiB or 2,000 lines.
|
|
337
|
-
|
|
338
|
-
`subagent_manage` no longer accepts its former compatibility `list` action.
|
|
339
|
-
Use `subagent_inspect({ "action": "list_runs", "includeClosed": true })` for metadata-only discovery and `get_run` for detail.
|
|
340
|
-
|
|
341
|
-
## 📖 Read-only consultation
|
|
342
|
-
|
|
343
|
-
Ordinary planning and review stay in the main agent with applicable skills and deterministic checks.
|
|
344
|
-
Use `subagent_consult` only when bounded read-only evidence and an independent perspective justify making the main agent wait.
|
|
345
|
-
It is registered whenever blocking delegation is enabled and runs exactly one synchronous, non-retained child with `--no-session`, `--no-extensions`, and only the effective intersection of the agent tools with `read`, `grep`, `find`, and `ls`.
|
|
346
|
-
A missing tool list receives those four defaults, while an explicit `tools: []` receives `--no-tools`.
|
|
347
|
-
Write, shell, lifecycle, custom, and extension tools cannot enter the child allow-list.
|
|
348
|
-
The executor policy remains authoritative even when the task or agent prompt asks for implementation.
|
|
349
|
-
|
|
350
|
-
```json
|
|
351
|
-
{
|
|
352
|
-
"agent": "explorer",
|
|
353
|
-
"task": "Inspect the authentication changes and report correctness and security findings with paths.",
|
|
354
|
-
"thinkingLevel": "high"
|
|
355
|
-
}
|
|
356
|
-
```
|
|
114
|
+
A child answers a main-agent request by providing `requestId`.
|
|
357
115
|
|
|
358
|
-
|
|
359
|
-
Any agent resolved from that scope may be selected; consultation always intersects its configured tools with the enforced read-only allow-list rather than defining a separate read-only agent category.
|
|
360
|
-
An unknown name fails before launch with a bounded name/source list for the requested scope.
|
|
361
|
-
Project scope is rejected before discovery when the project is untrusted.
|
|
362
|
-
A trusted project agent still asks for confirmation by default; non-interactive calls fail closed unless they explicitly send `confirmProjectAgents: false`.
|
|
363
|
-
Declining an interactive confirmation returns a normal cancelled result without launching or charging a child.
|
|
116
|
+
Execution and wait timeouts use seconds, accept finite numbers greater than zero through 2,147,483.647, and have no default.
|
|
364
117
|
|
|
365
|
-
|
|
118
|
+
Omitting a job execution timeout lets the child run until it exits, is cancelled, the session shuts down, or the Pi process exits.
|
|
366
119
|
|
|
367
|
-
|
|
368
|
-
| --- | --- |
|
|
369
|
-
| `"project-context"` (default) | Keep ordinary user context/system files and trusted project `AGENTS.md`, `CLAUDE.md`, `SYSTEM.md`, and `APPEND_SYSTEM.md`; disable skills and prompt templates |
|
|
370
|
-
| `"none"` | Use only the package consultation base, selected agent prompt, and enforced read-only instruction |
|
|
371
|
-
| `"all"` | Keep ordinarily discoverable trusted context/system/append-system files, skills, and prompt templates |
|
|
372
|
-
|
|
373
|
-
Extensions remain disabled for all three values.
|
|
374
|
-
Pi core owns system-prompt source precedence: a trusted project prompt wins over the global prompt, with the global prompt used as fallback.
|
|
375
|
-
A selected Pi prompt source must be a readable regular file; directories, FIFOs, devices, sockets, and unreadable sources fail before child launch.
|
|
376
|
-
A current target uses the session's effective project trust, including session-only or CLI overrides.
|
|
377
|
-
An external target uses the nearest saved trust decision.
|
|
378
|
-
For an untrusted, explicitly denied, unsaved, or trust-error target, consultation remains available when `cwdPolicy.consultation` permits it but automatically downgrades to `resources: "none"`.
|
|
379
|
-
This also disables context files because Pi does not protect `AGENTS.md` and `CLAUDE.md` with project trust alone.
|
|
380
|
-
A saved-trusted external target uses the configured resource policy and discovers `SYSTEM.md`, `APPEND_SYSTEM.md`, and ordinary child context from that target rather than the parent workspace.
|
|
381
|
-
|
|
382
|
-
Both settings are user-owned in `~/.pi/agent/pi-subagents.json`; projects cannot override them.
|
|
383
|
-
`cwdPolicy.consultation: "current-workspace"` rejects every canonical external target before agent discovery or launch even when that target is saved-trusted.
|
|
384
|
-
This is not a path sandbox: read-only tools can still read an explicitly requested accessible absolute path.
|
|
385
|
-
|
|
386
|
-
Result details report the canonical safe cwd, current/external boundary, bounded target-trust decision/source/warning, requested and effective tools/resources, downgrade reason, agent/model/thinking/timeout metadata, and the facts that extensions, session persistence, and retained-agent state are disabled.
|
|
387
|
-
They never dump prompt contents or the full trust store.
|
|
388
|
-
Nested model usage is returned through Pi's usage field, so footer, `/session`, and RPC totals include consultation cost.
|
|
389
|
-
Validation, disallowed targets, and launch failures throw.
|
|
390
|
-
Failures after model launch preserve bounded partial evidence and usage while the finalized Pi tool result is marked as an error.
|
|
391
|
-
Explicit abort, session replacement, and shutdown use the existing process-tree termination and temporary-file cleanup path; a work timeout additionally makes one separately bounded, tool-less summary attempt after abort.
|
|
392
|
-
|
|
393
|
-
## 🚀 Blocking batch examples
|
|
394
|
-
|
|
395
|
-
Every example in this section calls `subagent` and keeps the main agent unavailable until the batch finishes.
|
|
396
|
-
Use `subagent_spawn` instead when the work can complete asynchronously and its configured completion policy supports when synthesis is needed.
|
|
397
|
-
|
|
398
|
-
Run one read-only reconnaissance agent:
|
|
399
|
-
|
|
400
|
-
```json
|
|
401
|
-
{
|
|
402
|
-
"agent": "explorer",
|
|
403
|
-
"task": "Find the statusline extension entry points"
|
|
404
|
-
}
|
|
405
|
-
```
|
|
120
|
+
A wait timeout or caller cancellation stops only that wait and does not cancel its job or message request.
|
|
406
121
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
Run multiple agents in parallel with a shared thinking level and one per-task override:
|
|
410
|
-
|
|
411
|
-
```json
|
|
412
|
-
{
|
|
413
|
-
"tasks": [
|
|
414
|
-
{
|
|
415
|
-
"agent": "explorer",
|
|
416
|
-
"task": "Map package metadata files",
|
|
417
|
-
"timeoutMs": 30000,
|
|
418
|
-
"thinkingLevel": "low"
|
|
419
|
-
},
|
|
420
|
-
{
|
|
421
|
-
"agent": "explorer",
|
|
422
|
-
"task": "Inspect TypeScript config consistency"
|
|
423
|
-
}
|
|
424
|
-
],
|
|
425
|
-
"timeoutMs": 120000,
|
|
426
|
-
"thinkingLevel": "medium"
|
|
427
|
-
}
|
|
428
|
-
```
|
|
122
|
+
An incoming main-agent request interrupts an active child `subagent_wait` after RPC steering is queued so the child can receive the new request.
|
|
429
123
|
|
|
430
|
-
|
|
431
|
-
Do not send `null`, empty strings, or an empty object for an unused optional field; for compatibility, an aggregator with an empty or whitespace-only `agent` or `task` is treated as absent.
|
|
432
|
-
|
|
433
|
-
Run parallel workers, then aggregate their results:
|
|
434
|
-
|
|
435
|
-
```json
|
|
436
|
-
{
|
|
437
|
-
"tasks": [
|
|
438
|
-
{ "agent": "explorer", "task": "Find auth-related code" },
|
|
439
|
-
{ "agent": "explorer", "task": "Find auth-related tests" }
|
|
440
|
-
],
|
|
441
|
-
"aggregator": {
|
|
442
|
-
"agent": "explorer",
|
|
443
|
-
"task": "Merge, dedupe, and verify these findings. Use {previous}."
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
```
|
|
124
|
+
The interrupted child-originated request remains active and may be waited on again.
|
|
447
125
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
```json
|
|
451
|
-
{
|
|
452
|
-
"chain": [
|
|
453
|
-
{ "agent": "explorer", "task": "Find subagent-related code" },
|
|
454
|
-
{
|
|
455
|
-
"agent": "explorer",
|
|
456
|
-
"task": "Summarize the relevant paths and open questions from this inventory: {previous}"
|
|
457
|
-
}
|
|
458
|
-
]
|
|
459
|
-
}
|
|
460
|
-
```
|
|
126
|
+
Tasks are limited to 50 KiB of UTF-8 text.
|
|
461
127
|
|
|
462
|
-
|
|
463
|
-
Run an evidence-preserving panel only when consequential independent perspectives justify blocking the main agent:
|
|
464
|
-
|
|
465
|
-
```json
|
|
466
|
-
{
|
|
467
|
-
"panel": {
|
|
468
|
-
"id": "auth-panel",
|
|
469
|
-
"preset": "code-review",
|
|
470
|
-
"task": "Review the authentication change for correctness and regressions.",
|
|
471
|
-
"context": "Inspect the current repository snapshot and existing test evidence.",
|
|
472
|
-
"reviewers": [
|
|
473
|
-
{ "id": "correctness", "agent": "explorer", "focus": "Control flow and edge cases" },
|
|
474
|
-
{ "id": "tests", "agent": "explorer", "focus": "Coverage and regression risk" }
|
|
475
|
-
],
|
|
476
|
-
"synthesizer": { "agent": "explorer" },
|
|
477
|
-
"minValidReviews": 2
|
|
478
|
-
},
|
|
479
|
-
"totalTimeoutMs": 120000
|
|
480
|
-
}
|
|
481
|
-
```
|
|
128
|
+
Requests and responses are limited to 48 KiB and 1,992 lines so their protocol envelopes fit Pi's 50 KiB and 2,000-line model-text bounds without truncating accepted content.
|
|
482
129
|
|
|
483
|
-
|
|
484
|
-
Reviewer-specific `focus` text is appended after the shared block.
|
|
485
|
-
The executor accepts only strict `pi-subagents:panel-review:v1` artifacts, stamps reviewer provenance, and starts synthesis only after the valid-review barrier.
|
|
486
|
-
Agreement is corroboration rather than proof, and a vote cannot clear a correctness, safety, security, or explicit-requirement blocker.
|
|
487
|
-
If too few valid reviews remain, the tool returns `insufficient-panel` with bounded partial evidence and failure classes without running synthesis or claiming consensus.
|
|
488
|
-
Review, evidence-finalization, synthesis, and cleanup receive explicit phase allocations, and reviewer work cannot consume the synthesis or cleanup reserve.
|
|
489
|
-
Only transient launch or transport failures receive one bounded retry; invalid contracts, semantic stalls, permission failures, exhausted budgets, cancellation, and deterministic task failures do not.
|
|
490
|
-
Read-only reviewers share the approved target, while conservatively write-capable reviewers receive separate disposable Git worktrees from one clean base.
|
|
491
|
-
Worktrees isolate repository writes but do not isolate processes, the network, secrets, credentials, or the rest of the filesystem.
|
|
492
|
-
The blocking panel owns every reviewer, synthesizer, timer, generation, transport, and worktree and closes them when the call settles or Pi emits graceful session replacement or shutdown.
|
|
493
|
-
An uncatchable host kill or forced process termination cannot guarantee cleanup; inspect `git worktree list`, remove any confirmed generated `pi-subagent-worktree-*` entry, and run `git worktree prune` if the host terminated before Pi dispatched lifecycle cleanup.
|
|
494
|
-
Panel WorkItem snapshots persist metadata and artifact references for current-session inspection without storing raw review bodies.
|
|
495
|
-
|
|
496
|
-
Run an explicit dependency workflow:
|
|
497
|
-
|
|
498
|
-
```json
|
|
499
|
-
{
|
|
500
|
-
"workflow": {
|
|
501
|
-
"id": "auth-review",
|
|
502
|
-
"tasks": [
|
|
503
|
-
{
|
|
504
|
-
"id": "inventory",
|
|
505
|
-
"agent": "explorer",
|
|
506
|
-
"task": "Produce the auth inventory artifact.",
|
|
507
|
-
"resultFormat": "structured-v2",
|
|
508
|
-
"readPaths": ["src/auth"]
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
"id": "review",
|
|
512
|
-
"agent": "explorer",
|
|
513
|
-
"task": "Inspect the inventory and report verification evidence.",
|
|
514
|
-
"dependsOn": ["inventory"],
|
|
515
|
-
"inputArtifacts": ["auth-inventory"],
|
|
516
|
-
"resultFormat": "structured-v2"
|
|
517
|
-
}
|
|
518
|
-
]
|
|
519
|
-
},
|
|
520
|
-
"totalTimeoutMs": 120000
|
|
521
|
-
}
|
|
522
|
-
```
|
|
130
|
+
Each job may have up to four unresolved or answered-but-not-consumed requests across both directions.
|
|
523
131
|
|
|
524
|
-
|
|
525
|
-
The verifier examples below assume a custom user agent named `api-reviewer` with `independent-review` capability.
|
|
526
|
-
The executor infers the final mutating integration owner when none is declared, synthesizes one distinct read-only verifier, runs declared deterministic checks in a disposable Git worktree overlaid with the submitted state, and accepts only the exact unchanged submitted state.
|
|
527
|
-
Every deterministic check has a stable evidence ID, a direct executable with argument-array invocation, and an optional relative `cwd` and timeout.
|
|
528
|
-
Only `git`, `node`, `npm`, and `npx` are accepted; shell command strings fail before child allocation.
|
|
529
|
-
The integration owner must request `structured-v2`, declare a non-empty `writePaths` scope, and name current required evidence through its delegation contract.
|
|
530
|
-
Every required evidence ID must match a currently passed executor-owned check; worker-authored artifact metadata never satisfies that binding.
|
|
531
|
-
|
|
532
|
-
```json
|
|
533
|
-
{
|
|
534
|
-
"workflow": {
|
|
535
|
-
"verifiedExecution": {
|
|
536
|
-
"verifierAgent": "api-reviewer",
|
|
537
|
-
"maxReworkCycles": 1,
|
|
538
|
-
"checks": [
|
|
539
|
-
{
|
|
540
|
-
"id": "focused-test",
|
|
541
|
-
"command": "npm",
|
|
542
|
-
"args": ["test", "--", "feature"],
|
|
543
|
-
"timeoutMs": 120000
|
|
544
|
-
}
|
|
545
|
-
]
|
|
546
|
-
},
|
|
547
|
-
"tasks": [
|
|
548
|
-
{
|
|
549
|
-
"id": "implementation",
|
|
550
|
-
"agent": "worker",
|
|
551
|
-
"task": "Implement the contracted change.",
|
|
552
|
-
"writePaths": ["src", "test"],
|
|
553
|
-
"acceptanceCriteria": ["The focused regression test passes"],
|
|
554
|
-
"resultFormat": "structured-v2",
|
|
555
|
-
"contract": {
|
|
556
|
-
"version": "pi-subagents:delegation:v2",
|
|
557
|
-
"level": "full",
|
|
558
|
-
"taskId": "implementation",
|
|
559
|
-
"objective": "Implement the contracted change",
|
|
560
|
-
"requiredEvidence": ["focused-test"],
|
|
561
|
-
"sideEffectPolicy": "mutating"
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
]
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
```
|
|
132
|
+
The terminal states are `completed`, `partial`, `failed`, `timed_out`, and `cancelled`.
|
|
568
133
|
|
|
569
|
-
|
|
570
|
-
That task must directly and only depend on the integration owner, use `structured-v2`, select the configured distinct verifier agent, and declare an enforced read-only contract without shell or custom tools.
|
|
571
|
-
The executor narrows accepted verifier authority to `read` even when the selected agent normally has broader tools, and disables verifier extensions, skills, prompt templates, and inherited context files.
|
|
572
|
-
|
|
573
|
-
The older explicit verifier contract remains available as a compatibility gate without managed integration:
|
|
574
|
-
|
|
575
|
-
```json
|
|
576
|
-
{
|
|
577
|
-
"workflow": {
|
|
578
|
-
"tasks": [
|
|
579
|
-
{
|
|
580
|
-
"id": "implementation",
|
|
581
|
-
"agent": "worker",
|
|
582
|
-
"task": "Implement the contracted change.",
|
|
583
|
-
"resultFormat": "structured-v2",
|
|
584
|
-
"contract": {
|
|
585
|
-
"version": "pi-subagents:delegation:v2",
|
|
586
|
-
"level": "full",
|
|
587
|
-
"taskId": "implementation",
|
|
588
|
-
"objective": "Implement the contracted change",
|
|
589
|
-
"admission": {
|
|
590
|
-
"contextPressure": "medium",
|
|
591
|
-
"independentWorkItems": 1,
|
|
592
|
-
"coupling": "dense",
|
|
593
|
-
"verificationRequired": true,
|
|
594
|
-
"verificationAvailable": true,
|
|
595
|
-
"budgetAllowsChildren": true,
|
|
596
|
-
"requirementsComplete": true
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
},
|
|
600
|
-
{
|
|
601
|
-
"id": "verification",
|
|
602
|
-
"agent": "api-reviewer",
|
|
603
|
-
"task": "Independently verify the staged result.",
|
|
604
|
-
"dependsOn": ["implementation"],
|
|
605
|
-
"verifierFor": "implementation",
|
|
606
|
-
"resultFormat": "structured-v2"
|
|
607
|
-
}
|
|
608
|
-
]
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
```
|
|
134
|
+
`subagent_inspect` never returns complete task text, child output, prompts, selected tools, context, credentials, environment variables, requests, responses, or secrets.
|
|
612
135
|
|
|
613
|
-
|
|
614
|
-
Workflow scheduling starts at most two mutating tasks concurrently, while declared read-only work may use the existing four-child ceiling.
|
|
615
|
-
Set `workflow.honorAdmission: true` only when explicit contract admission metadata should be allowed to decline parent-owned or insufficient-evidence work before launch; admission never silently widens the requested architecture.
|
|
616
|
-
Workflow result details include the final ledger, scheduling decisions, artifact versions, task generations, attempts, hedge use, accepted plan identity, and bounded capability-grant metadata.
|
|
617
|
-
A task that explicitly requires independent verification must have exactly one direct-dependent `verifierFor` task using a different agent, and both tasks must request `structured-v2`.
|
|
618
|
-
The producer stops in `awaiting-verification`, its own passing verification claims remain untrusted, and ordinary downstream tasks stay blocked until the executor records an accepted verifier receipt.
|
|
619
|
-
The verifier runs alone in a fresh subprocess context against one bounded Git-visible tree identity and must encode `verification-accepted`, `verification-rework`, or `verification-rejected` through the documented `structured-v2` status and reason fields.
|
|
620
|
-
Dirty-tree identity covers at most 1 MiB across separately framed staged and unstaged binary diffs plus bounded non-ignored untracked paths and bytes; submodules, unsupported states, and changing trees fail closed.
|
|
621
|
-
The compatibility gate preserves bounded rework or rejection evidence but does not replay the producer automatically.
|
|
622
|
-
|
|
623
|
-
With `verifiedExecution`, execution completion and acceptance are separate `pi-subagents:work-acceptance:v1` states.
|
|
624
|
-
A worker's own verification, confidence, prose, consensus, or exit status cannot move `pending` acceptance to `accepted`.
|
|
625
|
-
The executor-owned `pi-subagents:verification-receipt:v1` binds both tree captures, patch digest, changed paths, accepted scope, target and verifier generations and `ExecutionPlan` IDs, verifier identity, acceptance criteria, required current evidence, and bounded deterministic check receipts.
|
|
626
|
-
Each receipt is capped at 12 KiB, each stored check stream at 2 KiB, and oversized acceptance evidence fails closed rather than expanding tool details.
|
|
627
|
-
The verifier receives the original objective, current artifact metadata, immutable tree identity, and executor-owned check output rather than the worker narrative.
|
|
628
|
-
Verifier mutation, a stale or replaced generation, a failed or unsafe check, missing evidence, wrong scope, patch, plan, tree, or identity, cancellation, timeout, and unsupported Git state all produce non-success.
|
|
629
|
-
One verifier `rework` decision may rotate the worker and verifier generations when `maxReworkCycles` is `1`; prior grants are revoked, prior evidence remains history, only current requirements and findings are added, and a second rejection is terminal.
|
|
630
|
-
Crashes, timeouts, cancellation, ambiguous settlement, and drift are never replayed.
|
|
631
|
-
The disposable check worktree includes bounded tracked and non-ignored untracked files and is removed after checks.
|
|
632
|
-
When the repository has a local `node_modules` directory, the worktree is nested beneath it so normal Node and npm resolution can read the installed dependency tree without copying it.
|
|
633
|
-
The worktree isolates repository build output, but it does not make the installed dependency tree read-only and is not an operating-system sandbox for processes, network, secrets, absolute paths, or host credentials.
|
|
634
|
-
The accepted state remains the selected shared workspace; no general patch merge or conflict resolver is added.
|
|
635
|
-
|
|
636
|
-
Omitting `verifiedExecution` preserves prior workflow behavior, including the older explicit verifier gate above.
|
|
637
|
-
To downgrade, finish active workflows, remove `verifiedExecution`, and either use the explicit `verifierFor` compatibility form or perform verification in the parent.
|
|
638
|
-
Older package versions reject the unknown managed contract rather than silently providing its guarantees.
|
|
639
|
-
Explicit workflow transitions are atomically persisted as mode-0600, private-text-redacted snapshots for current-session `list_workflows` and `get_workflow` inspection; in-flight execution or acceptance restores as interrupted non-success, and no prior side effect is automatically resumed.
|
|
640
|
-
Legacy v1 and v2 records without acceptance fields retain their prior completed terminal meaning, while v1 self-reported verification flags and artifact trust remain untrusted.
|
|
641
|
-
|
|
642
|
-
## 🔁 Stateful agents
|
|
643
|
-
|
|
644
|
-
Stateful lifecycle tools are available by default.
|
|
645
|
-
`subagent_spawn` is detached: it schedules work, returns immediately with an opaque `agentId` plus canonical `taskPath`, and later delivers a bounded completion to its intended parent.
|
|
646
|
-
Every turn receives an executor-owned `runId`, monotonically increasing agent-local generation, and unique `completionId`.
|
|
647
|
-
A caller can set `completionRequirement: "required"` on a spawn or follow-up to bind final-answer dependency state to that exact run and generation.
|
|
648
|
-
Required state moves from `pending` to `available` after durable terminal completion and to `visible` only after the intended parent context observes the exact completion ID.
|
|
649
|
-
Interruption, close, stale restore, and shutdown terminalize unfinished requirements explicitly instead of silently dropping them.
|
|
650
|
-
Tool-result details preserve fork-sensitive requirement evidence, and inspection projects bounded requirement state.
|
|
651
|
-
The successful tool handoff and delivered completion messages are the ordinary model-visible source of requirement state.
|
|
652
|
-
When a resumed session terminalizes an in-flight required run and the retained transcript still contains its pending handoff, one hidden append-only transition supersedes that stale evidence before the next model turn.
|
|
653
|
-
This also covers compacted contexts that retain the handoff.
|
|
654
|
-
If leading compaction or branch summaries remove the handoff, one canonical hidden fallback is restored at a fixed boundary immediately after the summaries.
|
|
655
|
-
Branch-local boundary metadata preserves that exact fallback across reload and branch navigation.
|
|
656
|
-
That restored fallback remains fixed for the summary epoch while later cancellation transitions or completion messages supersede it at the conversation tail.
|
|
657
|
-
The runtime rejects a sixty-fifth unresolved required run before acceptance so every unresolved exact identity fits in the bounded parent context.
|
|
658
|
-
The terminal completion and recipient are persisted before delivery, simultaneous root completions are batched, and the root broker allows at most one in-flight wake until that parent turn starts.
|
|
659
|
-
In TUI mode, completion messages show a compact task and payload summary while collapsed; use the configured tool-output expansion action (`Ctrl+O` by default) to show or hide the complete message globally.
|
|
660
|
-
|
|
661
|
-
Detached work follows a non-polling policy.
|
|
662
|
-
Before one ordinary `subagent_spawn`, identify useful non-overlapping main-agent work that starts immediately and a supported completion integration path.
|
|
663
|
-
With default `next-turn` delivery, the current response must not depend on the result because an idle root is not awakened.
|
|
664
|
-
With opt-in `auto-resume`, detached work may affect the final answer because completion steers into an active parent before its next model call or requests a synthesis turn from idle.
|
|
665
|
-
Mark every final-answer-dependent spawn with `completionRequirement: "required"`, retain its returned ID or path, treat interim output as progress, and synthesize only after every corresponding completion is visible or terminal.
|
|
666
|
-
When local work finishes before required children, emit at most one brief progress sentence and end the turn rather than repeating waiting updates or using the requested final format, verdict, or conclusion.
|
|
667
|
-
After spawning, immediately continue the identified local task instead of merely announcing the spawn, waiting, polling `subagent_inspect` or `subagent_mailbox`, duplicating the child task, or ending while useful local work remains.
|
|
668
|
-
Do not duplicate a running child's assigned work; use a bounded parent fallback only after completion reports failure or insufficient evidence.
|
|
669
|
-
Omit `contract` for ordinary `subagent_spawn` calls and use it only when explicit acceptance, authority, evidence, or admission semantics are required.
|
|
670
|
-
Enforced `requestedAuthority.capabilities` and `requestedAuthority.tools` can be checked and narrowed, but enforced `readPaths`, `writePaths`, network, and secret guarantees reject before child launch because the executor cannot provide those boundaries.
|
|
671
|
-
After that rejection, retry once without the unsupported fields or with audit enforcement only when they were advisory; stop when they represented a required security boundary.
|
|
672
|
-
Add another detached agent only for truly independent work with safe workspace concurrency and disjoint write ownership.
|
|
673
|
-
When both blocking and stateful delegation are enabled, `subagent_await` may intentionally join one retained turn after useful overlapping parent work is complete.
|
|
674
|
-
Its `timeoutMs` defaults to 30 seconds and limits only the wait; timeout or caller cancellation does not interrupt or close the child.
|
|
675
|
-
The normal at-least-once completion channel remains active, so the same completion may still arrive after the await result.
|
|
676
|
-
|
|
677
|
-
A detached `worker` may directly implement a bounded slice with clear ownership while the main agent handles another useful slice and retains integration and final verification.
|
|
678
|
-
Without concurrent main-agent work, use one worker only for an explicit user-requested specialist model, tool profile, or isolation boundary.
|
|
679
|
-
Simple and immediate critical-path work should stay in the main agent.
|
|
680
|
-
|
|
681
|
-
`stateful.completionDelivery` controls settled completion delivery:
|
|
682
|
-
|
|
683
|
-
- `"next-turn"` (default) sends `deliverAs: "steer"` without a turn trigger.
|
|
684
|
-
Pi queues it into an active root's context, while an idle root records it without waking.
|
|
685
|
-
- `"auto-resume"` sends completion to an active root with `deliverAs: "steer"` and no turn trigger, so Pi places it after the current assistant turn and before the next model call.
|
|
686
|
-
An idle root with no pending user or extension input receives at most one in-flight synthesis wake; pending input suppresses that wake, and simultaneous idle completions share one turn.
|
|
687
|
-
|
|
688
|
-
Completion delivery and required-run context make dependencies visible to the model but do not enforce model obedience, rewrite premature assistant output, or provide a hard final-answer barrier.
|
|
689
|
-
The supported Pi extension API exposes no hook for buffering assistant deltas before display and no replay-safe steering activity for a cross-mode interruptible join.
|
|
690
|
-
`message_end` replacement can repair finalized persistence but cannot retract already displayed streaming output.
|
|
691
|
-
The package therefore keeps `subagent_await` as the accurately documented blocking fallback and does not claim an extension-only hard barrier.
|
|
692
|
-
The repository protocol note at `docs/async-runtime-protocol.md` records the exact state machine and unavailable core guarantees; this work does not modify or publish Pi core packages.
|
|
693
|
-
The bounded persisted completion outbox provides ordered at-least-once delivery across process restart without replaying the child turn.
|
|
694
|
-
A top-level completion targets `/root`; a nested completion enters the direct retained parent's mailbox and is not duplicated into the root transcript.
|
|
695
|
-
If the direct parent cannot own delivery, routing walks toward the nearest live retained ancestor and uses `/root` only as the final fallback.
|
|
696
|
-
An idle parent remains asleep, and inspection exposes its unread and pending-completion counts until a later turn consumes the envelope.
|
|
697
|
-
When state must be reduced to its storage bound, persistence drops roots without pending completions first and trims old history rather than discarding an outbox-owned root.
|
|
698
|
-
A completion is acknowledged only after the intended recipient context observes its exact `completionId`; an injection that returns synchronously but never reaches context remains pending for retry.
|
|
699
|
-
The broker retains a bounded set of recently acknowledged IDs to suppress same-session re-enqueue while keeping memory bounded.
|
|
700
|
-
If the process exits after context assembly but before acknowledgement is persisted, the same ID can be delivered again and consumers must deduplicate it.
|
|
701
|
-
Auto-resume applies only to `/root`; nested delivery never silently starts the parent.
|
|
702
|
-
Transient terminal-persistence failures retry with bounded exponential backoff and keep the run pending; shutdown cancels retry waits and reports a final persistence failure instead of silently resolving unsaved work.
|
|
703
|
-
|
|
704
|
-
The default `subprocess` transport preserves compatibility: each turn starts a fresh isolated `pi --mode json -p --no-session` child and receives sanitized, bounded history.
|
|
705
|
-
Pi loads one generated split TypeScript runtime and registers every Subagents tool and command during startup, but loads blocking execution, manager UI, inspection work, and the selected detached transport implementation only on first use.
|
|
706
|
-
Session restoration, pending completion delivery, settings validation, and cleanup ownership remain eager.
|
|
707
|
-
A failed first-use code load is reported normally and can be retried.
|
|
708
|
-
Set `transport` to `in-process` to retain one public Pi SDK `AgentSession` per stateful `agentId`, avoiding repeated process startup while preserving native child history in memory.
|
|
709
|
-
Set it to `rpc` to retain one `pi --mode rpc --no-session --no-extensions` process per active retained agent, preserving native child history with a separate process boundary.
|
|
710
|
-
Set it to `auto` for deterministic preflight selection: read-only built-in tools use in-process, write-capable built-in tools use RPC, and extension/custom tools use subprocess.
|
|
711
|
-
Automatic selection never falls back after child creation or prompt acceptance.
|
|
712
|
-
|
|
713
|
-
Run `/subagents` in TUI mode to open the standard primary manager.
|
|
714
|
-
It leads with how subagents run, what Pi does when work finishes, and counts of working subagents and subagents saved for follow-up.
|
|
715
|
-
**How subagents run**, **Current subagents**, **Settings**, **Diagnostics**, and **Help** are the only top-level actions.
|
|
716
|
-
**Settings** groups **Folders and trusted resources**, **Completion and privacy**, **Agent defaults**, and **Advanced runtime settings** by user task.
|
|
717
|
-
**Diagnostics** shows detailed current-session values, configured values, sources, and the settings path.
|
|
718
|
-
**Advanced runtime settings** provides optional transport and capacity controls that most users can leave unchanged.
|
|
719
|
-
**Agent defaults** groups tool permissions with per-agent model, thinking, and time-limit defaults.
|
|
720
|
-
Per-agent defaults preserve tool and context settings, and explicit tool-call values remain authoritative.
|
|
721
|
-
The parallel-worker input rejects invalid values without discarding the draft and applies a successful save immediately.
|
|
722
|
-
The background-agent limit screen edits saved-subagent capacity, concurrent work, direct children, nested levels, and stored-record capacity.
|
|
723
|
-
Detached-limit saves are durable immediately but apply to the runtime after `/reload` or the next Pi session.
|
|
724
|
-
Escape returns from a nested screen to a newly refreshed manager, while Ctrl+C closes the full flow.
|
|
725
|
-
Exact workflow/reload and project-agent safety confirmations remain extension-owned because they guard live agent and trust-boundary policy rather than ordinary navigation.
|
|
726
|
-
|
|
727
|
-
The direct routes remain predictable: `/subagents settings` opens the same four settings groups as the manager; `/subagents status` reports detailed current-session runtime values separately from configured values, per-field sources, and path; `/subagents help` explains first steps, reload behavior, commands, and the non-sandbox limitation.
|
|
728
|
-
In RPC mode, bare `/subagents` emits the same bounded status through Pi's notification protocol instead of opening a custom TUI.
|
|
729
|
-
JSON and print modes do not emit ad hoc command output.
|
|
730
|
-
Manual edits use `~/.pi/agent/pi-subagents.json` and take effect after reloading Pi:
|
|
731
|
-
|
|
732
|
-
```json
|
|
733
|
-
{
|
|
734
|
-
"blocking": {
|
|
735
|
-
"enabled": false,
|
|
736
|
-
"maxParallelTasks": 8
|
|
737
|
-
},
|
|
738
|
-
"stateful": {
|
|
739
|
-
"enabled": true,
|
|
740
|
-
"transport": "auto",
|
|
741
|
-
"completionDelivery": "auto-resume",
|
|
742
|
-
"maxAgents": 16,
|
|
743
|
-
"maxActiveTurns": 4,
|
|
744
|
-
"maxDepth": 3,
|
|
745
|
-
"maxChildrenPerAgent": 8,
|
|
746
|
-
"maxMailboxMessages": 100,
|
|
747
|
-
"maxMailboxMessageBytes": 16384,
|
|
748
|
-
"idleTtlMs": 3600000,
|
|
749
|
-
"retentionDays": 30,
|
|
750
|
-
"maxStoredAgents": 50
|
|
751
|
-
},
|
|
752
|
-
"cwdPolicy": {
|
|
753
|
-
"consultation": "anywhere",
|
|
754
|
-
"delegation": "trusted-targets"
|
|
755
|
-
},
|
|
756
|
-
"consult": {
|
|
757
|
-
"resources": "project-context"
|
|
758
|
-
},
|
|
759
|
-
"usageRecording": {
|
|
760
|
-
"enabled": false
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
```
|
|
136
|
+
See [`docs/tools.md`](./docs/tools.md) for the concise schema reference.
|
|
764
137
|
|
|
765
|
-
|
|
766
|
-
It refuses to overwrite malformed or invalid settings.
|
|
767
|
-
Supported Pi writers serialize the latest-document read and same-directory temporary-file rename through `pi-subagents.json.mutation-lock`.
|
|
768
|
-
Editors and older extension versions do not participate in that lock, so avoid manual edits while a settings save is in progress.
|
|
769
|
-
`blocking.enabled` defaults to `true`, so **Background plus compatibility methods (async + sync)** remains the compatibility default even though `subagent` is deprecated for new work.
|
|
770
|
-
Set it to `false` for the **Keep Pi available (async)** workflow.
|
|
771
|
-
`blocking.maxParallelTasks` defaults to `8` and accepts positive integers from `1` through `64`.
|
|
772
|
-
It limits worker tasks in one blocking parallel call, while execution still starts at most four workers at once and treats an optional aggregator separately.
|
|
773
|
-
`stateful.enabled` also defaults to `true`; its existing `false` value remains the blocking-only workflow.
|
|
774
|
-
The detached defaults are `maxAgents: 16`, `maxActiveTurns: 4`, `maxChildrenPerAgent: 8`, `maxDepth: 3`, and `maxStoredAgents: 50`.
|
|
775
|
-
`maxDepth` accepts zero or a positive safe integer, while the other four detached limits accept positive safe integers.
|
|
776
|
-
Use `/subagents settings` → **Advanced runtime settings** → **Background agent limits** to edit them without replacing unknown JSON fields.
|
|
777
|
-
The screen shows current-session and configured values separately because changes apply after `/reload`.
|
|
778
|
-
It never reloads automatically, because reload can interrupt retained detached work.
|
|
779
|
-
Lowering retained, depth, or stored capacity shows a projected recovery warning when current records would be omitted.
|
|
780
|
-
Restored parents that already exceed a lowered `maxChildrenPerAgent` remain available, but they cannot gain another child until they fall below the configured limit.
|
|
781
|
-
`cwdPolicy.consultation` defaults to `"anywhere"`, `cwdPolicy.delegation` defaults to `"trusted-targets"`, and `consult.resources` defaults to `"project-context"`.
|
|
782
|
-
The Settings UI applies a saved live change immediately to subsequent launches and appends a superseding session-guidance message; manual edits take effect on session start or `/reload`.
|
|
783
|
-
The UI explicitly states that target/trust settings are not filesystem sandboxing and directs trust changes to Pi `/trust`.
|
|
784
|
-
When stateful tools are enabled, their membership and provider-visible definitions stay fixed across spawn, completion, interrupt, close, mailbox, catalog, and live-policy transitions.
|
|
785
|
-
Ordinary turns preserve the normalized provider-visible prefix, while a new guidance message or required-completion transition starts an explicit append-only prefix epoch.
|
|
786
|
-
Compaction restoration inserts deterministic guidance and requirement fallbacks after leading summaries and retains each restored message for that summary epoch while later tail messages supersede it.
|
|
787
|
-
Branch-local session metadata reconstructs those exact historical boundaries after reload and isolates them during tree navigation, including when refreshed settings require a later guidance transition.
|
|
788
|
-
These rules preserve cache-eligible prefixes but do not guarantee a provider-reported cache hit.
|
|
789
|
-
|
|
790
|
-
| Tool | Purpose |
|
|
791
|
-
| --- | --- |
|
|
792
|
-
| `subagent_spawn` | Start detached work with an optional canonical `taskName`, task-selected thinking and retained timeout, exact-retry `idempotencyKey`, and `text`, `structured-v1`, or `structured-v2` result format; return both `agentId` and `taskPath` immediately and deliver completion asynchronously. |
|
|
793
|
-
| `subagent_send` | Send follow-up work with an optional one-turn timeout override and trigger a new turn on a reusable agent; semantic skew requires explicit `revalidate: true`, and shared-workspace concurrency is allowed by default. |
|
|
794
|
-
| `subagent_manage` | Use `"interrupt"` to retain an agent after aborting active work or `"close"` to release it; both actions accept optional `subtree`. Use `subagent_inspect` for all list and detail operations. |
|
|
795
|
-
| `subagent_mailbox` | Use `action: "send"` for queue-only messages that do not start a turn, or `"read"` to read and optionally acknowledge unread messages. |
|
|
796
|
-
|
|
797
|
-
The action schemas are flat for provider compatibility and reject parameters that belong to another action.
|
|
798
|
-
For example:
|
|
799
|
-
|
|
800
|
-
```json
|
|
801
|
-
{
|
|
802
|
-
"action": "interrupt",
|
|
803
|
-
"agentId": "sa_example",
|
|
804
|
-
"subtree": true
|
|
805
|
-
}
|
|
806
|
-
```
|
|
138
|
+
## ⚙️ Job configuration
|
|
807
139
|
|
|
808
|
-
|
|
809
|
-
{
|
|
810
|
-
"action": "send",
|
|
811
|
-
"agentId": "sa_example",
|
|
812
|
-
"message": "Check the API compatibility note before finishing."
|
|
813
|
-
}
|
|
814
|
-
```
|
|
140
|
+
The task should state the child's role, objective, scope, constraints, and expected result.
|
|
815
141
|
|
|
816
|
-
|
|
817
|
-
Active turns are FIFO-limited by `maxActiveTurns`; excess retained work remains in `starting` state until a slot is available.
|
|
818
|
-
`maxAgents` separately bounds running, queued, and idle records.
|
|
819
|
-
`maxChildrenPerAgent` bounds direct children, while `maxDepth` counts nested levels below a depth-zero root.
|
|
820
|
-
`maxStoredAgents` bounds sanitized records persisted per session and does not increase live runtime capacity.
|
|
821
|
-
`parentId` accepts either an opaque ID or canonical path and creates a bounded child relationship; subtree interrupt and close operate child-first.
|
|
142
|
+
The optional `tools` list limits what the child can do.
|
|
822
143
|
|
|
823
|
-
|
|
144
|
+
Accepted names are `read`, `bash`, `powershell`, `edit`, `write`, `grep`, `find`, and `ls`.
|
|
824
145
|
|
|
825
|
-
|
|
826
|
-
Every live retained record also has a session-scoped path under `/root`, such as `/root/research` or `/root/research/tests`.
|
|
827
|
-
Supply `taskName` to choose the final segment.
|
|
828
|
-
Segments accept lowercase ASCII letters, digits, and underscores; `root`, `.`, `..`, slashes, empty values, and names longer than 128 characters are rejected.
|
|
829
|
-
An omitted name receives a deterministic privacy-safe `agent_<hash>` fallback, including for restored legacy records.
|
|
830
|
-
A path must be unique while its record is retained and not closed, and the same path may be reused after close.
|
|
146
|
+
Unavailable or extension-only tool names are rejected before a job is queued.
|
|
831
147
|
|
|
832
|
-
|
|
833
|
-
A peer target without a leading slash resolves below the authenticated sender's path, while `/root` and paths beginning with `/root/` are absolute.
|
|
834
|
-
Use an opaque ID when addressing historical closed records because a closed path is no longer reserved.
|
|
148
|
+
Omitting `tools` selects `read`, `grep`, `find`, and `ls`.
|
|
835
149
|
|
|
836
|
-
|
|
150
|
+
Passing an empty list gives the child no work tools.
|
|
837
151
|
|
|
838
|
-
|
|
839
|
-
- `subagent_peer_list` returns only bounded ID, path, agent-name, and lifecycle metadata for the current session.
|
|
152
|
+
The runtime always adds `subagent_send` and child `subagent_wait` and removes duplicate names.
|
|
840
153
|
|
|
841
|
-
|
|
842
|
-
A running retained target may receive the persisted envelope through its active transport; an idle target remains asleep and consumes the message on its next turn.
|
|
843
|
-
Message IDs and optional deduplication keys make retry at-least-once, so recipients must tolerate seeing the same exact ID again after an acknowledgement persistence failure.
|
|
844
|
-
Process children use an authenticated loopback JSONL bridge.
|
|
845
|
-
Its random credential is bound to one retained process generation, captured and removed from the child environment before model tools run, never persisted or rendered, and revoked on release, replacement, or shutdown.
|
|
846
|
-
The broker bounds frames, connections, handshakes, message text, and response text.
|
|
847
|
-
If a transport cannot accept a live push, the durable mailbox remains the fallback rather than starting another turn.
|
|
154
|
+
Adding `edit` or `write` lets the child modify files.
|
|
848
155
|
|
|
849
|
-
|
|
850
|
-
Older records require no manual migration because missing paths and recipients are reconstructed deterministically under the unchanged state version.
|
|
156
|
+
Adding `bash` or `powershell` grants unrestricted command execution and can also modify the workspace.
|
|
851
157
|
|
|
852
|
-
|
|
158
|
+
The optional `thinkingLevel` accepts `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max`.
|
|
853
159
|
|
|
854
|
-
|
|
855
|
-
Update explicit prompts and integrations as follows:
|
|
160
|
+
Omitting `thinkingLevel` captures the main agent's effective level when `subagent_spawn` executes.
|
|
856
161
|
|
|
857
|
-
|
|
858
|
-
| --- | --- |
|
|
859
|
-
| `subagent_list({ includeClosed })` | `subagent_inspect({ action: "list_runs", includeClosed })` |
|
|
860
|
-
| `subagent_manage({ action: "list", includeClosed })` | `subagent_inspect({ action: "list_runs", includeClosed })` |
|
|
861
|
-
| `subagent_interrupt({ agentId, subtree })` | `subagent_manage({ action: "interrupt", agentId, subtree })` |
|
|
862
|
-
| `subagent_close({ agentId, subtree })` | `subagent_manage({ action: "close", agentId, subtree })` |
|
|
863
|
-
| `subagent_message({ agentId, message, ... })` | `subagent_mailbox({ action: "send", agentId, message, ... })` |
|
|
864
|
-
| `subagent_messages({ agentId, acknowledge, limit })` | `subagent_mailbox({ action: "read", agentId, acknowledge, limit })` |
|
|
865
|
-
|
|
866
|
-
Persisted agent and mailbox records require no manual migration; older records load with an empty completion outbox and generation zero.
|
|
867
|
-
If an explicit prompt in a resumed conversation keeps requesting an old name, update it with the mapping above or start a fresh conversation.
|
|
868
|
-
To roll back after an upgrade, pin the package version used before the upgrade; for this migration, use `pi install npm:@narumitw/pi-subagents@0.26.0`.
|
|
869
|
-
The previous release can read the same state directory.
|
|
870
|
-
|
|
871
|
-
A spawn can request a thinking level explicitly:
|
|
872
|
-
|
|
873
|
-
```json
|
|
874
|
-
{
|
|
875
|
-
"agent": "explorer",
|
|
876
|
-
"taskName": "concurrency_analysis",
|
|
877
|
-
"task": "Analyze the cross-package concurrency failure and identify the safest fix",
|
|
878
|
-
"thinkingLevel": "high"
|
|
879
|
-
}
|
|
880
|
-
```
|
|
162
|
+
The child inherits the main agent's effective provider and model when `subagent_spawn` executes.
|
|
881
163
|
|
|
882
|
-
|
|
883
|
-
The same fields on `subagent_send` override only that follow-up turn.
|
|
884
|
-
`subagent_send` does not provide a per-turn thinking override; create a new agent when a later task needs a different level.
|
|
164
|
+
Spawn rejects providers registered by a parent extension because child processes disable unrelated extensions.
|
|
885
165
|
|
|
886
|
-
|
|
166
|
+
Spawn also rejects process-local runtime API keys, including a parent-only `--api-key` value.
|
|
887
167
|
|
|
888
|
-
|
|
889
|
-
{
|
|
890
|
-
"agent": "worker",
|
|
891
|
-
"taskName": "approved_change",
|
|
892
|
-
"task": "Implement the approved change",
|
|
893
|
-
"idempotencyKey": "approved-change-1"
|
|
894
|
-
}
|
|
895
|
-
```
|
|
168
|
+
Use stored or environment credentials that child processes can read.
|
|
896
169
|
|
|
897
|
-
The
|
|
898
|
-
Reusing the key with different behavior-affecting parameters fails.
|
|
899
|
-
Closing the retained record releases the key.
|
|
900
|
-
|
|
901
|
-
Set `resultFormat: "structured-v1"` to ask for legacy `summary`, `evidence`, `changes`, `verification`, and `risks` fields.
|
|
902
|
-
Prefer `resultFormat: "structured-v2"` when orchestration must distinguish `completed`, `partial`, `blocked`, `needs-input`, `failed`, `interrupted`, `abstained`, `stale`, or `contract-invalid` outcomes and consume typed artifact evidence.
|
|
903
|
-
The child prompt includes a complete minimum JSON object and item shapes; every displayed top-level field remains required even when its array is empty.
|
|
904
|
-
Valid structured data and deterministic recovery classification appear in completion and inspection details, while malformed structured output becomes `contract-invalid` instead of being treated as success.
|
|
905
|
-
The executor stamps task generation, cancellation lineage, and accepted `ExecutionPlan` identity after parsing, so model output cannot forge the provenance used for stale-result containment.
|
|
906
|
-
|
|
907
|
-
`subagent_spawn.context` accepts:
|
|
908
|
-
|
|
909
|
-
- `"none"` (default) — no parent conversation.
|
|
910
|
-
- `"all"` — bounded user/assistant text from the active branch.
|
|
911
|
-
- `"summary"` — a bounded earlier-context checkpoint plus recent messages verbatim.
|
|
912
|
-
- A positive number — the most recent N user turns and related assistant text.
|
|
913
|
-
|
|
914
|
-
Use `contextEntryIds` to select exact session entries.
|
|
915
|
-
Supplying IDs without `context` implies `context: "all"`; an explicit `context: "none"` still disables parent context.
|
|
916
|
-
Stable source IDs are retained so repeated follow-ups do not need to duplicate parent context.
|
|
917
|
-
Use `subagent_inspect` with `action: "preview_context"` to inspect selected turns, source count, UTF-8 bytes, and truncation before spawning without returning the context text.
|
|
918
|
-
The byte count is not a provider token estimate.
|
|
919
|
-
|
|
920
|
-
Reasoning, tool results, custom transport messages, and non-text parts are excluded.
|
|
921
|
-
Text inside `<private>...</private>` and lines containing `[subagent-private]` are omitted before context, mailbox content, or history is persisted.
|
|
922
|
-
|
|
923
|
-
Stateful execution uses a transport boundary:
|
|
924
|
-
|
|
925
|
-
- `subprocess` is the default compatibility and rollback path and starts a fresh child for every turn.
|
|
926
|
-
- `in-process` uses only public Pi SDK APIs: `createAgentSessionServices()`, `createAgentSessionFromServices()`, `SessionManager.inMemory()`, and normal session lifecycle methods.
|
|
927
|
-
It isolates conversation/tool selection, not memory or crashes; child failures share the parent Node.js process.
|
|
928
|
-
- `rpc` uses strict bounded JSONL over one lazy child process per active retained agent.
|
|
929
|
-
A `get_state` response proves readiness, prompt response means accepted only, and `agent_settled` is the completion boundary after retry or compaction.
|
|
930
|
-
- `auto` selects one transport before launch and retains the choice for that agent's runtime lifetime.
|
|
931
|
-
It never retries through another transport after startup or accepted work.
|
|
932
|
-
- In-process and RPC child resource loading disables user and project extensions to prevent recursive `pi-subagents` loading and duplicate extension side effects while retaining trust-eligible context/skill resources and the selected agent prompt.
|
|
933
|
-
All transports add only the package-owned peer bridge and its two communication tools; the bridge does not add filesystem, shell, model, network-destination, or user-extension authority.
|
|
934
|
-
The compatibility subprocess path retains its recursion-depth guard and configured execution tools.
|
|
935
|
-
Transports receive the same resolved target-trust boolean through their public SDK or explicit CLI trust controls.
|
|
936
|
-
- Agent model strings use Pi core's CLI resolver, including provider/model patterns, fuzzy matching, custom provider model IDs, and `:<thinking>` suffixes.
|
|
937
|
-
Thinking level and built-in tool allow-list overrides are applied when the child is created.
|
|
938
|
-
Parent model/thinking changes are snapshotted for subsequently created children; an existing child keeps its own session configuration.
|
|
939
|
-
- Extension/custom tool names are rejected by in-process and RPC v1 before child creation; automatic mode selects `subprocess` for them, and permissions are never silently widened.
|
|
940
|
-
- Timeout, parent abort, close, expiry, and session shutdown abort or dispose owned child sessions or process groups.
|
|
941
|
-
A child that does not settle after abort grace is discarded rather than reused.
|
|
942
|
-
- RPC progress uses `pi-subagents:v1` metadata and reports only bounded phase, queue, timing, effective model/thinking, and validated usage fields.
|
|
943
|
-
Successive Pi 0.84.2 `message_update.usage` values replace one cumulative in-flight snapshot, while a valid final `message_end.message.usage` remains authoritative.
|
|
944
|
-
Missing or invalid final usage falls back to the latest valid streaming snapshot, and an interrupted attempt is committed before retry or timeout-summary usage is added.
|
|
945
|
-
Usage progress and terminal outcomes therefore retain partial token and total-cost evidence without double counting cumulative updates.
|
|
946
|
-
The `turns` field still counts finalized assistant messages only, not interrupted attempts or tool-result messages.
|
|
947
|
-
Telemetry never exposes raw prompts, assistant content, reasoning, credentials, headers, environment values, or full RPC events.
|
|
948
|
-
- A successful RPC prompt response is never treated as completion, and accepted or ambiguously accepted work is never replayed automatically.
|
|
949
|
-
- In-process startup failures do not silently retry through subprocesses, preventing duplicate side effects.
|
|
950
|
-
If the loaded Pi core lacks public `createAgentSessionServices()`, `createAgentSessionFromServices()`, or `resolveCliModel()` support, startup fails with an actionable instruction to select `stateful.transport: "subprocess"`.
|
|
951
|
-
|
|
952
|
-
No private Pi imports, runtime casts, or `ExtensionAPI` monkey-patching are used.
|
|
953
|
-
The package uses public Pi root RPC types but owns exact CLI resolution, bounded framing, readiness, stderr, cancellation, and process-group cleanup because the stock client does not provide those package-specific guarantees.
|
|
954
|
-
Approval policy, sandbox profile, provider-header hooks, extension state, global scheduling, and parent/child transcript switching are not inherited or provided by in-process or RPC transport.
|
|
955
|
-
|
|
956
|
-
Write-capable detached agents share the workspace and may run concurrently by default.
|
|
957
|
-
Classification remains intentionally conservative for automatic transport selection: an agent with `bash`, `write`, or `edit` is write-capable even when its task prompt says “read only,” because prompt wording is not a filesystem sandbox.
|
|
958
|
-
Assign disjoint file or responsibility ownership to concurrent writers and keep integration in the main agent.
|
|
959
|
-
Use isolated worktrees when repository-write isolation is required.
|
|
960
|
-
The deprecated `allowConcurrentWrites` field remains accepted for compatibility but no longer changes admission behavior.
|
|
961
|
-
Use the blocking batch only when synchronous outputs justify making the main agent unavailable.
|
|
962
|
-
|
|
963
|
-
Set `workspaceMode: "worktree"` to opt into a disposable detached Git worktree; this requires a clean repository and the worktree is removed on close or session shutdown.
|
|
964
|
-
The generated path inherits the approved base cwd's trust snapshot.
|
|
965
|
-
Retained records mark disposable worktrees explicitly, so they are never restored even if cleanup could not remove the generated directory.
|
|
966
|
-
Shared-workspace retained records store an additive bounded target-trust snapshot for transport and inspection parity; session restore canonicalizes the retained cwd and re-resolves current/saved trust rather than blindly trusting the persisted value.
|
|
967
|
-
Older records without either field remain readable.
|
|
968
|
-
|
|
969
|
-
## 📜 Compatibility and failure contract
|
|
970
|
-
|
|
971
|
-
Existing accepted `subagent` payload shapes remain unchanged.
|
|
972
|
-
`subagent_spawn` adds optional `taskName`, `idempotencyKey`, and `resultFormat` fields without changing omitted behavior.
|
|
973
|
-
`allowConcurrentWrites` remains accepted by `subagent_spawn` and `subagent_send` as a deprecated no-op so stored or resumed calls remain valid.
|
|
974
|
-
Spawn request identity continues to include its submitted value for exact-retry compatibility.
|
|
975
|
-
Older releases do not recognize `stateful.transport: "rpc"` or `"auto"`; change the value to `"subprocess"` and reload before downgrading.
|
|
976
|
-
Retained records remain transport-neutral, and older readers ignore the additive task identity, completion-recipient, idempotency, and context-footprint fields while the state version remains compatible.
|
|
977
|
-
The `tasks` schema now advertises the absolute 64-item safety bound, while the effective `blocking.maxParallelTasks` value may be lower.
|
|
978
|
-
The intentional compatibility change is that an external target without saved trust is rejected by the new default `cwdPolicy.delegation: "trusted-targets"`; set the user-owned policy to `"anywhere"` to restore the preceding target flexibility.
|
|
979
|
-
|
|
980
|
-
| Mode | Ordering | Failure behavior |
|
|
981
|
-
| --- | --- | --- |
|
|
982
|
-
| Single | One result. | A failed/aborted/timed-out worker is marked as a tool error while preserving bounded details. |
|
|
983
|
-
| Chain | Input order. | Stops at the first failed step; completed steps remain in details. |
|
|
984
|
-
| Parallel | Input order, up to `blocking.maxParallelTasks` total workers and at most four active children. | Rejects calls above the configured limit; otherwise collects all task results, and partial worker failure does not discard successful results. |
|
|
985
|
-
| Parallel + aggregator | Source input order, then aggregator. | The aggregator runs with successful outputs and failure descriptions only when total budget remains; aggregator failure or orchestration expiry marks the tool result as an error. |
|
|
986
|
-
| Workflow | Deterministic dependency-ready and critical-path order, with results returned in declared task order. | Invalid graphs fail before launch; blocked or failed dependencies prevent downstream start; bounded retry and hedging require explicit side-effect contracts. |
|
|
987
|
-
| Panel | Reviewer declaration order, then at most one synthesizer. | Invalid or failed reviews remain visible; synthesis requires `minValidReviews`; insufficient panels preserve partial evidence without a consensus claim; synthesis contract failure marks the tool result as an error. |
|
|
170
|
+
The extension does not expose a per-job model override.
|
|
988
171
|
|
|
989
|
-
|
|
172
|
+
## 🔄 Messaging, lifecycle, and retention
|
|
990
173
|
|
|
991
|
-
|
|
992
|
-
Blocking idle, turn, and tool-call precedence is task/step/aggregator → call → omitted.
|
|
993
|
-
Stateful budget precedence is the explicit `subagent_send` field for one follow-up → retained `subagent_spawn` field → timeout-only agent/environment fallback where applicable.
|
|
994
|
-
Blocking thinking precedence remains: task/step/aggregator → call → agent setting → child default.
|
|
995
|
-
Stateful spawn thinking precedence is: `subagent_spawn.thinkingLevel` → agent setting → transport fallback.
|
|
996
|
-
Project-agent resolution and confirmation behavior is unchanged after target preflight.
|
|
997
|
-
Blocking and retained result/inspection details add bounded target, budget, termination, and effective trust metadata.
|
|
174
|
+
The session starts one TCP broker on `127.0.0.1` with an operating-system-assigned ephemeral port.
|
|
998
175
|
|
|
999
|
-
|
|
176
|
+
Each job receives one cryptographically random token bound to its job identity and session generation.
|
|
1000
177
|
|
|
1001
|
-
|
|
178
|
+
The parent passes the broker credentials once through a private inherited pipe instead of placing them in the child's initial environment or command line.
|
|
1002
179
|
|
|
1003
|
-
|
|
1004
|
-
| --- | --- | --- |
|
|
1005
|
-
| `explorer` | Read-only codebase exploration for specific questions. | `read`, `grep`, `find`, `ls` |
|
|
1006
|
-
| `worker` | Bounded implementation and command execution with clear ownership. | Pi default tools |
|
|
1007
|
-
|
|
1008
|
-
Ordinary review stays in the main agent with a review skill and deterministic checks.
|
|
1009
|
-
Use a custom user or project verifier only when consequential independent verification justifies the added cost and coordination.
|
|
1010
|
-
|
|
1011
|
-
Built-in agents inherit the active/default Pi model instead of forcing a provider-specific model alias, which keeps every transport usable across different Pi setups.
|
|
1012
|
-
The built-in `explorer` defaults to `low` thinking for bounded exploration and intentionally omits `bash` so it remains read-only and preserves the automatic in-process route.
|
|
1013
|
-
Users who need shell-assisted read-mostly work can define a custom agent, but `bash` makes transport classification conservatively write-capable because prompt wording is not an enforcement boundary.
|
|
1014
|
-
`worker` inherits thinking unless a caller, frontmatter, or per-agent setting selects one.
|
|
1015
|
-
|
|
1016
|
-
## ⚙️ Configure agent tools
|
|
1017
|
-
|
|
1018
|
-
Open `/subagents settings`, choose **Agent defaults**, then **Tool permissions** in an interactive Pi session to edit the tools each subagent may use.
|
|
1019
|
-
Choose **Model, thinking, and time limit** to edit provider-neutral model patterns, thinking levels, and time limits without changing tools.
|
|
1020
|
-
The standard bounded multi-select keeps a one-save draft: toggles do not write until **Save changes**, Escape leaves the draft without writing, and unavailable configured tool names remain visible and preserved.
|
|
1021
|
-
In TUI mode, type to fuzzy-search tool names and availability metadata; Save and Discard remain pinned below the matches.
|
|
1022
|
-
These are user settings stored in `~/.pi/agent/pi-subagents.json` and affect future sessions.
|
|
1023
|
-
|
|
1024
|
-
Compatibility: a valid legacy `pi-subagents-config.json` remains readable with a warning and is never modified automatically; rename it to `pi-subagents.json`.
|
|
1025
|
-
The first subsequent settings save writes the canonical file.
|
|
1026
|
-
If both files exist, the new filename takes precedence.
|
|
1027
|
-
A saved `agents.scout` override from earlier releases applies to the renamed built-in `explorer` only when no explicit `agents.explorer` override exists and no custom `scout` agent is available.
|
|
1028
|
-
|
|
1029
|
-
- Select an agent, then press Enter or Space to toggle tools.
|
|
1030
|
-
- Choose **Save changes** to write the draft, choose **Discard draft** to abandon it, or press Esc to return to agent selection without writing.
|
|
1031
|
-
- Save the default selection to remove a custom override and use the agent defaults again.
|
|
1032
|
-
- Deselect every tool and save to run that agent with no tools.
|
|
1033
|
-
An explicit empty list remains distinct from an absent list; blank `tools:` or `tools: []` in agent frontmatter also means no tools.
|
|
1034
|
-
|
|
1035
|
-
Configured tool names that are not currently registered are preserved, so settings for tools from other extension sessions are not silently dropped.
|
|
1036
|
-
|
|
1037
|
-
## 🧩 Custom agents
|
|
1038
|
-
|
|
1039
|
-
Create markdown agent definitions in either location:
|
|
1040
|
-
|
|
1041
|
-
- `~/.pi/agent/agents/*.md` for user agents.
|
|
1042
|
-
- `.pi/agents/*.md` for project-local agents.
|
|
1043
|
-
|
|
1044
|
-
Example:
|
|
1045
|
-
|
|
1046
|
-
```markdown
|
|
1047
|
-
---
|
|
1048
|
-
name: api-reviewer
|
|
1049
|
-
description: Review API changes for compatibility and tests
|
|
1050
|
-
tools: read, grep, find, ls
|
|
1051
|
-
model: sonnet
|
|
1052
|
-
thinkingLevel: high
|
|
1053
|
-
capabilityManifest:
|
|
1054
|
-
version: pi-subagents:capabilities:v1
|
|
1055
|
-
capabilities: [code-review, evidence-review]
|
|
1056
|
-
modalities: [text]
|
|
1057
|
-
resultFormats: [text, structured-v2]
|
|
1058
|
-
authority:
|
|
1059
|
-
filesystem: read
|
|
1060
|
-
verificationRoles: [independent-review]
|
|
1061
|
-
contextStrengths: [repository]
|
|
1062
|
-
costHint: medium
|
|
1063
|
-
latencyHint: medium
|
|
1064
|
-
---
|
|
1065
|
-
|
|
1066
|
-
You are an API review subagent. Do not edit files. Check compatibility,
|
|
1067
|
-
test coverage, and migration risks. Report PASS/FAIL/PARTIAL with evidence.
|
|
1068
|
-
```
|
|
180
|
+
The child bridge reads and closes that descriptor before model tool execution.
|
|
1069
181
|
|
|
1070
|
-
|
|
1071
|
-
An omitted field keeps the agent's default tools; blank, `null`, or `[]` explicitly selects no tools.
|
|
182
|
+
Each child runs in Pi RPC mode so the parent can inject a main-originated request through `steer` after the initial prompt is accepted.
|
|
1072
183
|
|
|
1073
|
-
|
|
1074
|
-
Explicit workflow routing can match declared capabilities, configured tools, filesystem authority, verification roles, and low/medium/high cost or latency hints.
|
|
1075
|
-
A missing or malformed manifest remains unknown and cannot satisfy a capability-routed task.
|
|
1076
|
-
The parent-facing session-guidance message exposes contract-relevant catalog declarations before the first delegation decision.
|
|
1077
|
-
Use those identifiers exactly; enforced `readPaths`, `writePaths`, network, and secret guarantees are currently unsupported and require an external enforcement boundary.
|
|
1078
|
-
A rejected enforced contract reports both contract repair and stop as recovery choices, but repair is safe only when the unsupported fields were descriptive rather than required protection.
|
|
184
|
+
Each child broker call uses one request-scoped connection, while a response wait uses an abortable long poll.
|
|
1079
185
|
|
|
1080
|
-
|
|
1081
|
-
It is not a setting in `~/.pi/agent/pi-subagents.json` and does not belong in agent frontmatter.
|
|
1082
|
-
The parent-facing session-guidance contract discovers these definitions after session start and labels their source and required scope.
|
|
1083
|
-
Edit agent files and run `/reload` (or start a new session) to refresh the catalog; there is no live filesystem watcher.
|
|
1084
|
-
The scope selects which custom agent directories are loaded; built-in agents remain available in every scope:
|
|
186
|
+
A main-originated request to a queued job waits for RPC readiness before delivery is accepted.
|
|
1085
187
|
|
|
1086
|
-
|
|
1087
|
-
| --- | --- |
|
|
1088
|
-
| `"user"` (default) | User agents only. |
|
|
1089
|
-
| `"project"` | Project-local agents only. |
|
|
1090
|
-
| `"both"` | User and project-local agents. Project definitions override same-named user definitions. |
|
|
1091
|
-
|
|
1092
|
-
For an existing compatibility caller, invoke a project-local agent with the deprecated blocking `subagent` tool:
|
|
1093
|
-
|
|
1094
|
-
```json
|
|
1095
|
-
{
|
|
1096
|
-
"agent": "api-reviewer",
|
|
1097
|
-
"task": "Review this project's API changes",
|
|
1098
|
-
"agentScope": "project"
|
|
1099
|
-
}
|
|
1100
|
-
```
|
|
188
|
+
After RPC accepts the steering message, the runtime interrupts active child response waits so the queued request can reach the child model.
|
|
1101
189
|
|
|
1102
|
-
|
|
190
|
+
Caller cancellation before RPC delivery starts rolls the request back.
|
|
1103
191
|
|
|
1104
|
-
|
|
1105
|
-
{
|
|
1106
|
-
"agent": "api-reviewer",
|
|
1107
|
-
"task": "Review this project's API changes",
|
|
1108
|
-
"agentScope": "project"
|
|
1109
|
-
}
|
|
1110
|
-
```
|
|
192
|
+
Once RPC delivery starts, cancellation stops only the caller's wait; the request may still arrive and remains answerable until delivery fails or the job terminates.
|
|
1111
193
|
|
|
1112
|
-
|
|
1113
|
-
Every new blocking `subagent` invocation or `subagent_spawn` call that needs project agents must supply `agentScope: "project"` or `"both"` again.
|
|
194
|
+
The interrupted child-originated requests remain active and retryable.
|
|
1114
195
|
|
|
1115
|
-
|
|
1116
|
-
Interactive sessions also ask for confirmation before using them by default.
|
|
1117
|
-
Passing `confirmProjectAgents: false` as another top-level tool argument skips that confirmation dialog, but it does not bypass the project trust requirement.
|
|
196
|
+
The first accepted `subagent_send` response wins.
|
|
1118
197
|
|
|
1119
|
-
|
|
198
|
+
Repeated responses acknowledge the existing answer without replacing it.
|
|
1120
199
|
|
|
1121
|
-
|
|
200
|
+
A child may retry `subagent_wait` after a wait timeout because the underlying request remains active.
|
|
1122
201
|
|
|
1123
|
-
|
|
1124
|
-
- The worker-count limit defaults to 8 and does not change the fixed four-at-a-time execution concurrency.
|
|
1125
|
-
- Set `timeoutMs` on the top-level blocking call to apply a work deadline to all jobs.
|
|
1126
|
-
- Set `timeoutMs` on a task, chain step, or aggregator to override it locally.
|
|
1127
|
-
- Set top-level blocking `totalTimeoutMs` to cap model work across the whole call; each child receives at most the remaining budget, queued work is not started after expiry, fan-in receives only remaining time, and an orchestration-expired child skips model finalization.
|
|
1128
|
-
Bounded process-cleanup grace may follow the deadline.
|
|
1129
|
-
- Set `idleTimeoutMs` to stop a turn that has produced no completed assistant turn or tool result within that interval.
|
|
1130
|
-
- Set `maxTurns` or `maxToolCalls` to stop unfinished repeated work; a terminal answer at the exact turn limit remains successful.
|
|
1131
|
-
- Give evidence tasks enough turn and tool-call headroom for discovery, reads, and final synthesis, or omit those optional limits instead of guessing tight values.
|
|
1132
|
-
- Set spawn budgets as retained defaults, or the same fields on `subagent_send` to override one follow-up turn.
|
|
1133
|
-
- Top-level blocking turn budgets apply to every job, while a task, chain step, or aggregator can override them locally.
|
|
1134
|
-
- Choose the shortest realistic budgets for the task difficulty; split an oversized task instead of extending limits merely to compensate for broad scope.
|
|
1135
|
-
- Valid time values range from 1 to 2,147,483,647 milliseconds, matching the runtime timer limit.
|
|
1136
|
-
- `maxTurns` and `maxToolCalls` accept integers from 1 through 1,000,000.
|
|
1137
|
-
- If `timeoutMs` is omitted, the default is the retained or agent setting, then `PI_SUBAGENT_TIMEOUT_MS`, or `600000` milliseconds (10 minutes) when unset; the other new budgets remain opt-in.
|
|
202
|
+
A new job starts as `queued`, transitions to `running`, and reaches exactly one terminal state.
|
|
1138
203
|
|
|
1139
|
-
|
|
1140
|
-
Blocking subprocess calls pass the resolved value through `--thinking <level>`.
|
|
204
|
+
The runtime retains up to 32 recent terminal records for up to 24 hours within the current extension session.
|
|
1141
205
|
|
|
1142
|
-
|
|
206
|
+
Inspection reports older records removed by retention bounds through `omitted.jobs`.
|
|
1143
207
|
|
|
1144
|
-
|
|
1145
|
-
| --- | --- |
|
|
1146
|
-
| `off` / `minimal` | Extraction, formatting, or mechanical work requiring almost no reasoning. |
|
|
1147
|
-
| `low` | Straightforward, bounded tasks with direct steps. |
|
|
1148
|
-
| `medium` | Ordinary multi-step research or implementation. |
|
|
1149
|
-
| `high` | Complex debugging, design, review, or cross-file analysis. |
|
|
1150
|
-
| `xhigh` | Highly ambiguous, cross-system, or high-risk analysis. |
|
|
1151
|
-
| `max` | Exceptional hardest tasks where quality clearly outweighs latency and cost. |
|
|
1152
|
-
|
|
1153
|
-
Blocking thinking precedence is: task/chain step/aggregator `thinkingLevel` → top-level `thinkingLevel` → agent default from config or frontmatter → Pi subprocess default.
|
|
1154
|
-
|
|
1155
|
-
Stateful spawn precedence is: `subagent_spawn.thinkingLevel` → agent default from settings or frontmatter → model suffix → transport fallback.
|
|
1156
|
-
Subprocess uses spawned Pi model/default resolution.
|
|
1157
|
-
In-process delegates configured model parsing to loaded Pi core and then uses the parent thinking snapshot captured at child creation.
|
|
1158
|
-
RPC passes the selected CLI model and thinking controls before its readiness handshake and reports the effective state returned by Pi.
|
|
1159
|
-
An explicit spawn value is retained for the agent lifecycle and wins over every fallback.
|
|
1160
|
-
|
|
1161
|
-
Omit `thinkingLevel` to preserve existing behavior.
|
|
1162
|
-
Reported stateful details show the requested level, not a guarantee of the provider's effective value.
|
|
1163
|
-
Pi still owns model capability clamping; `pi-subagents` does not duplicate capability detection.
|
|
1164
|
-
|
|
1165
|
-
When any execution budget expires, the extension aborts the active run first and creates a versioned, bounded, redacted checkpoint containing partial assistant notes, completed tool evidence, changed-file hints, and whether side effects may already have occurred.
|
|
1166
|
-
After authoritative settlement it may make one concise summary attempt over that checkpoint without replaying the stopped task.
|
|
1167
|
-
The summary attempt has its own extension-owned model-work deadline of at most 45 seconds, followed only by bounded abort and process-cleanup grace.
|
|
1168
|
-
Fresh subprocess summaries run with no tools or project resources.
|
|
1169
|
-
Retained RPC and in-process summaries reuse their child context and are explicitly instructed not to call tools; the current child APIs do not support replacing an existing session's tool set for one turn, so their separate deadline and abort path remain the enforcement boundary.
|
|
1170
|
-
Before a retained RPC summary starts, validated in-flight usage from the interrupted work attempt is committed so the summary adds to it exactly once.
|
|
1171
|
-
The deterministic checkpoint remains available when finalization or the provider fails, and results retain exit `124` plus a structured termination reason and finalization status.
|
|
1172
|
-
When bounded finalization succeeds with non-empty usable output, detached registry state reports a typed `partial` outcome with the exact budget reason instead of collapsing that evidence into an undifferentiated failure.
|
|
1173
|
-
Malformed required structured output, empty or failed finalization, and transport failure remain non-success.
|
|
1174
|
-
Partial evidence never satisfies mutating acceptance, required evidence, or independent verification.
|
|
1175
|
-
Inspection and opt-in content-free telemetry distinguish runtime-owned omitted limits from explicit per-turn limits.
|
|
1176
|
-
Explicit parent or user abort stops immediately, never starts finalization, and is not mislabeled as a budget stop.
|
|
1177
|
-
|
|
1178
|
-
This release does not claim a cooperative soft-wrap-up phase because print-mode subprocess children cannot receive steering while they are running.
|
|
1179
|
-
It also does not retry budget-stopped work automatically because file or external side effects may already have occurred.
|
|
1180
|
-
|
|
1181
|
-
The child event protocol limits each JSON line to 256 KiB.
|
|
1182
|
-
Captured output uses these defaults:
|
|
1183
|
-
|
|
1184
|
-
- final output and fan-in/chain context: 50 KiB;
|
|
1185
|
-
- stderr: 16 KiB;
|
|
1186
|
-
- captured messages: 200.
|
|
1187
|
-
|
|
1188
|
-
Truncated text includes a `truncated by pi-subagents` marker and details expose `truncated: true`.
|
|
1189
|
-
Inspection and consultation model-facing content also stops at 2,000 lines, whichever limit is reached first.
|
|
1190
|
-
`PI_SUBAGENT_MAX_DEPTH` controls nested delegation depth and defaults to 1; child processes receive `PI_SUBAGENT_DEPTH` automatically.
|
|
1191
|
-
|
|
1192
|
-
## 📡 Runtime status
|
|
1193
|
-
|
|
1194
|
-
Run the offline transport benchmark from the repository root when comparing startup overhead:
|
|
208
|
+
Cancelling or terminalizing a job revokes its token and rejects pending child waits before stale output can replace the terminal state.
|
|
1195
209
|
|
|
1196
|
-
|
|
1197
|
-
just benchmark-subagents
|
|
1198
|
-
```
|
|
210
|
+
Session replacement and shutdown cancel active work, suppress stale completion delivery, revoke credentials, close sockets, and stop the broker.
|
|
1199
211
|
|
|
1200
|
-
|
|
1201
|
-
Queue time starts when the registry accepts work, transport startup starts when execution begins, RPC readiness comes from `get_state`, RPC acceptance comes from the correlated `prompt` response, first activity comes from a bounded lifecycle event, settlement comes from `agent_settled`, and delivery is recorded after the parent accepts the completion message.
|
|
1202
|
-
Subprocess and in-process timing fields use the nearest public lifecycle boundary and may be coarser than RPC.
|
|
1203
|
-
Timing and progress are current-session diagnostics and are not persisted.
|
|
1204
|
-
The benchmark measures transport overhead rather than model latency or output quality.
|
|
212
|
+
## 🔀 Migrating from 2.x
|
|
1205
213
|
|
|
1206
|
-
|
|
214
|
+
Version 3.0 replaces the previous orchestration runtime.
|
|
1207
215
|
|
|
1208
|
-
|
|
1209
|
-
just benchmark-async-subagents --model provider/model
|
|
1210
|
-
```
|
|
216
|
+
It does not migrate legacy settings, persisted jobs, retained conversations, or recovery state.
|
|
1211
217
|
|
|
1212
|
-
|
|
218
|
+
Finish or record any required work before upgrading, then start a fresh Pi session so stored calls do not request removed tool names.
|
|
1213
219
|
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
220
|
+
Use these replacements where the new job model supports the previous intent:
|
|
221
|
+
|
|
222
|
+
| Previous interface | Version 3 interface |
|
|
223
|
+
| --- | --- |
|
|
224
|
+
| `subagent` or `subagent_spawn` | `subagent_spawn` |
|
|
225
|
+
| `subagent_await` | `subagent_wait` |
|
|
226
|
+
| `subagent_inspect` | `subagent_inspect` |
|
|
227
|
+
| `subagent_manage` cancellation | `subagent_cancel` |
|
|
228
|
+
| Child-to-main questions | Child `subagent_send` and `subagent_wait`, plus main `subagent_send` |
|
|
229
|
+
| Running main-to-child questions | Main and child `subagent_send` |
|
|
230
|
+
|
|
231
|
+
The version 3 `subagent_send` contracts are not compatible with the legacy retained-agent follow-up tool of the same name.
|
|
1217
232
|
|
|
1218
|
-
|
|
1219
|
-
The runner alternates arm order, starts work deadlines only after RPC readiness, runs at most three pairs concurrently, and reports completion coverage, evidence score, premature finals, terminal outcomes, median and P95 latency, and cost when available.
|
|
1220
|
-
Quick mode targets completion within five minutes under normal provider capacity but reports external timeouts and entitlement failures rather than silently reducing the sample.
|
|
1221
|
-
Live results remain provider- and model-dependent evidence rather than deterministic CI or proof of causality.
|
|
1222
|
-
The synchronous `subagent` tool remains available whenever a quality gate fails or detached chain, fan-in, panel, or workflow compatibility is unmatched.
|
|
233
|
+
The `/subagents` command, extension settings, legacy retained follow-ups, `subagent_mailbox`, `subagent_consult`, custom agent catalogs, advanced orchestration, alternate transports, trust-aware cwd policy, and extension-owned worktrees have no direct replacement.
|
|
1223
234
|
|
|
1224
|
-
|
|
1225
|
-
Any statusline extension that reads Pi's generic extension status API can display it; no package-to-package dependency is required.
|
|
235
|
+
Describe the child's specialization in `task` and grant only the required work tools through `tools`.
|
|
1226
236
|
|
|
1227
237
|
## 🔒 Security and privacy
|
|
1228
238
|
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
239
|
+
The selected work tools run in the current working directory.
|
|
240
|
+
|
|
241
|
+
The default list contains no shell or file-mutation tool.
|
|
242
|
+
|
|
243
|
+
It is not a filesystem sandbox because its read tools can inspect files available to the user account.
|
|
1234
244
|
|
|
1235
|
-
|
|
1236
|
-
Interrupt, close, shutdown, replacement, persistence, and restore revoke active grants before signalling work or accepting another generation, and late old-plan results become `stale` diagnostic evidence.
|
|
245
|
+
Selecting `bash`, `powershell`, `edit`, or `write` permits workspace mutation with the Pi process environment and user permissions.
|
|
1237
246
|
|
|
1238
|
-
|
|
247
|
+
Every child disables session persistence, unrelated extensions, skills, and prompt templates.
|
|
1239
248
|
|
|
1240
|
-
-
|
|
1241
|
-
- overridden when selected: cwd, model, thinking level, and tool list;
|
|
1242
|
-
- unsupported guarantees: parent approval policy, sandbox profile, and provider headers.
|
|
249
|
+
Provider selection therefore supports Pi's child-visible built-in and configured providers, not providers registered only by a parent extension.
|
|
1243
250
|
|
|
1244
|
-
|
|
1245
|
-
Stateful project agents require Pi's project trust; interactive use also keeps confirmation enabled by default.
|
|
251
|
+
Credentials must be available independently to the child through Pi's stored credentials or its inherited environment.
|
|
1246
252
|
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
A
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
253
|
+
The broker accepts only loopback TCP connections with an active per-job token.
|
|
254
|
+
|
|
255
|
+
The token is bootstrapped through a private inherited pipe and is absent from the child's initial environment and command line.
|
|
256
|
+
|
|
257
|
+
A child request or response is visible main-agent model context, but its envelope explicitly identifies it as untrusted subagent content rather than user authorization.
|
|
258
|
+
|
|
259
|
+
A child message cannot grant permission for writes, shell commands, credential access, or other privileged actions.
|
|
260
|
+
|
|
261
|
+
A main-agent request is visible child model context, but it cannot expand the child's selected tools or grant capabilities the child did not receive at spawn time.
|
|
262
|
+
|
|
263
|
+
Terminal controls and bidirectional controls are stripped before untrusted child text is displayed.
|
|
264
|
+
|
|
265
|
+
Tasks, repository context, requests, responses, and inspected file content may be sent to the selected model provider.
|
|
266
|
+
|
|
267
|
+
Parallel writers require disjoint ownership or workspace isolation outside this extension.
|
|
268
|
+
|
|
269
|
+
## 🚧 Limitations
|
|
270
|
+
|
|
271
|
+
The extension does not load arbitrary extension tools or parent-registered model providers in child processes.
|
|
272
|
+
|
|
273
|
+
Process-local runtime API keys are not forwarded to children.
|
|
274
|
+
|
|
275
|
+
The extension does not provide custom agents, per-job models, custom system prompts, peer-to-peer child messaging, retained conversations, user-directed follow-up work, mailboxes, Agent Teams, chains, fan-in aggregators, panels, workflow DAGs, dynamic scheduling, verification orchestration, nested subagents, or extension-owned semantic memory.
|
|
276
|
+
|
|
277
|
+
Bidirectional messages use request-response coordination, not a retained conversational session.
|
|
278
|
+
|
|
279
|
+
The main agent must verify child claims against the actual diff and deterministic checks.
|
|
280
|
+
|
|
281
|
+
Child requests and responses trigger a main-agent turn, but asynchronous job completions do not wake an otherwise idle model turn automatically.
|
|
282
|
+
|
|
283
|
+
Jobs, broker requests, and retained results do not survive extension reload, session replacement, or process exit.
|
|
1257
284
|
|
|
1258
285
|
## 🗂️ Package layout
|
|
1259
286
|
|
|
1260
|
-
```
|
|
287
|
+
```text
|
|
1261
288
|
packages/pi-subagents/
|
|
1262
|
-
├── dist/
|
|
1263
|
-
├── docs/
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
├──
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
│ ├── index.ts # Thin authoritative source entrypoint
|
|
1271
|
-
│ ├── subagents-extension.ts # Lightweight extension composition and blocking registration
|
|
1272
|
-
│ ├── subagents.ts # Backward-compatible public utility exports
|
|
1273
|
-
│ ├── cached-module-loader.ts # Retryable first-use code-module cache
|
|
1274
|
-
│ ├── inspect-registration.ts # Lightweight inspection tool registration
|
|
1275
|
-
│ ├── inspect.ts # First-use side-effect-free metadata inspection
|
|
1276
|
-
│ ├── consult-registration.ts # Lightweight consultation tool registration
|
|
1277
|
-
│ ├── consult.ts # First-use synchronous read-only consultation
|
|
1278
|
-
│ ├── consult-policy.ts # Enforced read-only tool intersection
|
|
1279
|
-
│ ├── cwd-policy.ts # Canonical target and saved-trust resolution
|
|
1280
|
-
│ ├── prompt-resources.ts # Core-selected SYSTEM and APPEND_SYSTEM resources
|
|
1281
|
-
│ ├── safe-text.ts # Shared byte/line/path sanitization
|
|
1282
|
-
│ ├── stateful-registration.ts # Detached lifecycle registration and dispatch
|
|
1283
|
-
│ ├── stateful.ts # Backward-compatible detached utility exports
|
|
1284
|
-
│ ├── settings-reader.ts # Side-effect-free startup settings reads and inspection
|
|
1285
|
-
│ ├── create-stateful-transport.ts # First-turn selected transport loader
|
|
1286
|
-
│ ├── rpc-transport.ts # Persistent strict-JSONL Pi RPC child transport
|
|
1287
|
-
│ ├── rpc-timeout-finalization.ts # RPC abort-settle-summary recovery
|
|
1288
|
-
│ ├── rpc-transport-metadata.ts # RPC result policy and bounded metadata helpers
|
|
1289
|
-
│ ├── rpc-turn-capture.ts # RPC evidence capture, usage, and budget events
|
|
1290
|
-
│ ├── auto-transport.ts # Deterministic preflight transport routing
|
|
1291
|
-
│ ├── transport-types.ts # Bounded pi-subagents:v1 progress and telemetry contract
|
|
1292
|
-
│ ├── usage-recording.ts # Opt-in content-free event collection and local identities
|
|
1293
|
-
│ ├── usage-recording-store.ts # Private per-runtime JSONL writers and retention pruning
|
|
1294
|
-
│ ├── completion-delivery.ts # Top-level completion batching and optional idle-root wake
|
|
1295
|
-
│ ├── session-guidance-contract.ts # Append-only catalog and effective-policy guidance
|
|
1296
|
-
│ ├── completion-requirement.ts # Exact required-run tracking and fixed-boundary fallback
|
|
1297
|
-
│ ├── completion-routing.ts # Direct-parent and live-ancestor recipient selection
|
|
1298
|
-
│ ├── task-path.ts # Canonical retained-agent task identity and resolution
|
|
1299
|
-
│ ├── peer-communication.ts # Session peer routing and authenticated loopback broker
|
|
1300
|
-
│ ├── peer-transport.ts # Child transport bridge wiring and ephemeral credentials
|
|
1301
|
-
│ ├── child-peer-tools.ts # Child-only peer tools and context acknowledgements
|
|
1302
|
-
│ ├── child-peer-bridge.ts # Explicit process-child extension entrypoint
|
|
1303
|
-
│ ├── admission-policy.ts # Audit-only deterministic delegation admission
|
|
1304
|
-
│ ├── capability-grant.ts # Generation-bound authority lifetime and revocation
|
|
1305
|
-
│ ├── execution-plan.ts # Executor-owned authority and resource resolution
|
|
1306
|
-
│ ├── work-item-ledger.ts # Persistent dependency and artifact state machine
|
|
1307
|
-
│ ├── work-item-persistence.ts # Atomic redacted workflow state and inspection
|
|
1308
|
-
│ ├── workflow-verification.ts # Compatibility independent-verifier receipts
|
|
1309
|
-
│ ├── verified-execution-contract.ts # Explicit managed-verification request boundary
|
|
1310
|
-
│ ├── workflow-completion-controller.ts # Sole opted-in terminal acceptance owner
|
|
1311
|
-
│ ├── verification-harness.ts # Disposable deterministic check execution
|
|
1312
|
-
│ ├── verification-receipt.ts # Strict executor-owned managed receipts
|
|
1313
|
-
│ ├── verified-execution-benchmark.ts # Matched offline acceptance/cost fixture
|
|
1314
|
-
│ ├── async-subagent-benchmark.ts # Paired live-quality planning, scoring, and summaries
|
|
1315
|
-
│ ├── workflow-tree-identity.ts # Bounded exact Git-visible tree identities
|
|
1316
|
-
│ ├── integration-controller.ts # Fail-closed canonical integration admission
|
|
1317
|
-
│ ├── adaptive-scheduler.ts # Dependency, capacity, budget, and conflict scheduling
|
|
1318
|
-
│ ├── semantic-snapshot.ts # Privacy-safe continuation compatibility checks
|
|
1319
|
-
│ ├── supervision.ts # Bounded idempotent retries and read-only hedging
|
|
1320
|
-
│ ├── panel-execution.ts # Blocking review barrier, synthesis, and lifecycle owner
|
|
1321
|
-
│ ├── panel-contract.ts # Strict review and synthesis evidence contracts
|
|
1322
|
-
│ ├── panel-evidence.ts # Bounded monotonic reviewer evidence ledger
|
|
1323
|
-
│ ├── panel-planning.ts # Panel validation, phase budgets, and WorkItems
|
|
1324
|
-
│ ├── panel-prompts.ts # Shared-task reviewer and synthesis prompts
|
|
1325
|
-
│ ├── panel-reconciliation.ts # Objection-preserving valid-review barrier
|
|
1326
|
-
│ ├── panel-child-group.ts # Child signals and disposable-worktree cleanup
|
|
1327
|
-
│ ├── panel-render.ts # Compact and expanded sanitized panel rows
|
|
1328
|
-
│ ├── execution-ui.ts # Per-agent execution settings screens
|
|
1329
|
-
│ ├── stateful-guidance.ts # Detached model-facing workflow guidance
|
|
1330
|
-
│ ├── stateful-lifecycle.ts # Runtime disposal and spawn ownership guards
|
|
1331
|
-
│ ├── timeout-finalization.ts # Abort-time bounded summary prompts and deadlines
|
|
1332
|
-
│ ├── timeout-checkpoint.ts # Redacted deterministic termination evidence
|
|
1333
|
-
│ ├── turn-budget.ts # Idle, assistant-turn, and tool-call enforcement
|
|
1334
|
-
│ ├── runner.ts # Blocking subprocess execution and progress capture
|
|
1335
|
-
│ ├── runner-types.ts # Shared subprocess result and launch contracts
|
|
1336
|
-
│ ├── subagent-details.ts # Composed tool-result and panel detail contracts
|
|
1337
|
-
│ ├── process-control.ts # Reusable child-process termination and escalation
|
|
1338
|
-
│ ├── runner-usage.ts # Bounded subprocess usage accumulation
|
|
1339
|
-
│ ├── runner-result.ts # Shared subprocess result interpretation
|
|
1340
|
-
│ ├── stateful-limit-ui.ts # Detached capacity settings and recovery previews
|
|
1341
|
-
│ ├── stateful-limits.ts # Shared detached defaults, labels, and validation
|
|
1342
|
-
│ ├── stateful-safety.ts # Project-agent and shared-write safety checks
|
|
1343
|
-
│ ├── stateful-tool-params.ts # Consolidated action schemas and validation
|
|
1344
|
-
│ └── *.ts # Package-local discovery, execution, rendering, and settings modules
|
|
1345
|
-
├── README.md
|
|
1346
|
-
├── LICENSE
|
|
1347
|
-
├── tsconfig.json
|
|
1348
|
-
└── package.json
|
|
1349
|
-
```
|
|
1350
|
-
|
|
1351
|
-
`src/index.ts` is the authoritative thin entrypoint and forwards to `subagents-extension.ts`.
|
|
1352
|
-
The package build bundles that source graph into split `.ts` files under `dist` for Pi's Jiti loader.
|
|
1353
|
-
`subagents.ts` and `stateful.ts` preserve existing source-level utility imports without making those utility graphs part of Pi startup.
|
|
1354
|
-
Workflow settings remain backward compatible: older files without `blocking.enabled` receive the eight-tool default, and an absent `blocking.maxParallelTasks` keeps the previous eight-worker limit.
|
|
1355
|
-
Existing `stateful.enabled: false` files expose deprecated blocking `subagent` plus supported inspection and consultation.
|
|
1356
|
-
Older package releases ignore and preserve the optional `blocking.maxParallelTasks`, `consult`, `cwdPolicy`, and `usageRecording` fields.
|
|
1357
|
-
The package exposes its Pi extension through `package.json`:
|
|
1358
|
-
|
|
1359
|
-
```json
|
|
1360
|
-
{
|
|
1361
|
-
"pi": {
|
|
1362
|
-
"extensions": ["./dist/index.ts"]
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
289
|
+
├── dist/ # Generated Jiti runtime and child bridge
|
|
290
|
+
├── docs/ # Concise tools and design references
|
|
291
|
+
├── scripts/ # Deterministic runtime builder
|
|
292
|
+
├── skills/using-pi-subagents/ # Repository-only example delegation skill
|
|
293
|
+
├── src/ # Extension, broker, child bridge, and subprocess runtime
|
|
294
|
+
├── test/ # Protocol, lifecycle, process, and policy tests
|
|
295
|
+
├── package.json # Pi extension declaration
|
|
296
|
+
└── README.md # User guide and safety boundaries
|
|
1365
297
|
```
|
|
1366
298
|
|
|
1367
299
|
## 🔎 Keywords
|
|
1368
300
|
|
|
1369
|
-
Pi
|
|
301
|
+
Pi, subagents, delegation, subagent jobs, least privilege, main-agent messaging, cancellation, job lifecycle.
|
|
1370
302
|
|
|
1371
303
|
## 📄 License
|
|
1372
304
|
|
|
1373
|
-
MIT
|
|
1374
|
-
See [`LICENSE`](./LICENSE).
|
|
305
|
+
[MIT](./LICENSE)
|