@narumitw/pi-subagents 2.0.6 → 2.1.1

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.
Files changed (180) hide show
  1. package/README.md +171 -60
  2. package/dist/chunks/{auto-transport-SY2VHUFH.ts → auto-transport-FUUKFDIG.ts} +6 -6
  3. package/dist/chunks/{capability-grant-CGEWOEKE.ts → capability-grant-PR72SWWS.ts} +4 -4
  4. package/dist/chunks/{chunk-CBP76ARQ.ts → chunk-2LMJU25E.ts} +172 -74
  5. package/dist/chunks/chunk-2LMJU25E.ts.map +7 -0
  6. package/dist/chunks/{chunk-DPPVEQAM.ts → chunk-4AQSF7AS.ts} +1 -1
  7. package/dist/chunks/chunk-4AQSF7AS.ts.map +7 -0
  8. package/dist/chunks/chunk-6H6TBBED.ts +108 -0
  9. package/dist/chunks/chunk-6H6TBBED.ts.map +7 -0
  10. package/dist/chunks/{chunk-YBUWBRF7.ts → chunk-6NSJVPXX.ts} +6 -16
  11. package/dist/chunks/{chunk-YBUWBRF7.ts.map → chunk-6NSJVPXX.ts.map} +2 -2
  12. package/dist/chunks/{chunk-DSOOH73Y.ts → chunk-7AAJEUSL.ts} +3 -3
  13. package/dist/chunks/{chunk-DSOOH73Y.ts.map → chunk-7AAJEUSL.ts.map} +2 -2
  14. package/dist/chunks/{chunk-7QPPBBXZ.ts → chunk-D4CR7T73.ts} +21 -3
  15. package/dist/chunks/chunk-D4CR7T73.ts.map +7 -0
  16. package/dist/chunks/{chunk-NIF42QMF.ts → chunk-FEVPWRMU.ts} +7 -4
  17. package/dist/chunks/chunk-FEVPWRMU.ts.map +7 -0
  18. package/dist/chunks/{chunk-S2IWVK3J.ts → chunk-ILEQ27AL.ts} +3 -2
  19. package/dist/chunks/chunk-ILEQ27AL.ts.map +7 -0
  20. package/dist/chunks/{chunk-DQMN4OYM.ts → chunk-ITVWPNU4.ts} +12 -106
  21. package/dist/chunks/chunk-ITVWPNU4.ts.map +7 -0
  22. package/dist/chunks/{chunk-QDVGH2X7.ts → chunk-IWC32VPY.ts} +2 -1
  23. package/dist/chunks/{chunk-QDVGH2X7.ts.map → chunk-IWC32VPY.ts.map} +2 -2
  24. package/dist/chunks/{chunk-I2FAK44T.ts → chunk-JSZIP73U.ts} +48 -10
  25. package/dist/chunks/chunk-JSZIP73U.ts.map +7 -0
  26. package/dist/chunks/{chunk-ZHTNCZIA.ts → chunk-JU6LUNLP.ts} +2 -2
  27. package/dist/chunks/{chunk-PSK43Y6A.ts → chunk-LASD73CM.ts} +2 -2
  28. package/dist/chunks/{chunk-C4L6P266.ts → chunk-LEOYDZI3.ts} +1 -1
  29. package/dist/chunks/{chunk-C4L6P266.ts.map → chunk-LEOYDZI3.ts.map} +2 -2
  30. package/dist/chunks/{chunk-H3BFJ7HJ.ts → chunk-LL4LP2T7.ts} +5 -5
  31. package/dist/chunks/chunk-N2T5IN4X.ts +18 -0
  32. package/dist/chunks/chunk-N2T5IN4X.ts.map +7 -0
  33. package/dist/chunks/chunk-NLT67IZS.ts +322 -0
  34. package/dist/chunks/chunk-NLT67IZS.ts.map +7 -0
  35. package/dist/chunks/{chunk-G3RSMSXJ.ts → chunk-NTRPLF46.ts} +1 -1
  36. package/dist/chunks/chunk-NTRPLF46.ts.map +7 -0
  37. package/dist/chunks/{chunk-EFBPISNT.ts → chunk-PBZMBTNJ.ts} +104 -103
  38. package/dist/chunks/chunk-PBZMBTNJ.ts.map +7 -0
  39. package/dist/chunks/{chunk-SCZ33MYW.ts → chunk-PGLSFLYW.ts} +2 -2
  40. package/dist/chunks/{chunk-O4VO6JUJ.ts → chunk-TM2R67J3.ts} +3 -3
  41. package/dist/chunks/{chunk-QBORTI4W.ts → chunk-TMZRHIIK.ts} +32 -3
  42. package/dist/chunks/chunk-TMZRHIIK.ts.map +7 -0
  43. package/dist/chunks/chunk-TZ34IQ3M.ts +59 -0
  44. package/dist/chunks/chunk-TZ34IQ3M.ts.map +7 -0
  45. package/dist/chunks/{chunk-7OBINKFM.ts → chunk-VDG7LTYE.ts} +11 -11
  46. package/dist/chunks/chunk-VDG7LTYE.ts.map +7 -0
  47. package/dist/chunks/{chunk-AEUYS7JC.ts → chunk-X4NMONPE.ts} +1 -1
  48. package/dist/chunks/chunk-X4NMONPE.ts.map +7 -0
  49. package/dist/chunks/{chunk-HKC4ES4B.ts → chunk-YPJEN6NU.ts} +2 -2
  50. package/dist/chunks/{chunk-434NII74.ts → chunk-YU53SHA7.ts} +54 -8
  51. package/dist/chunks/chunk-YU53SHA7.ts.map +7 -0
  52. package/dist/chunks/{completion-delivery-YPOWSSV3.ts → completion-delivery-RSJU6BXL.ts} +5 -4
  53. package/dist/chunks/{config-status-J4GPWP46.ts → config-status-FKGDECZ3.ts} +7 -6
  54. package/dist/chunks/{config-ui-2YUCUEBM.ts → config-ui-ABHYNGQ7.ts} +297 -231
  55. package/dist/chunks/config-ui-ABHYNGQ7.ts.map +7 -0
  56. package/dist/chunks/{consult-IV7UBNQQ.ts → consult-LJU3IQY5.ts} +14 -13
  57. package/dist/chunks/consult-LJU3IQY5.ts.map +7 -0
  58. package/dist/chunks/{create-stateful-transport-ZP3IXNV3.ts → create-stateful-transport-JWC2EFYL.ts} +6 -6
  59. package/dist/chunks/{delegation-contract-WJPT4FVS.ts → delegation-contract-LA56I5DT.ts} +2 -2
  60. package/dist/chunks/{discovery-K25T3SH4.ts → discovery-MIFB2U4Y.ts} +3 -3
  61. package/dist/chunks/{execution-LA7HN5YF.ts → execution-Q2JZLKJA.ts} +19 -16
  62. package/dist/chunks/execution-Q2JZLKJA.ts.map +7 -0
  63. package/dist/chunks/{in-process-transport-4RF3J6XK.ts → in-process-transport-HJ6TZXC3.ts} +9 -9
  64. package/dist/chunks/{inspect-XV2QALMR.ts → inspect-UH2TKH6E.ts} +25 -10
  65. package/dist/chunks/inspect-UH2TKH6E.ts.map +7 -0
  66. package/dist/chunks/{persistence-VSGXAW4P.ts → persistence-UY3PY6E5.ts} +11 -7
  67. package/dist/chunks/persistence-UY3PY6E5.ts.map +7 -0
  68. package/dist/chunks/{registry-E6XPJB7L.ts → registry-BT54L6CY.ts} +136 -15
  69. package/dist/chunks/registry-BT54L6CY.ts.map +7 -0
  70. package/dist/chunks/{retained-semantic-state-7WXSGRJU.ts → retained-semantic-state-GM75FZGE.ts} +3 -3
  71. package/dist/chunks/{rpc-transport-NEHBHWX4.ts → rpc-transport-7R7DVCEB.ts} +12 -16
  72. package/dist/chunks/rpc-transport-7R7DVCEB.ts.map +7 -0
  73. package/dist/chunks/{spawn-idempotency-QGHO2WKC.ts → spawn-idempotency-BNHOSMZW.ts} +2 -2
  74. package/dist/chunks/{subprocess-transport-NSHOGDC4.ts → subprocess-transport-VHZJRBTW.ts} +15 -14
  75. package/dist/chunks/subprocess-transport-VHZJRBTW.ts.map +7 -0
  76. package/dist/chunks/usage-recording-store-CW3EH2SZ.ts +164 -0
  77. package/dist/chunks/usage-recording-store-CW3EH2SZ.ts.map +7 -0
  78. package/dist/index.ts +682 -82
  79. package/dist/index.ts.map +3 -3
  80. package/docs/async-runtime-protocol.md +83 -0
  81. package/docs/implementation-notes/pi-subagents-capability-matrix.md +62 -0
  82. package/docs/implementation-notes/pi-subagents-current-direction.md +99 -0
  83. package/docs/implementation-notes/pi-subagents-rpc-v1.md +153 -0
  84. package/docs/pi-subagents-diagrams.md +183 -0
  85. package/package.json +9 -8
  86. package/src/agents/types.ts +2 -0
  87. package/src/async-subagent-benchmark.ts +532 -0
  88. package/src/completion-delivery.ts +71 -4
  89. package/src/completion-render.ts +1 -0
  90. package/src/completion-requirement.ts +479 -0
  91. package/src/config-registration.ts +5 -5
  92. package/src/config-status.ts +66 -70
  93. package/src/config-ui.ts +244 -150
  94. package/src/consult-registration.ts +4 -12
  95. package/src/consult-resources.ts +1 -1
  96. package/src/consult.ts +3 -8
  97. package/src/delegation-contract.ts +55 -9
  98. package/src/execution-plan.ts +1 -1
  99. package/src/execution-ui.ts +40 -29
  100. package/src/execution.ts +2 -3
  101. package/src/inspect.ts +24 -1
  102. package/src/orchestration-metrics.ts +1 -1
  103. package/src/panel-execution.ts +2 -3
  104. package/src/panel-failure.ts +1 -1
  105. package/src/panel-render.ts +1 -1
  106. package/src/parallel-limit-ui.ts +6 -5
  107. package/src/params.ts +2 -1
  108. package/src/persistence.ts +9 -0
  109. package/src/process-control.ts +43 -0
  110. package/src/registry-types.ts +5 -0
  111. package/src/registry.ts +162 -18
  112. package/src/render.ts +2 -1
  113. package/src/rpc-transport.ts +1 -1
  114. package/src/runner-outcome.ts +1 -1
  115. package/src/runner-result.ts +1 -1
  116. package/src/runner-types.ts +102 -0
  117. package/src/runner.ts +11 -192
  118. package/src/session-guidance-contract.ts +309 -0
  119. package/src/settings/inspection.ts +27 -0
  120. package/src/settings/schema.ts +9 -0
  121. package/src/settings-reader.ts +7 -0
  122. package/src/settings.ts +20 -0
  123. package/src/spawn-idempotency.ts +5 -0
  124. package/src/stateful-agent-view.ts +15 -19
  125. package/src/stateful-guidance.ts +11 -18
  126. package/src/stateful-limit-ui.ts +23 -20
  127. package/src/stateful-limits.ts +10 -10
  128. package/src/stateful-registration.ts +126 -36
  129. package/src/stateful-render.ts +27 -2
  130. package/src/subagent-details.ts +43 -0
  131. package/src/subagents-extension.ts +116 -68
  132. package/src/subagents.ts +2 -0
  133. package/src/subprocess-transport.ts +2 -1
  134. package/src/supervision.ts +2 -1
  135. package/src/timeout-finalization.ts +1 -1
  136. package/src/tool-schema-compatibility.ts +73 -0
  137. package/src/transport-types.ts +6 -0
  138. package/src/transport-ui.ts +18 -46
  139. package/src/usage-recording-config.ts +13 -0
  140. package/src/usage-recording-store.ts +183 -0
  141. package/src/usage-recording.ts +478 -0
  142. package/src/verification-harness.ts +1 -1
  143. package/src/workflow-ui.ts +17 -9
  144. package/dist/chunks/chunk-434NII74.ts.map +0 -7
  145. package/dist/chunks/chunk-7OBINKFM.ts.map +0 -7
  146. package/dist/chunks/chunk-7QPPBBXZ.ts.map +0 -7
  147. package/dist/chunks/chunk-AEUYS7JC.ts.map +0 -7
  148. package/dist/chunks/chunk-CBP76ARQ.ts.map +0 -7
  149. package/dist/chunks/chunk-DPPVEQAM.ts.map +0 -7
  150. package/dist/chunks/chunk-DQMN4OYM.ts.map +0 -7
  151. package/dist/chunks/chunk-EFBPISNT.ts.map +0 -7
  152. package/dist/chunks/chunk-G3RSMSXJ.ts.map +0 -7
  153. package/dist/chunks/chunk-I2FAK44T.ts.map +0 -7
  154. package/dist/chunks/chunk-NIF42QMF.ts.map +0 -7
  155. package/dist/chunks/chunk-QBORTI4W.ts.map +0 -7
  156. package/dist/chunks/chunk-S2IWVK3J.ts.map +0 -7
  157. package/dist/chunks/config-ui-2YUCUEBM.ts.map +0 -7
  158. package/dist/chunks/consult-IV7UBNQQ.ts.map +0 -7
  159. package/dist/chunks/execution-LA7HN5YF.ts.map +0 -7
  160. package/dist/chunks/inspect-XV2QALMR.ts.map +0 -7
  161. package/dist/chunks/persistence-VSGXAW4P.ts.map +0 -7
  162. package/dist/chunks/registry-E6XPJB7L.ts.map +0 -7
  163. package/dist/chunks/rpc-transport-NEHBHWX4.ts.map +0 -7
  164. package/dist/chunks/subprocess-transport-NSHOGDC4.ts.map +0 -7
  165. /package/dist/chunks/{auto-transport-SY2VHUFH.ts.map → auto-transport-FUUKFDIG.ts.map} +0 -0
  166. /package/dist/chunks/{capability-grant-CGEWOEKE.ts.map → capability-grant-PR72SWWS.ts.map} +0 -0
  167. /package/dist/chunks/{chunk-ZHTNCZIA.ts.map → chunk-JU6LUNLP.ts.map} +0 -0
  168. /package/dist/chunks/{chunk-PSK43Y6A.ts.map → chunk-LASD73CM.ts.map} +0 -0
  169. /package/dist/chunks/{chunk-H3BFJ7HJ.ts.map → chunk-LL4LP2T7.ts.map} +0 -0
  170. /package/dist/chunks/{chunk-SCZ33MYW.ts.map → chunk-PGLSFLYW.ts.map} +0 -0
  171. /package/dist/chunks/{chunk-O4VO6JUJ.ts.map → chunk-TM2R67J3.ts.map} +0 -0
  172. /package/dist/chunks/{chunk-HKC4ES4B.ts.map → chunk-YPJEN6NU.ts.map} +0 -0
  173. /package/dist/chunks/{completion-delivery-YPOWSSV3.ts.map → completion-delivery-RSJU6BXL.ts.map} +0 -0
  174. /package/dist/chunks/{config-status-J4GPWP46.ts.map → config-status-FKGDECZ3.ts.map} +0 -0
  175. /package/dist/chunks/{create-stateful-transport-ZP3IXNV3.ts.map → create-stateful-transport-JWC2EFYL.ts.map} +0 -0
  176. /package/dist/chunks/{delegation-contract-WJPT4FVS.ts.map → delegation-contract-LA56I5DT.ts.map} +0 -0
  177. /package/dist/chunks/{discovery-K25T3SH4.ts.map → discovery-MIFB2U4Y.ts.map} +0 -0
  178. /package/dist/chunks/{in-process-transport-4RF3J6XK.ts.map → in-process-transport-HJ6TZXC3.ts.map} +0 -0
  179. /package/dist/chunks/{retained-semantic-state-7WXSGRJU.ts.map → retained-semantic-state-GM75FZGE.ts.map} +0 -0
  180. /package/dist/chunks/{spawn-idempotency-QGHO2WKC.ts.map → spawn-idempotency-BNHOSMZW.ts.map} +0 -0
package/README.md CHANGED
@@ -6,7 +6,7 @@ Delegate bounded research or implementation work to isolated specialist agents w
6
6
 
7
7
  Use the built-in `explorer` for read-only evidence and `worker` for a clearly owned implementation slice.
8
8
 
9
- The compatibility default exposes every delegation method, while **Async only** is the recommended smaller surface for normal parallel work.
9
+ The compatibility default exposes background and blocking methods, while **Keep Pi available (async)** is an optional smaller background-only surface.
10
10
 
11
11
  ## ✨ Features
12
12
 
@@ -19,6 +19,7 @@ The compatibility default exposes every delegation method, while **Async only**
19
19
  - Routes nested completion and peer communication through authenticated session-scoped channels.
20
20
  - Provides `/subagents` settings, status, help, tool-surface selection, and recovery diagnostics.
21
21
  - Returns concise model-visible results with complete bounded details and sanitized terminal rendering.
22
+ - Optionally records content-free local lifecycle and timing events for evaluating delegation behavior.
22
23
  - Loads a generated split runtime while preserving lazy execution, UI, inspection, and transport chunks.
23
24
 
24
25
  ## 📦 Install
@@ -45,57 +46,93 @@ An unbuilt checkout intentionally has no declared generated entrypoint.
45
46
 
46
47
  ## 🚀 Quick start
47
48
 
48
- For normal async-first use, run `/subagents`, choose **Change delegation**, select **Async only · Recommended**, confirm the exact tool changes, and reload.
49
+ Run `/subagents`, choose **How subagents run**, and review the tools registered by each workflow.
49
50
 
50
- This registers `subagent_spawn`, `subagent_send`, `subagent_manage`, `subagent_mailbox`, and `subagent_inspect` while keeping the main agent responsive.
51
+ The compatibility default includes background agents and blocking compatibility methods.
52
+
53
+ Select **Keep Pi available (async)** to register `subagent_spawn`, `subagent_send`, `subagent_manage`, `subagent_mailbox`, and `subagent_inspect` without the blocking methods.
54
+
55
+ Confirm any change and reload to apply it.
51
56
 
52
57
  Default `next-turn` delivery is for work the current response does not require.
53
- When the final answer depends on detached work, use `/subagents settings` to select **Resume automatically when finished**.
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.
54
60
 
55
- Keep **All delegation methods** when an explicit blocking workflow or synchronous read-only `subagent_consult` is still required.
61
+ **Background plus compatibility methods (async + sync)** also provides the deprecated blocking `subagent`, supported `subagent_await` join, and synchronous read-only `subagent_consult`.
62
+ The blocking `subagent` tool is deprecated for new work.
56
63
 
57
- Async-first delegation still requires useful parallel main-agent work, clear worker ownership, and a supported completion path.
64
+ Background delegation still requires useful parallel main-agent work, clear worker ownership, and a supported completion path.
58
65
 
59
66
  ## 💬 Commands
60
67
 
61
68
  - `/subagents` opens the current-session manager in TUI mode and reports bounded status in RPC mode.
62
- - `/subagents settings` configures target locations, trusted resources, and async completion delivery.
63
- - `/subagents status` shows current-session and configured values with their sources.
64
- - `/subagents help` summarizes the command surface and isolation limits.
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.
65
72
 
66
73
  ## ⚙️ Settings
67
74
 
68
- Use `/subagents settings` for target location, trust, consultation resource, and detached-completion preferences.
69
- Use `/subagents` → **Advanced settings** for delegation workflow, agent tool permissions, and runtime limits.
75
+ Use `/subagents settings` for **Folders and trusted resources**, **Completion and privacy**, **Agent defaults**, and **Advanced runtime settings**.
76
+ Use `/subagents` → **How subagents run** to change the registered delegation tools.
70
77
  Settings are stored in `~/.pi/agent/pi-subagents.json`; the detailed sections below document precedence, reload requirements, and safety behavior.
71
78
 
79
+ ## 📊 Local usage recording
80
+
81
+ Local usage recording is disabled by default and creates no usage storage until the user selects **On · local only** in `/subagents settings`.
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.
84
+
85
+ Records are stored below `<pi-agent-directory>/pi-subagents-usage/` as private per-runtime JSONL writer files.
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.
91
+
92
+ Stored fields are limited to extension-generated runtime, session, turn, tool, child, run, and completion ordinals; the effective delegation surface; lifecycle and typed outcome states; bounded executor-owned termination reasons; runtime-versus-explicit budget-source labels; completion-delivery transitions; bounded usage numbers; errors as booleans; and monotonic timing or durations.
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.
95
+
96
+ The events can describe blocking versus async tool selection, operational errors, parent/child overlap, child terminal states, completion attempts and visibility, turns, tokens, and wall-clock durations within one runtime.
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.
100
+
101
+ `/subagents status` reports whether recording is active, the current-session event count, retention, and the local path.
102
+ A failed write drops that event, reports one bounded warning, and retries on later events without exposing filesystem details.
103
+
72
104
  ## 🛠️ Tools
73
105
 
74
- `pi-subagents` registers seven tools by default.
75
- Run `/subagents`, choose **Change delegation**, review the concrete tool changes, then select **Save and reload** to apply one of these workflows:
106
+ `pi-subagents` registers eight tools by default.
107
+ Run `/subagents`, choose **How subagents run**, review the concrete tool changes, then select **Save and reload** to apply one of these workflows:
76
108
 
77
109
  | Workflow | Registered tools |
78
110
  | --- | --- |
79
- | **All delegation methods** (compatibility default) | `subagent`, `subagent_spawn`, `subagent_send`, `subagent_manage`, `subagent_mailbox`, `subagent_inspect`, and `subagent_consult` |
80
- | **Async only** (recommended) | `subagent_spawn`, `subagent_send`, `subagent_manage`, `subagent_mailbox`, and `subagent_inspect` |
81
- | **Blocking only** (compatibility) | `subagent`, `subagent_inspect`, and `subagent_consult` |
82
- | **Disabled** | `subagent_inspect` only; delegation is disabled |
83
-
84
- `subagent` and `subagent_consult` remain explicit compatibility routes with no current deprecation deadline.
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.
85
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)**.
86
121
  Any default change, tool removal, or lifecycle consolidation requires a separately approved compatibility migration.
87
122
 
88
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.
89
124
  Escape or **Cancel** leaves settings unchanged.
90
125
  Tool removal requires an extension reload because Pi does not expose extension tool unregistration.
91
- To avoid aborting work or removing isolated worktrees during `session_shutdown`, workflow changes are blocked while detached agents are retained; finish or clear them through **Current agents** first.
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.
92
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.
93
128
 
94
129
  The available tools are:
95
130
 
96
- - `subagent` — delegate blocking single, parallel, fan-in, chained, panel-review, or explicit dependency-workflow tasks.
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.
97
133
  The main agent cannot process queued steering until the call returns.
98
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.
99
136
  - `subagent_inspect` — inspect agent/model/run/runtime metadata without launching work or changing state.
100
137
  - `subagent_consult` — run one ephemeral read-only consultation and wait for its answer.
101
138
 
@@ -119,10 +156,11 @@ It does not pretend to stream the background child after the tool call has compl
119
156
  Custom transcript rendering is TUI presentation only.
120
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.
121
158
 
122
- After each session starts, the descriptions of the registered `subagent`, `subagent_spawn`, and `subagent_consult` tools include the same bounded parent-facing catalog of the agents available in that session.
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.
123
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.
124
161
  The catalog also warns that enforced path, network, and secret guarantees are unsupported.
125
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.
126
164
 
127
165
  Choose the API by lifecycle:
128
166
 
@@ -133,10 +171,11 @@ Choose the API by lifecycle:
133
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 |
134
172
  | Two or more independent implementation slices | Use workers with disjoint write ownership while the main agent coordinates and integrates |
135
173
  | Broad read-only evidence that can run beside main-agent work | Use async `subagent_spawn` with `explorer` |
136
- | Final-answer-dependent detached work | Enable `completionDelivery: "auto-resume"` so completion requests a synthesis turn |
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 |
137
175
  | Bounded synchronous read-only evidence whose independent perspective justifies waiting | Use `subagent_consult` when blocking delegation is enabled |
138
- | Intentional synchronous workflow, panel, chain, or fan-in | Use blocking `subagent` when making the main agent unavailable is justified |
176
+ | Existing synchronous workflow, panel, chain, or fan-in caller without a detached replacement | Keep deprecated `subagent` as a compatibility route |
139
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 |
140
179
  | Side-effect-free agent/model/run diagnostics | Use `subagent_inspect` |
141
180
 
142
181
  Execution modes:
@@ -158,6 +197,7 @@ Common controls:
158
197
  - `thinkingLevel` — request `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max` thinking for the spawned Pi process or retained child.
159
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.
160
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.
161
201
  - `totalTimeoutMs` — bound a whole explicit blocking workflow; no new task starts after the budget is exhausted.
162
202
 
163
203
  For `subagent_spawn`, the root agent selects the lowest thinking level and shortest realistic work deadline sufficient for the delegated task.
@@ -193,11 +233,11 @@ For real isolation, run Pi in a container, VM, micro-VM, or OS sandbox with only
193
233
 
194
234
  ## 🧭 Proactive use
195
235
 
196
- When registered, the blocking `subagent` tool advertises only blocking guidance.
197
- When stateful lifecycle tools are registered, `subagent_spawn` adds detached guidance for the active completion-delivery policy.
198
- Changing the policy through `/subagents settings` refreshes that guidance immediately.
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.
199
239
 
200
- The `subagent`, `subagent_spawn`, and `subagent_consult` descriptions advertise the current agent catalog automatically; no preliminary list call is needed.
240
+ The current session-guidance message advertises the agent catalog automatically, so no preliminary list call is needed.
201
241
  Each entry exposes the exact declared capability and tool identifiers needed by an enforced contract, plus filesystem authority and result formats.
202
242
  Agents without a valid capability manifest are labeled `undeclared` instead of implying support.
203
243
  Built-ins and user agents appear under the default `agentScope: "user"`.
@@ -205,7 +245,7 @@ Trusted project agents appear separately and explicitly require `agentScope: "pr
205
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"`.
206
246
  A user override of a built-in also shows the built-in fallback available with `agentScope: "project"`; `"both"` keeps the user definition.
207
247
  The catalog is bounded and reports its omission count; metadata discovery also caps files and bytes read per scope.
208
- Refreshed metadata replaces the previous session's catalog rather than accumulating stale entries.
248
+ Each newer session-guidance message explicitly supersedes earlier guidance while preserving the existing conversation prefix.
209
249
 
210
250
  Delegation guidance:
211
251
 
@@ -216,12 +256,14 @@ Delegation guidance:
216
256
  - If no useful main-agent work exists, perform the single-lane task directly instead of spawning one ordinary worker.
217
257
  - A single worker without concurrent main-agent work remains available when the user explicitly requests a specialist model, tool profile, or isolation boundary.
218
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.
219
- - With `completionDelivery: "auto-resume"`, detached work may affect the final answer because completion requests a later synthesis turn.
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.
220
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.
221
263
  - Use multiple workers only for truly independent slices with disjoint write ownership and safe workspace concurrency, and keep integration in the main agent.
222
264
  - Keep ordinary planning in the main agent or express a genuine dependency graph through an explicit caller-authored `workflow` payload.
223
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.
224
- - Use blocking `subagent` only when intentional synchronous output or isolation justifies making the main agent unavailable.
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.
225
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.
226
268
 
227
269
  Examples where the main agent chooses the topology:
@@ -240,7 +282,8 @@ The main agent owns `src/parser.ts`, immediately continues that work after spawn
240
282
  ```json
241
283
  {
242
284
  "agent": "worker",
243
- "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."
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"
244
287
  }
245
288
  ```
246
289
 
@@ -283,7 +326,7 @@ It never starts a child, sends or acknowledges mailbox messages, interrupts or c
283
326
  | `get_workflow` | Required `workflowId` | Bounded task states, generations, dependencies, plan identities, artifact metadata, verification state, and outcome reasons without artifact contents |
284
327
  | `list_models` | Optional `limit` (default 50, maximum 100) | Session-scoped models, or the already-loaded available snapshot |
285
328
  | `preview_context` | Optional `context` and `contextEntryIds` | Selected mode, user turns, source count, UTF-8 bytes, and truncation without returning context text |
286
- | `status` | No additional fields | Effective workflow, runtime counts/transport, detached limit values, completion delivery, consultation resources, and configured/runtime settings with per-field sources |
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 |
287
330
  | `diagnose` | No additional fields | Structured `pass`, `warning`, and `fail` checks; failed checks are report data rather than a tool error |
288
331
 
289
332
  The schema rejects fields that do not belong to the selected action.
@@ -601,16 +644,34 @@ Legacy v1 and v2 records without acceptance fields retain their prior completed
601
644
  Stateful lifecycle tools are available by default.
602
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.
603
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
+ That restored fallback remains fixed for the summary epoch while later cancellation transitions or completion messages supersede it at the conversation tail.
656
+ The runtime rejects a sixty-fifth unresolved required run before acceptance so every unresolved exact identity fits in the bounded parent context.
604
657
  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.
605
658
  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.
606
659
 
607
660
  Detached work follows a non-polling policy.
608
661
  Before one ordinary `subagent_spawn`, identify useful non-overlapping main-agent work that starts immediately and a supported completion integration path.
609
662
  With default `next-turn` delivery, the current response must not depend on the result because an idle root is not awakened.
610
- With opt-in `auto-resume`, detached work may affect the final answer because completion requests a synthesis turn after the main agent settles.
663
+ 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.
664
+ 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.
665
+ 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.
611
666
  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.
667
+ Do not duplicate a running child's assigned work; use a bounded parent fallback only after completion reports failure or insufficient evidence.
668
+ Omit `contract` for ordinary `subagent_spawn` calls and use it only when explicit acceptance, authority, evidence, or admission semantics are required.
669
+ 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.
670
+ 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.
612
671
  Add another detached agent only for truly independent work with safe workspace concurrency and disjoint write ownership.
613
- Detached lifecycle work intentionally has no `subagent_wait` tool.
672
+ When both blocking and stateful delegation are enabled, `subagent_await` may intentionally join one retained turn after useful overlapping parent work is complete.
673
+ Its `timeoutMs` defaults to 30 seconds and limits only the wait; timeout or caller cancellation does not interrupt or close the child.
674
+ The normal at-least-once completion channel remains active, so the same completion may still arrive after the await result.
614
675
 
615
676
  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.
616
677
  Without concurrent main-agent work, use one worker only for an explicit user-requested specialist model, tool profile, or isolation boundary.
@@ -620,15 +681,21 @@ Simple and immediate critical-path work should stay in the main agent.
620
681
 
621
682
  - `"next-turn"` (default) sends `deliverAs: "steer"` without a turn trigger.
622
683
  Pi queues it into an active root's context, while an idle root records it without waking.
623
- - `"auto-resume"` holds completion while the root is active, then requests one synthesis turn after the parent settles when no user or extension messages are already pending.
624
- Simultaneous completions share that turn, active work is not interrupted, and pending input suppresses the automatic wake.
625
-
684
+ - `"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.
685
+ 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.
686
+
687
+ 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.
688
+ 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.
689
+ `message_end` replacement can repair finalized persistence but cannot retract already displayed streaming output.
690
+ The package therefore keeps `subagent_await` as the accurately documented blocking fallback and does not claim an extension-only hard barrier.
691
+ 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.
626
692
  The bounded persisted completion outbox provides ordered at-least-once delivery across process restart without replaying the child turn.
627
693
  A top-level completion targets `/root`; a nested completion enters the direct retained parent's mailbox and is not duplicated into the root transcript.
628
694
  If the direct parent cannot own delivery, routing walks toward the nearest live retained ancestor and uses `/root` only as the final fallback.
629
695
  An idle parent remains asleep, and inspection exposes its unread and pending-completion counts until a later turn consumes the envelope.
630
696
  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.
631
697
  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.
698
+ The broker retains a bounded set of recently acknowledged IDs to suppress same-session re-enqueue while keeping memory bounded.
632
699
  If the process exits after context assembly but before acknowledgement is persisted, the same ID can be delivered again and consumers must deduplicate it.
633
700
  Auto-resume applies only to `/root`; nested delivery never silently starts the parent.
634
701
  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.
@@ -643,18 +710,20 @@ Set it to `auto` for deterministic preflight selection: read-only built-in tools
643
710
  Automatic selection never falls back after child creation or prompt acceptance.
644
711
 
645
712
  Run `/subagents` in TUI mode to open the standard primary manager.
646
- It leads with the current delegation workflow, human-readable async completion behavior, consultation/delegation target policies, consultation-resource policy, parallel-worker limit, and active/retained counts.
647
- **Change delegation**, **Current agents**, and **Settings** cover the common workflows.
648
- Agent permissions, **Maximum parallel workers**, **Detached agent limits**, **Performance and execution**, transport/runtime details, source, and settings path remain under **Advanced settings**.
649
- **Performance and execution** provides responsiveness guidance, transport previews, and per-agent model/thinking/timeout defaults.
713
+ It leads with how subagents run, what Pi does when work finishes, and counts of working subagents and subagents saved for follow-up.
714
+ **How subagents run**, **Current subagents**, **Settings**, **Diagnostics**, and **Help** are the only top-level actions.
715
+ **Settings** groups **Folders and trusted resources**, **Completion and privacy**, **Agent defaults**, and **Advanced runtime settings** by user task.
716
+ **Diagnostics** shows detailed current-session values, configured values, sources, and the settings path.
717
+ **Advanced runtime settings** provides optional transport and capacity controls that most users can leave unchanged.
718
+ **Agent defaults** groups tool permissions with per-agent model, thinking, and time-limit defaults.
650
719
  Per-agent defaults preserve tool and context settings, and explicit tool-call values remain authoritative.
651
720
  The parallel-worker input rejects invalid values without discarding the draft and applies a successful save immediately.
652
- The detached-limit screen edits retained capacity, active-turn concurrency, direct children, tree depth, and stored-record capacity.
721
+ The background-agent limit screen edits saved-subagent capacity, concurrent work, direct children, nested levels, and stored-record capacity.
653
722
  Detached-limit saves are durable immediately but apply to the runtime after `/reload` or the next Pi session.
654
723
  Escape returns from a nested screen to a newly refreshed manager, while Ctrl+C closes the full flow.
655
724
  Exact workflow/reload and project-agent safety confirmations remain extension-owned because they guard live agent and trust-boundary policy rather than ordinary navigation.
656
725
 
657
- The direct routes remain predictable: `/subagents settings` changes both target policies, consultation resources, and completion delivery and applies them immediately, including refreshing model-facing tool guidance; `/subagents status` reports current-session runtime values separately from configured values, per-field sources, and path; `/subagents help` summarizes the single-command interface and the non-sandbox limitation.
726
+ 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.
658
727
  In RPC mode, bare `/subagents` emits the same bounded status through Pi's notification protocol instead of opening a custom TUI.
659
728
  JSON and print modes do not emit ad hoc command output.
660
729
  Manual edits use `~/.pi/agent/pi-subagents.json` and take effect after reloading Pi:
@@ -685,6 +754,9 @@ Manual edits use `~/.pi/agent/pi-subagents.json` and take effect after reloading
685
754
  },
686
755
  "consult": {
687
756
  "resources": "project-context"
757
+ },
758
+ "usageRecording": {
759
+ "enabled": false
688
760
  }
689
761
  }
690
762
  ```
@@ -693,23 +765,25 @@ The settings UI patches the raw JSON atomically and preserves unknown fields.
693
765
  It refuses to overwrite malformed or invalid settings.
694
766
  Supported Pi writers serialize the latest-document read and same-directory temporary-file rename through `pi-subagents.json.mutation-lock`.
695
767
  Editors and older extension versions do not participate in that lock, so avoid manual edits while a settings save is in progress.
696
- `blocking.enabled` defaults to `true`, so **All delegation methods** remains the compatibility default.
697
- Set it to `false` for the recommended async-only workflow.
768
+ `blocking.enabled` defaults to `true`, so **Background plus compatibility methods (async + sync)** remains the compatibility default even though `subagent` is deprecated for new work.
769
+ Set it to `false` for the **Keep Pi available (async)** workflow.
698
770
  `blocking.maxParallelTasks` defaults to `8` and accepts positive integers from `1` through `64`.
699
771
  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.
700
772
  `stateful.enabled` also defaults to `true`; its existing `false` value remains the blocking-only workflow.
701
773
  The detached defaults are `maxAgents: 16`, `maxActiveTurns: 4`, `maxChildrenPerAgent: 8`, `maxDepth: 3`, and `maxStoredAgents: 50`.
702
774
  `maxDepth` accepts zero or a positive safe integer, while the other four detached limits accept positive safe integers.
703
- Use `/subagents` → **Advanced settings** → **Detached agent limits** to edit them without replacing unknown JSON fields.
775
+ Use `/subagents settings` → **Advanced runtime settings** → **Background agent limits** to edit them without replacing unknown JSON fields.
704
776
  The screen shows current-session and configured values separately because changes apply after `/reload`.
705
777
  It never reloads automatically, because reload can interrupt retained detached work.
706
778
  Lowering retained, depth, or stored capacity shows a projected recovery warning when current records would be omitted.
707
779
  Restored parents that already exceed a lowered `maxChildrenPerAgent` remain available, but they cannot gain another child until they fall below the configured limit.
708
780
  `cwdPolicy.consultation` defaults to `"anywhere"`, `cwdPolicy.delegation` defaults to `"trusted-targets"`, and `consult.resources` defaults to `"project-context"`.
709
- The Settings UI applies a saved change immediately to subsequent launches and refreshes the affected tool descriptions; manual edits take effect on session start or `/reload`.
781
+ 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`.
710
782
  The UI explicitly states that target/trust settings are not filesystem sandboxing and directs trust changes to Pi `/trust`.
711
- When stateful tools are enabled, their membership stays fixed across spawn, completion, interrupt, close, and mailbox transitions.
712
- This avoids lifecycle-driven tool-schema churn and preserves a stable provider prompt prefix for KV caching.
783
+ When stateful tools are enabled, their membership and provider-visible definitions stay fixed across spawn, completion, interrupt, close, mailbox, catalog, and live-policy transitions.
784
+ Ordinary turns preserve the normalized provider-visible prefix, while a new guidance message or required-completion transition starts an explicit append-only prefix epoch.
785
+ 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.
786
+ These rules preserve cache-eligible prefixes but do not guarantee a provider-reported cache hit.
713
787
 
714
788
  | Tool | Purpose |
715
789
  | --- | --- |
@@ -737,7 +811,7 @@ For example:
737
811
  }
738
812
  ```
739
813
 
740
- Use the **Current agents** action in `/subagents` to inspect the indented agent tree, lifecycle state, unread count, and available actions, or to confirm clearing retained agents.
814
+ Use **Current subagents** in `/subagents` to inspect the indented agent tree, lifecycle state, unread count, and current task summary, or to confirm clearing subagents saved for follow-up.
741
815
  Active turns are FIFO-limited by `maxActiveTurns`; excess retained work remains in `starting` state until a slot is available.
742
816
  `maxAgents` separately bounds running, queued, and idle records.
743
817
  `maxChildrenPerAgent` bounds direct children, while `maxDepth` counts nested levels below a depth-zero root.
@@ -939,8 +1013,8 @@ Users who need shell-assisted read-mostly work can define a custom agent, but `b
939
1013
 
940
1014
  ## ⚙️ Configure agent tools
941
1015
 
942
- Open `/subagents`, choose **Advanced settings**, then **Agent tool permissions** in an interactive Pi session to edit the tools each subagent may use.
943
- Choose **Performance and execution** **Agent execution defaults** to edit provider-neutral inherited model patterns, thinking levels, and timeouts without changing tools.
1016
+ Open `/subagents settings`, choose **Agent defaults**, then **Tool permissions** in an interactive Pi session to edit the tools each subagent may use.
1017
+ Choose **Model, thinking, and time limit** to edit provider-neutral model patterns, thinking levels, and time limits without changing tools.
944
1018
  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.
945
1019
  In TUI mode, type to fuzzy-search tool names and availability metadata; Save and Discard remain pinned below the matches.
946
1020
  These are user settings stored in `~/.pi/agent/pi-subagents.json` and affect future sessions.
@@ -997,12 +1071,13 @@ An omitted field keeps the agent's default tools; blank, `null`, or `[]` explici
997
1071
  `capabilityManifest` is optional for legacy custom agents and never grants authority by itself.
998
1072
  Explicit workflow routing can match declared capabilities, configured tools, filesystem authority, verification roles, and low/medium/high cost or latency hints.
999
1073
  A missing or malformed manifest remains unknown and cannot satisfy a capability-routed task.
1000
- The parent-facing catalog exposes contract-relevant declarations before the first delegation decision.
1074
+ The parent-facing session-guidance message exposes contract-relevant catalog declarations before the first delegation decision.
1001
1075
  Use those identifiers exactly; enforced `readPaths`, `writePaths`, network, and secret guarantees are currently unsupported and require an external enforcement boundary.
1076
+ 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.
1002
1077
 
1003
1078
  `agentScope` is a top-level tool argument supplied per invocation.
1004
1079
  It is not a setting in `~/.pi/agent/pi-subagents.json` and does not belong in agent frontmatter.
1005
- The parent-facing tool metadata discovers these definitions after session start and labels their source and required scope.
1080
+ The parent-facing session-guidance contract discovers these definitions after session start and labels their source and required scope.
1006
1081
  Edit agent files and run `/reload` (or start a new session) to refresh the catalog; there is no live filesystem watcher.
1007
1082
  The scope selects which custom agent directories are loaded; built-in agents remain available in every scope:
1008
1083
 
@@ -1012,7 +1087,7 @@ The scope selects which custom agent directories are loaded; built-in agents rem
1012
1087
  | `"project"` | Project-local agents only. |
1013
1088
  | `"both"` | User and project-local agents. Project definitions override same-named user definitions. |
1014
1089
 
1015
- For example, invoke a project-local agent with the blocking `subagent` tool:
1090
+ For an existing compatibility caller, invoke a project-local agent with the deprecated blocking `subagent` tool:
1016
1091
 
1017
1092
  ```json
1018
1093
  {
@@ -1043,7 +1118,7 @@ Passing `confirmProjectAgents: false` as another top-level tool argument skips t
1043
1118
 
1044
1119
  Every turn can combine main-agent-selected wall-clock, idle, assistant-turn, and tool-call budgets with an extension-owned hard-bounded finalization deadline.
1045
1120
 
1046
- - Set `blocking.maxParallelTasks` in `~/.pi/agent/pi-subagents.json`, or use `/subagents` → **Advanced settings** → **Maximum parallel workers**, to allow 1 through 64 worker tasks in one blocking parallel call.
1121
+ - Set `blocking.maxParallelTasks` in `~/.pi/agent/pi-subagents.json`, or use `/subagents settings` → **Advanced runtime settings** → **Blocking worker limit**, to allow 1 through 64 worker tasks in one blocking parallel call.
1047
1122
  - The worker-count limit defaults to 8 and does not change the fixed four-at-a-time execution concurrency.
1048
1123
  - Set `timeoutMs` on the top-level blocking call to apply a work deadline to all jobs.
1049
1124
  - Set `timeoutMs` on a task, chain step, or aggregator to override it locally.
@@ -1051,6 +1126,7 @@ Every turn can combine main-agent-selected wall-clock, idle, assistant-turn, and
1051
1126
  Bounded process-cleanup grace may follow the deadline.
1052
1127
  - Set `idleTimeoutMs` to stop a turn that has produced no completed assistant turn or tool result within that interval.
1053
1128
  - Set `maxTurns` or `maxToolCalls` to stop unfinished repeated work; a terminal answer at the exact turn limit remains successful.
1129
+ - 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.
1054
1130
  - Set spawn budgets as retained defaults, or the same fields on `subagent_send` to override one follow-up turn.
1055
1131
  - Top-level blocking turn budgets apply to every job, while a task, chain step, or aggregator can override them locally.
1056
1132
  - Choose the shortest realistic budgets for the task difficulty; split an oversized task instead of extending limits merely to compensate for broad scope.
@@ -1091,6 +1167,10 @@ Fresh subprocess summaries run with no tools or project resources.
1091
1167
  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.
1092
1168
  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.
1093
1169
  The deterministic checkpoint remains available when finalization or the provider fails, and results retain exit `124` plus a structured termination reason and finalization status.
1170
+ 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.
1171
+ Malformed required structured output, empty or failed finalization, and transport failure remain non-success.
1172
+ Partial evidence never satisfies mutating acceptance, required evidence, or independent verification.
1173
+ Inspection and opt-in content-free telemetry distinguish runtime-owned omitted limits from explicit per-turn limits.
1094
1174
  Explicit parent or user abort stops immediately, never starts finalization, and is not mislabeled as a budget stop.
1095
1175
 
1096
1176
  This release does not claim a cooperative soft-wrap-up phase because print-mode subprocess children cannot receive steering while they are running.
@@ -1121,6 +1201,24 @@ Subprocess and in-process timing fields use the nearest public lifecycle boundar
1121
1201
  Timing and progress are current-session diagnostics and are not persisted.
1122
1202
  The benchmark measures transport overhead rather than model latency or output quality.
1123
1203
 
1204
+ Preview the paired quality benchmark without making provider requests:
1205
+
1206
+ ```bash
1207
+ just benchmark-async-subagents --model provider/model
1208
+ ```
1209
+
1210
+ Run three paired trials with isolated sync-only and async-only tool surfaces, fixed model and thinking settings, redacted raw records, and a hard per-trial deadline:
1211
+
1212
+ ```bash
1213
+ just benchmark-async-subagents --run --mode quick --model provider/model --output /tmp/subagent-quick.json
1214
+ ```
1215
+
1216
+ Use `--mode extended` for ten paired trials before any further sync deprecation decision.
1217
+ 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.
1218
+ Quick mode targets completion within five minutes under normal provider capacity but reports external timeouts and entitlement failures rather than silently reducing the sample.
1219
+ Live results remain provider- and model-dependent evidence rather than deterministic CI or proof of causality.
1220
+ The synchronous `subagent` tool remains available whenever a quality gate fails or detached chain, fan-in, panel, or workflow compatibility is unmatched.
1221
+
1124
1222
  While the `subagent` tool is running, `pi-subagents` publishes compact activity status with `ctx.ui.setStatus("subagents", "...")`.
1125
1223
  Any statusline extension that reads Pi's generic extension status API can display it; no package-to-package dependency is required.
1126
1224
 
@@ -1153,13 +1251,17 @@ Snapshots hash agent manifests, prompts, effective tools, model/thinking, transp
1153
1251
  A non-Git target has no stable repository generation proof, so each later follow-up requires explicit revalidation.
1154
1252
  Count projection keeps complete ancestor chains together when stored or restored limits omit older trees.
1155
1253
  Retention and count limits are configurable.
1156
- Downgrading is safe: older extension versions ignore this separate state directory; clear **Current agents** from `/subagents` before downgrade if the histories should be removed.
1254
+ Downgrading is safe: older extension versions ignore this separate state directory; clear **Current subagents** from `/subagents` before downgrade if the histories should be removed.
1157
1255
 
1158
1256
  ## 🗂️ Package layout
1159
1257
 
1160
1258
  ```txt
1161
1259
  packages/pi-subagents/
1162
1260
  ├── dist/ # Generated split TypeScript runtime loaded through Pi's Jiti loader
1261
+ ├── docs/
1262
+ │ ├── async-runtime-protocol.md # Required-run state machine and unavailable core guarantees
1263
+ │ ├── implementation-notes/ # Current direction, capabilities, and RPC contract
1264
+ │ └── pi-subagents-diagrams.md # Maintained architecture and workflow diagrams
1163
1265
  ├── scripts/
1164
1266
  │ └── build-runtime.mjs # Deterministic bundler and eager-boundary validator
1165
1267
  ├── src/
@@ -1185,7 +1287,11 @@ packages/pi-subagents/
1185
1287
  │ ├── rpc-turn-capture.ts # RPC evidence capture, usage, and budget events
1186
1288
  │ ├── auto-transport.ts # Deterministic preflight transport routing
1187
1289
  │ ├── transport-types.ts # Bounded pi-subagents:v1 progress and telemetry contract
1290
+ │ ├── usage-recording.ts # Opt-in content-free event collection and local identities
1291
+ │ ├── usage-recording-store.ts # Private per-runtime JSONL writers and retention pruning
1188
1292
  │ ├── completion-delivery.ts # Top-level completion batching and optional idle-root wake
1293
+ │ ├── session-guidance-contract.ts # Append-only catalog and effective-policy guidance
1294
+ │ ├── completion-requirement.ts # Exact required-run tracking and fixed-boundary fallback
1189
1295
  │ ├── completion-routing.ts # Direct-parent and live-ancestor recipient selection
1190
1296
  │ ├── task-path.ts # Canonical retained-agent task identity and resolution
1191
1297
  │ ├── peer-communication.ts # Session peer routing and authenticated loopback broker
@@ -1203,6 +1309,7 @@ packages/pi-subagents/
1203
1309
  │ ├── verification-harness.ts # Disposable deterministic check execution
1204
1310
  │ ├── verification-receipt.ts # Strict executor-owned managed receipts
1205
1311
  │ ├── verified-execution-benchmark.ts # Matched offline acceptance/cost fixture
1312
+ │ ├── async-subagent-benchmark.ts # Paired live-quality planning, scoring, and summaries
1206
1313
  │ ├── workflow-tree-identity.ts # Bounded exact Git-visible tree identities
1207
1314
  │ ├── integration-controller.ts # Fail-closed canonical integration admission
1208
1315
  │ ├── adaptive-scheduler.ts # Dependency, capacity, budget, and conflict scheduling
@@ -1222,6 +1329,10 @@ packages/pi-subagents/
1222
1329
  │ ├── timeout-finalization.ts # Abort-time bounded summary prompts and deadlines
1223
1330
  │ ├── timeout-checkpoint.ts # Redacted deterministic termination evidence
1224
1331
  │ ├── turn-budget.ts # Idle, assistant-turn, and tool-call enforcement
1332
+ │ ├── runner.ts # Blocking subprocess execution and progress capture
1333
+ │ ├── runner-types.ts # Shared subprocess result and launch contracts
1334
+ │ ├── subagent-details.ts # Composed tool-result and panel detail contracts
1335
+ │ ├── process-control.ts # Reusable child-process termination and escalation
1225
1336
  │ ├── runner-usage.ts # Bounded subprocess usage accumulation
1226
1337
  │ ├── runner-result.ts # Shared subprocess result interpretation
1227
1338
  │ ├── stateful-limit-ui.ts # Detached capacity settings and recovery previews
@@ -1239,8 +1350,8 @@ packages/pi-subagents/
1239
1350
  The package build bundles that source graph into split `.ts` files under `dist` for Pi's Jiti loader.
1240
1351
  `subagents.ts` and `stateful.ts` preserve existing source-level utility imports without making those utility graphs part of Pi startup.
1241
1352
  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.
1242
- Existing `stateful.enabled: false` files expose blocking delegation plus inspection/consultation.
1243
- Older package releases ignore and preserve the optional `blocking.maxParallelTasks`, `consult`, and `cwdPolicy` fields.
1353
+ Existing `stateful.enabled: false` files expose deprecated blocking `subagent` plus supported inspection and consultation.
1354
+ Older package releases ignore and preserve the optional `blocking.maxParallelTasks`, `consult`, `cwdPolicy`, and `usageRecording` fields.
1244
1355
  The package exposes its Pi extension through `package.json`:
1245
1356
 
1246
1357
  ```json
@@ -2,14 +2,14 @@
2
2
  // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
3
3
  import {
4
4
  isWriteCapable
5
- } from "./chunk-O4VO6JUJ.ts";
5
+ } from "./chunk-TM2R67J3.ts";
6
6
  import {
7
7
  discoverAgents
8
- } from "./chunk-PSK43Y6A.ts";
8
+ } from "./chunk-LASD73CM.ts";
9
9
  import "./chunk-RSUXZD6S.ts";
10
- import "./chunk-QBORTI4W.ts";
11
- import "./chunk-7OBINKFM.ts";
12
- import "./chunk-DPPVEQAM.ts";
10
+ import "./chunk-TMZRHIIK.ts";
11
+ import "./chunk-VDG7LTYE.ts";
12
+ import "./chunk-4AQSF7AS.ts";
13
13
  import "./chunk-SWGQLFSD.ts";
14
14
  import "./chunk-H3FP6DLR.ts";
15
15
 
@@ -106,4 +106,4 @@ var AutoTransport = class {
106
106
  export {
107
107
  AutoTransport
108
108
  };
109
- //# sourceMappingURL=auto-transport-SY2VHUFH.ts.map
109
+ //# sourceMappingURL=auto-transport-FUUKFDIG.ts.map
@@ -6,9 +6,9 @@ import {
6
6
  isCapabilityGrantActive,
7
7
  issueCapabilityGrant,
8
8
  revokeCapabilityGrant
9
- } from "./chunk-HKC4ES4B.ts";
10
- import "./chunk-DSOOH73Y.ts";
11
- import "./chunk-DPPVEQAM.ts";
9
+ } from "./chunk-YPJEN6NU.ts";
10
+ import "./chunk-7AAJEUSL.ts";
11
+ import "./chunk-4AQSF7AS.ts";
12
12
  export {
13
13
  CAPABILITY_GRANT_VERSION,
14
14
  isCapabilityGrant,
@@ -16,4 +16,4 @@ export {
16
16
  issueCapabilityGrant,
17
17
  revokeCapabilityGrant
18
18
  };
19
- //# sourceMappingURL=capability-grant-CGEWOEKE.ts.map
19
+ //# sourceMappingURL=capability-grant-PR72SWWS.ts.map