pi-subagents 0.66.0 → 0.68.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.
Files changed (172) hide show
  1. package/CHANGELOG.md +138 -0
  2. package/README.md +5 -4
  3. package/agents/evidence-auditor.md +34 -0
  4. package/agents/reviewer.md +3 -2
  5. package/docs/agents.md +43 -15
  6. package/docs/configuration.md +67 -23
  7. package/docs/extension-api.md +38 -19
  8. package/docs/missions.md +10 -2
  9. package/docs/models.md +11 -79
  10. package/docs/observability.md +22 -12
  11. package/docs/standalone-background.md +59 -0
  12. package/docs/tool-reference.md +33 -20
  13. package/docs/watchdog.md +39 -10
  14. package/docs/workflows.md +37 -13
  15. package/index.ts +5 -2
  16. package/inspector-runner.mjs +2 -2
  17. package/package.json +4 -2
  18. package/prompts/parallel-review.md +1 -1
  19. package/runner-peer-loader.mjs +24 -0
  20. package/runner-peer-preload.mjs +32 -0
  21. package/skills/pi-subagents/SKILL.md +32 -21
  22. package/skills/pi-subagents/references/constraints-and-recipes.md +3 -2
  23. package/skills/pi-subagents/references/execution-controls.md +11 -9
  24. package/skills/pi-subagents/references/management-authoring-rpc.md +0 -1
  25. package/skills/pi-subagents/references/multi-lane-orchestration.md +1 -1
  26. package/skills/pi-subagents/references/prompting-and-roles.md +17 -13
  27. package/skills/pi-subagents/references/review-and-validation.md +3 -3
  28. package/src/agents/advertised-agent-prompt.ts +34 -3
  29. package/src/agents/agent-management.ts +57 -58
  30. package/src/agents/agent-serializer.ts +4 -3
  31. package/src/agents/agents.ts +190 -71
  32. package/src/agents/builtin-names.ts +1 -0
  33. package/src/agents/chain-serializer.ts +5 -0
  34. package/src/agents/runtime-agent-registry.ts +7 -6
  35. package/src/api/delegation.ts +4 -0
  36. package/src/api/preflight.ts +94 -59
  37. package/src/api/required-child-extensions.ts +6 -0
  38. package/src/api/shared-types.ts +2 -0
  39. package/src/extension/config.ts +10 -37
  40. package/src/extension/fanout-child.ts +66 -4
  41. package/src/extension/herdr-pi-bridge.ts +160 -0
  42. package/src/extension/index.ts +62 -39
  43. package/src/extension/public-execution.ts +7 -5
  44. package/src/extension/rpc.ts +4 -0
  45. package/src/extension/schemas.ts +81 -81
  46. package/src/extension/tool-description.ts +30 -82
  47. package/src/inspectors/actions.ts +148 -0
  48. package/src/inspectors/ghostty/actions.ts +74 -0
  49. package/src/inspectors/ghostty/plugin.ts +17 -0
  50. package/src/inspectors/herdr/actions.ts +99 -179
  51. package/src/inspectors/herdr/plugin.ts +20 -0
  52. package/src/inspectors/herdr/project-panes.ts +1 -1
  53. package/src/inspectors/{herdr/inspector-runner.ts → inspector-runner.ts} +12 -12
  54. package/src/inspectors/plugins.ts +8 -0
  55. package/src/inspectors/{herdr/session-roots-codec.ts → session-roots-codec.ts} +3 -14
  56. package/src/inspectors/types.ts +51 -0
  57. package/src/intercom/intercom-bridge.ts +50 -8
  58. package/src/intercom/native-supervisor-channel.ts +44 -31
  59. package/src/policy/authority.ts +4 -0
  60. package/src/profiles/profiles.ts +12 -6
  61. package/src/runs/background/active-async-capacity.ts +4 -0
  62. package/src/runs/background/active-run-index.ts +17 -1
  63. package/src/runs/background/async-execution.ts +348 -176
  64. package/src/runs/background/async-job-tracker.ts +8 -6
  65. package/src/runs/background/async-resume.ts +17 -12
  66. package/src/runs/background/async-status.ts +15 -4
  67. package/src/runs/background/auto-drain.ts +23 -10
  68. package/src/runs/background/binary-bootstrap.ts +38 -0
  69. package/src/runs/background/chain-append.ts +1 -1
  70. package/src/runs/background/chain-root-attachment.ts +14 -33
  71. package/src/runs/background/fleet-view.ts +30 -2
  72. package/src/runs/background/notify.ts +105 -7
  73. package/src/runs/background/owned-process-tree.ts +29 -2
  74. package/src/runs/background/result-files.ts +8 -4
  75. package/src/runs/background/result-watcher.ts +19 -2
  76. package/src/runs/background/run-child-session.ts +81 -33
  77. package/src/runs/background/run-status.ts +3 -0
  78. package/src/runs/background/runner-aliases.ts +12 -33
  79. package/src/runs/background/runner-child-launch.ts +6 -1
  80. package/src/runs/background/runner-child-sessions.ts +5 -4
  81. package/src/runs/background/runner-http-dispatcher.ts +119 -0
  82. package/src/runs/background/scheduled-runs.ts +51 -18
  83. package/src/runs/background/stale-run-reconciler.ts +35 -11
  84. package/src/runs/background/steering.ts +20 -2
  85. package/src/runs/background/subagent-runner.ts +441 -304
  86. package/src/runs/background/subagent-wait.ts +176 -28
  87. package/src/runs/background/wait-completions.ts +75 -27
  88. package/src/runs/background/wait-subscriptions.ts +9 -3
  89. package/src/runs/background/wait-tool.ts +5 -3
  90. package/src/runs/foreground/async-steering-action.ts +18 -7
  91. package/src/runs/foreground/async-stop-action.ts +93 -3
  92. package/src/runs/foreground/execution.ts +134 -248
  93. package/src/runs/foreground/foreground-history.ts +2 -1
  94. package/src/runs/foreground/prompt-audit.ts +3 -1
  95. package/src/runs/foreground/subagent-executor.ts +374 -178
  96. package/src/runs/foreground/workflow-detach-reconcile.ts +2 -0
  97. package/src/runs/foreground/workflow-foreground-steering.ts +2 -1
  98. package/src/runs/shared/acceptance.ts +38 -11
  99. package/src/runs/shared/async-status-projection.ts +127 -33
  100. package/src/runs/shared/capability-ceiling.ts +2 -0
  101. package/src/runs/shared/child-hooks.ts +25 -10
  102. package/src/runs/shared/child-launch-plan.ts +15 -3
  103. package/src/runs/shared/child-launch.ts +28 -5
  104. package/src/runs/shared/child-lifecycle.ts +6 -3
  105. package/src/runs/shared/child-runtime-config.ts +8 -1
  106. package/src/runs/shared/child-session.ts +127 -52
  107. package/src/runs/shared/child-tool-plan.ts +142 -11
  108. package/src/runs/shared/completion-guard.ts +5 -3
  109. package/src/runs/shared/dynamic-fanout.ts +2 -2
  110. package/src/runs/shared/effective-system-prompt.ts +33 -0
  111. package/src/runs/shared/external-cli-contract.ts +11 -1
  112. package/src/runs/shared/external-cli-preflight.ts +6 -2
  113. package/src/runs/shared/external-cli-runner.ts +9 -7
  114. package/src/runs/shared/herdr-connection.ts +134 -0
  115. package/src/runs/shared/herdr-external-adapters.ts +169 -0
  116. package/src/runs/shared/herdr-machine.ts +279 -0
  117. package/src/runs/shared/herdr-pi-protocol.ts +59 -0
  118. package/src/runs/shared/herdr-placed-run.ts +263 -0
  119. package/src/runs/shared/llm-intent-arbiter.ts +12 -3
  120. package/src/runs/shared/model-resolution-diagnostic.ts +76 -0
  121. package/src/runs/shared/{model-fallback.ts → model-resolution.ts} +22 -235
  122. package/src/runs/shared/model-scope.ts +1 -1
  123. package/src/runs/shared/nested-events.ts +11 -2
  124. package/src/runs/shared/orca-progress-tabs.ts +1 -1
  125. package/src/runs/shared/parallel-utils.ts +7 -2
  126. package/src/runs/shared/pi-spawn.ts +10 -0
  127. package/src/runs/shared/subagent-prompt-runtime.ts +12 -4
  128. package/src/runs/shared/task-intent.ts +46 -13
  129. package/src/runs/shared/workflow-async-child-guidance.ts +18 -0
  130. package/src/runs/shared/worktree-setup-command.ts +27 -4
  131. package/src/runs/shared/worktree.ts +45 -15
  132. package/src/shared/child-cache-retention.ts +43 -0
  133. package/src/shared/fork-context.ts +15 -72
  134. package/src/shared/launch-contract.ts +68 -8
  135. package/src/shared/opencode-session-headers.ts +30 -0
  136. package/src/shared/pruned-fork.ts +1 -1
  137. package/src/shared/required-child-extensions.ts +81 -0
  138. package/src/shared/settings.ts +5 -2
  139. package/src/shared/shortcuts.ts +0 -4
  140. package/src/shared/types.ts +74 -30
  141. package/src/slash/delegation-adapters.ts +3 -1
  142. package/src/slash/delegation-request.ts +14 -0
  143. package/src/slash/slash-commands.ts +2 -7
  144. package/src/slash/subagents-admin.ts +24 -13
  145. package/src/tui/fleet-status.ts +164 -19
  146. package/src/tui/fleet.ts +16 -14
  147. package/src/tui/render.ts +168 -37
  148. package/src/watchdog/child-status.ts +28 -28
  149. package/src/watchdog/lsp-diagnostics.ts +1 -1
  150. package/src/watchdog/model-selection.ts +21 -1
  151. package/src/watchdog/permission-arbiter.ts +3 -1
  152. package/src/watchdog/register-child.ts +10 -2
  153. package/src/watchdog/register-main.ts +39 -35
  154. package/src/watchdog/render.ts +1 -1
  155. package/src/watchdog/review.ts +123 -74
  156. package/src/watchdog/rules.ts +1 -1
  157. package/src/watchdog/runtime.ts +100 -27
  158. package/src/watchdog/scope.ts +1 -1
  159. package/src/watchdog/settings.ts +3 -0
  160. package/src/watchdog/tool-actions.ts +13 -12
  161. package/src/watchdog/turn-delta.ts +23 -0
  162. package/src/watchdog/types.ts +5 -3
  163. package/src/watchdog/warning-format.ts +1 -1
  164. package/src/workflows/scripted-workflow.ts +279 -10
  165. package/src/workflows/workflow-checklist.ts +2 -2
  166. package/src/workflows/workflow-receipt.ts +21 -3
  167. package/src/workflows/workflow-resources.ts +13 -2
  168. package/runner-server-preload.mjs +0 -13
  169. package/src/runs/shared/model-exclusions.ts +0 -374
  170. package/src/runs/shared/readonly-model-continuation.ts +0 -69
  171. package/src/runs/shared/readonly-session-evidence.ts +0 -307
  172. /package/src/inspectors/{herdr/shell-command.ts → shell-command.ts} +0 -0
package/docs/workflows.md CHANGED
@@ -25,7 +25,7 @@ A failure in the subagent workflow, child launch, prompt runtime, extension load
25
25
 
26
26
  Stop and report the exact failure, run/status, and repository/cwd/worktree/branch/ref state. Before a same-protocol retry or asking the owner, verify the worktree is clean or capture the partial diff. Retry or fix the `subagent` path only through a clear same-protocol action. For backlog lanes and other subagent-governed workflows, external/foreground/CLI fallback requires explicit owner approval. `interactive_shell` remains valid when the user explicitly requests visible foreground/CLI work or the task is outside the governed subagent protocol.
27
27
 
28
- Pi core may print a generic `pi -ne` extension-load hint; that out-of-repo hint is not protocol-approved fallback. Configured native model/provider fallback remains governed by its own contract and does not authorize an execution-mode switch.
28
+ Pi core may print a generic `pi -ne` extension-load hint; that out-of-repo hint is not protocol-approved fallback. A verified compaction abort may continue the retained child once on its already resolved model; it does not authorize an execution-mode or model switch.
29
29
 
30
30
  ## Prompt shortcuts
31
31
 
@@ -45,6 +45,10 @@ Add `autofix` to `/parallel-review` or `/parallel-cleanup` to apply only the syn
45
45
 
46
46
  Use direct `{ agent, task }` for one bounded child. Use `workflowScript` when the parent needs a stable keyed child, sequence, fanout, steering, retry, or aggregation. For ordinary parallel fanout, use `await runs.all([{ key, agent, task }, ...])`. It resolves to an ordered array, not a key map, so use indexes, destructuring, or `.map(...)`, not `results.<key>`. Do not read `.output` from unawaited `runs.run` launches. Store a `runs.run` promise only when the script later observes it with `await`, `Promise.race`, or `Promise.all`, such as steering a live child before awaiting its result. Scripts are ordinary JavaScript statement bodies. Use an explicit `return` for a useful result:
47
47
 
48
+ For multi-step or parallel work, make exactly one top-level `subagent` workflow call with `async:true` and launch children only inside it. Read this guide for recipes rather than constructing a second top-level orchestration. Available sandbox helpers include `runs.run`, `runs.all`, `runs.lanes`, `runs.steer`, `runs.status`, `runs.ref`/`runs.refs`, `emit`, `console`, standard JavaScript, and mission `state` when enabled. No filesystem, shell, arbitrary Pi tools, or host globals are available; named resources alone may grant `runs.host` authority.
49
+
50
+ Workflow-level child controls default onto each `runs.run`/`runs.all` launch; explicit child fields override them. See [retained children](tool-reference.md#retained-children) for follow-up challenges, [output binding](tool-reference.md#output-mode-details) for durable artifacts, and [schedules](missions.md#schedules) for delayed/recurring scripts.
51
+
48
52
  Child results cross into the script as plain JSON data. Non-JSON host metadata is omitted, so use returned fields such as `runId`, `ok`, `output`, and `structuredOutput` for workflow control.
49
53
 
50
54
  Validate a script without launching children:
@@ -65,6 +69,16 @@ subagent({ action: "validate", workflowScriptPath: "workflows/review.js" });
65
69
 
66
70
  The fields are mutually exclusive. Relative paths resolve against the request `cwd`; absolute paths pass through. The host reads the file before validation, schedule creation, or workflow sandbox execution. The sandbox still has no filesystem access. Missing, unreadable, and empty files return file input errors instead of script syntax errors.
67
71
 
72
+ Inline and file-backed scripts accept bounded plain-JSON `args`:
73
+
74
+ ```js
75
+ subagent({ workflowScriptPath: "workflows/review.js", args: { target: "src/workflows" } });
76
+ // workflows/review.js
77
+ return runs.run("review", { agent: "reviewer", task: `Review ${args.target}` });
78
+ ```
79
+
80
+ Omitted arguments are an empty object. The `args` object, its nested objects, and its arrays are frozen in the sandbox. Arguments are data only: they do not grant `runs.host` or other authority. Normalized arguments are persisted with workflow and schedule evidence for replay and diagnosis, so do not put secrets in them. Routine status text does not render argument values.
81
+
68
82
  ### Named workflow resources for permission extensions
69
83
 
70
84
  Use a named workflow resource when a permission or policy extension needs to distinguish extension-resolved workflow content from raw model-authored scripts:
@@ -104,10 +118,10 @@ The result is `{ ok, errors }`. Invalid scripts return a tool error and include
104
118
 
105
119
  ```js
106
120
  subagent({ workflowScript: `
107
- const scan = await runs.run("scan", { agent: "scout", task: "Scan the codebase" });
121
+ const scan = await runs.run("scan", { label: "Map codebase behavior", agent: "scout", task: "Scan the codebase" });
108
122
  const reviews = await runs.all([
109
- { key: "correctness", agent: "reviewer", task: "Review correctness: " + scan.output },
110
- { key: "tests", agent: "reviewer", task: "Review tests: " + scan.output }
123
+ { key: "correctness", label: "Review codebase correctness", agent: "reviewer", task: "Review correctness: " + scan.output },
124
+ { key: "tests", label: "Review test coverage", agent: "reviewer", task: "Review tests: " + scan.output }
111
125
  ]);
112
126
  return reviews.map(result => result.output);
113
127
  ` });
@@ -118,7 +132,7 @@ Keep helper functions portable across Node and Bun. Use top-level `await`, plain
118
132
  ```js
119
133
  subagent({ workflowScript: `
120
134
  function scan() {
121
- return runs.run("scan", { agent: "scout", task: "Scan the codebase" });
135
+ return runs.run("scan", { label: "Map codebase behavior", agent: "scout", task: "Scan the codebase" });
122
136
  }
123
137
  const result = await scan();
124
138
  return result.output;
@@ -129,8 +143,8 @@ Chaining is still supported. The supported form is scripted chaining: await one
129
143
 
130
144
  ```js
131
145
  subagent({ workflowScript: `
132
- const plan = await runs.run("plan", { agent: "scout", task: "Plan the migration" });
133
- const patch = await runs.run("patch", { agent: "worker", task: "Implement this plan:\n" + plan.output });
146
+ const plan = await runs.run("plan", { label: "Plan migration behavior", agent: "scout", task: "Plan the migration" });
147
+ const patch = await runs.run("patch", { label: "Implement migration behavior", agent: "worker", task: "Implement this plan:\n" + plan.output });
134
148
  return patch.output;
135
149
  ` });
136
150
  ```
@@ -145,16 +159,16 @@ subagent({ workflowScript: `
145
159
  {
146
160
  key: "api",
147
161
  stages: [
148
- { key: "writer", agent: "worker", task: "Implement the API change" },
149
- { key: "challenge", resume: "previous", task: "Challenge the API implementation" },
150
- { key: "review", agent: "reviewer", task: "Review the API lane" }
162
+ { key: "writer", label: "Implement API behavior", agent: "worker", task: "Implement the API change" },
163
+ { key: "challenge", label: "Challenge API behavior", resume: "previous", task: "Challenge the API implementation" },
164
+ { key: "review", label: "Review API behavior", agent: "reviewer", task: "Review the API lane" }
151
165
  ]
152
166
  },
153
167
  {
154
168
  key: "ui",
155
169
  stages: [
156
- { key: "writer", agent: "worker", task: "Implement the UI change" },
157
- { key: "review", agent: "reviewer", task: "Review the UI lane" }
170
+ { key: "writer", label: "Implement UI behavior", agent: "worker", task: "Implement the UI change" },
171
+ { key: "review", label: "Review UI behavior", agent: "reviewer", task: "Review the UI lane" }
158
172
  ]
159
173
  }
160
174
  ]);
@@ -203,7 +217,7 @@ subagent({ workflowScript: `
203
217
  ` });
204
218
  ```
205
219
 
206
- The receipt state is `queued`, `delivered`, `missed`, or `failed`. `delivered` means the child Pi session accepted the input. It does not mean the model followed it. `missed` means the keyed child became terminal or had no live route before delivery. This first slice uses the existing foreground and async steering transports but does not start steering recovery. Workflow traces include one steering attempt entry and one receipt entry.
220
+ The receipt state is `queued`, `delivered`, `missed`, or `failed`. For an async child, `delivered` means it consumed the correlated user input; for a foreground child, it means the in-process Pi transport accepted the input. It does not mean the model followed it. `missed` means the keyed child became terminal or had no live route before delivery. This first slice uses the existing foreground and async steering transports but does not start steering recovery. Workflow traces include one steering attempt entry and one receipt entry.
207
221
 
208
222
  Always await or return a `runs.steer` promise. The workflow waits for an observed steering side effect to settle before it exits and rejects fire-and-forget calls. Use ordinary `Promise.race` when the first child or steering receipt should advance the script. There is no callback API or child inbox access.
209
223
 
@@ -380,6 +394,8 @@ Each child uses the existing worktree lifecycle: it branches from clean HEAD, jo
380
394
 
381
395
  A top-level `{ workflowScript, worktree: true }` makes isolation the default for every workflow child. An individual child can override that default with `worktree: false`. Keep one writer when parallel writes are not intentionally isolated.
382
396
 
397
+ Before a materialized `runs.run` or `runs.all` group dispatches fresh children, isolated sources must be Git repositories with clean working trees (excluding `.pi/subagents/` runtime state). A rejected group dispatches no children and spends no fan-out slots or child output claims; key-level failure traces can remain. Checks are shared only within that group, are cancellable, and run again at allocation because sources can change. Retained resumes keep their stored contracts. Select the correct cwd or arrange an operator-approved commit/stash; isolation is never dropped automatically.
398
+
383
399
  Use `baseRef` to branch managed worktrees from `HEAD` or a supported named ref such as `refs/heads/release`, `refs/tags/v1`, or `origin/main`. Full 40/64-character commit IDs and revision expressions such as `HEAD~1` are unsupported. For example, `{ workflowScript, worktree: true, baseRef: "refs/heads/release" }` applies the release ref to children unless a child supplies its own `baseRef`. If omitted, the default `HEAD` is resolved at worktree allocation, not when the script is validated or a schedule is created. The source checkout must still be clean, and the ref must resolve to a commit before any worktree is allocated.
384
400
 
385
401
  Configure the worktree provider, native path layout, base directory, and setup hook in [configuration.md](configuration.md).
@@ -439,6 +455,14 @@ Children should not ask for clarification when the only conflict is review-only/
439
455
 
440
456
  The parent replies with `subagent_supervisor({ action: "reply", replyTo, message })` or checks pending requests with `subagent_supervisor({ action: "pending" })`. Supervisor messages are scoped to the exact Pi session id that spawned the child. A second Pi session in the same repository does not receive those requests.
441
457
 
458
+ A nested coordinator needs both directions of coordination. If its agent declares an explicit `tools` allowlist, include `subagent_supervisor` to answer its own children, alongside `subagent` for delegation and `contact_supervisor` for asking its parent:
459
+
460
+ ```yaml
461
+ tools: read, subagent, contact_supervisor, subagent_supervisor
462
+ ```
463
+
464
+ For A → B → C, C's request belongs to B, not A. B can escalate a separate question to A with `contact_supervisor`, then answer C using C's original `replyTo` request id. A's reply to B does not resolve C's request, and steering is not a substitute for replying. Only fanout-authorized children get the downward supervisor provider; explicit tool exclusions and capability ceilings still apply, and ordinary leaves do not gain delegation or reply tools. Requesting `subagent_supervisor` without fanout authorization fails at launch with an actionable error. A coordinator that excludes the reply tool does not start downward supervision or receive prompts to use it. Explicitly selected native coordination tools survive host-builtin filtering because their providers are child runtime hooks, not host builtins.
465
+
442
466
  Child-side routine completion handoffs are not expected. If a child appears stalled, needs-attention notices show up in the parent session with useful next actions, such as checking `subagent({ action: "status" })`, interrupting the run, or nudging the child.
443
467
 
444
468
  If a `workflowScript` child detaches through `contact_supervisor`, the enclosing async workflow stays `paused` until that child exits. Then the extension reconciles it to `complete` or `failed`. Wait on the child until that happens.
package/index.ts CHANGED
@@ -1,10 +1,13 @@
1
1
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
2
  import type {} from "./src/types/pi-runtime-compat.d.ts";
3
+ import { HERDR_PI_MODE_ENV } from "./src/runs/shared/herdr-pi-protocol.ts";
3
4
 
4
- const registerParentExtension = process.env.PI_SUBAGENT_CHILD === "1"
5
+ const registerExtension = process.env[HERDR_PI_MODE_ENV] === "1"
6
+ ? (await import("./src/extension/herdr-pi-bridge.ts")).default
7
+ : process.env.PI_SUBAGENT_CHILD === "1"
5
8
  ? undefined
6
9
  : (await import("./src/extension/index.ts")).default;
7
10
 
8
11
  export default function registerSubagentExtension(pi: ExtensionAPI): void {
9
- registerParentExtension?.(pi);
12
+ registerExtension?.(pi);
10
13
  }
@@ -1,11 +1,11 @@
1
1
  import { createJiti } from "jiti";
2
2
 
3
3
  const jiti = createJiti(import.meta.url);
4
- const { runInspector } = await jiti.import("./src/inspectors/herdr/inspector-runner.ts");
4
+ const { runInspector } = await jiti.import("./src/inspectors/inspector-runner.ts");
5
5
 
6
6
  try {
7
7
  runInspector();
8
8
  } catch (cause) {
9
- process.stderr.write(`Herdr inspector failed: ${cause instanceof Error ? cause.message : String(cause)}\n`);
9
+ process.stderr.write(`Inspector failed: ${cause instanceof Error ? cause.message : String(cause)}\n`);
10
10
  process.exitCode = 1;
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-subagents",
3
- "version": "0.66.0",
3
+ "version": "0.68.0",
4
4
  "description": "Pi extension for single-agent delegation and scripted multi-agent workflows",
5
5
  "author": "Nico Bailon",
6
6
  "license": "MIT",
@@ -14,6 +14,7 @@
14
14
  "./delegation": "./src/api/delegation.ts",
15
15
  "./capability-ceiling": "./src/api/capability-ceiling.ts",
16
16
  "./workflow-resources": "./src/api/workflow-resources.ts",
17
+ "./required-child-extensions": "./src/api/required-child-extensions.ts",
17
18
  "./preflight": "./src/api/preflight.ts",
18
19
  "./control-channel": "./src/api/control-channel.ts",
19
20
  "./intercom-bridge": "./src/api/intercom-bridge.ts",
@@ -53,6 +54,8 @@
53
54
  "CHANGELOG.md"
54
55
  ],
55
56
  "scripts": {
57
+ "build:pkg": "node scripts/build-package.mjs",
58
+ "pack:pkg": "npm run build:pkg && npm pack ./dist-pkg",
56
59
  "typecheck": "tsc --noEmit",
57
60
  "test": "npm run test:unit",
58
61
  "test:unit": "node --experimental-strip-types --import ./test/support/isolated-temp-root.mjs --test test/unit/*.test.ts",
@@ -91,7 +94,6 @@
91
94
  }
92
95
  },
93
96
  "dependencies": {
94
- "@earendil-works/pi-server": "0.85.0",
95
97
  "acorn": "8.18.0",
96
98
  "jiti": "2.7.0",
97
99
  "typebox": "1.1.38",
@@ -28,7 +28,7 @@ Choose or adapt angles when the work calls for it:
28
28
 
29
29
  Prefer three strong reviewers over many vague reviewers.
30
30
 
31
- Give every reviewer a specific task prompt naming its angle. Ask reviewers to return concise, evidence-backed findings with file/line references and suggested fixes. Filter on evidence, not severity: a finding must be concrete, current, caused or made reachable by the target diff, and supported by source proof, a test or repro, or a contract contradiction. Label findings P0/P1/P2. P0 blocks merge. P1 should be fixed before release. P2 is report-only. End each review with `Merge verdict: BLOCK`, `Merge verdict: OK`, or `Merge verdict: OK with notes`. If nothing qualifies, ask the reviewer to say exactly `No issues found.` The response should be review feedback, not a context summary. Reviewers must not edit files unless I explicitly ask for a writer pass.
31
+ Give every reviewer a specific task prompt naming its angle. Ask reviewers to return concise, evidence-backed findings with file/line references and suggested fixes. Filter on evidence, not severity: a finding must be concrete and current within the named review target, and supported by source proof, a test or repro, or a contract contradiction. For a diff review, require that the issue is caused or made reachable by that diff. Label findings P0/P1/P2. P0 blocks merge. P1 should be fixed before release. P2 is report-only. End each review with `Merge verdict: BLOCK`, `Merge verdict: OK`, or `Merge verdict: OK with notes`. If nothing qualifies, ask the reviewer to say exactly `No issues found.` The response should be review feedback, not a context summary. Reviewers must not edit files unless I explicitly ask for a writer pass.
32
32
 
33
33
  Do not default first-pass reviews to `blockers only`. That phrase is valid only for final pre-merge re-checks after P1/P2 findings are already inventoried, or for explicit emergency hotfix lanes where non-blocking findings are intentionally deferred.
34
34
 
@@ -0,0 +1,24 @@
1
+ import { pathToFileURL } from "node:url";
2
+
3
+ let aliases = {};
4
+ let nativeRunner = false;
5
+ let compiledRunner = false;
6
+ let packageRootUrl;
7
+ const redirected = new Set([
8
+ "@earendil-works/pi-tui",
9
+ ]);
10
+
11
+ export function initialize(data) {
12
+ aliases = data?.aliases ?? {};
13
+ nativeRunner = data?.nativeRunner === true;
14
+ compiledRunner = data?.compiledRunner === true;
15
+ packageRootUrl = data?.packageRootUrl;
16
+ }
17
+
18
+ export function resolve(specifier, context, nextResolve) {
19
+ const packageImport = typeof packageRootUrl === "string" && context.parentURL?.startsWith(packageRootUrl) === true;
20
+ if (nativeRunner && (!compiledRunner || packageImport) ? aliases[specifier] : redirected.has(specifier) && aliases[specifier]) {
21
+ return nextResolve(pathToFileURL(aliases[specifier]).href, context);
22
+ }
23
+ return nextResolve(specifier, context);
24
+ }
@@ -0,0 +1,32 @@
1
+ import * as nodeModule from "node:module";
2
+ import { pathToFileURL } from "node:url";
3
+
4
+ const aliases = JSON.parse(process.env.JITI_ALIAS ?? "{}");
5
+ const nativeRunner = process.env.PI_ASYNC_NATIVE_RUNNER === "1";
6
+ const compiledRunner = process.env.PI_ASYNC_COMPILED_RUNNER === "1";
7
+ // Pi's jiti loader owns aliases for external extensions; these hooks only supply peers to our compiled package.
8
+ const packageRootUrl = new URL("./", import.meta.url).href;
9
+ const redirected = new Set([
10
+ "@earendil-works/pi-tui",
11
+ ]);
12
+
13
+ if (typeof nodeModule.registerHooks === "function") {
14
+ nodeModule.registerHooks({
15
+ resolve(specifier, context, nextResolve) {
16
+ const packageImport = context.parentURL?.startsWith(packageRootUrl) === true;
17
+ if ((nativeRunner && (!compiledRunner || packageImport) ? aliases[specifier] : redirected.has(specifier) && aliases[specifier])) {
18
+ return nextResolve(pathToFileURL(aliases[specifier]).href, context);
19
+ }
20
+ try {
21
+ return nextResolve(specifier, context);
22
+ } catch (error) {
23
+ if (nativeRunner && specifier.endsWith(".js")) return nextResolve(`${specifier.slice(0, -3)}.ts`, context);
24
+ throw error;
25
+ }
26
+ },
27
+ });
28
+ } else {
29
+ nodeModule.register(new URL("./runner-peer-loader.mjs", import.meta.url), {
30
+ data: { aliases, nativeRunner, compiledRunner, packageRootUrl },
31
+ });
32
+ }
@@ -1,28 +1,25 @@
1
1
  ---
2
2
  name: pi-subagents
3
3
  description: |
4
- Delegate to builtin or custom subagents for single-agent handoffs, parallel
5
- review, scripted chaining, async work, forked context, and coordinated
6
- workflows. Use when one parent agent should stay in control while children
7
- supply focused context, planning, review, or execution.
4
+ Technical guidance for operator-requested delegation to builtin or custom
5
+ subagents: bounded handoffs, parallel review, scripted workflows, async work,
6
+ forked context, isolation, and coordinated execution.
8
7
  ---
9
8
 
10
9
  # Pi Subagents
11
10
 
12
- Choose a mode:
13
-
14
- - **Direct mode:** For tiny or focused work, the parent handles the task
15
- directly; a single bounded child handoff is fine. Skip workflow ceremony.
16
- - **Orchestrator mode:** For substantial or delegated work, the parent is the
17
- supervisor, arbiter, and authority holder—not the routine primary doer.
18
- Subagents may own planning/design, scouting, implementation,
19
- simplification/challenge, validation, and review as useful. The parent keeps
20
- user intent, constraints, authority, routing, arbitration, final acceptance,
21
- and publication.
22
- - A useful loop for substantial work is **writer → challenge/simplify → review**;
23
- the parent arbitrates between steps, and tiny tasks can skip it.
24
- - Direct parent edits during orchestrator mode should be intentional, small
25
- interventions with a brief reason.
11
+ The parent works directly by default. Invoke subagents only when the operator
12
+ requested delegation in the current request or through applicable user/project
13
+ instructions. Task size, complexity, risk, tool-call count, recipe fit, or an
14
+ available specialist does not independently authorize delegation.
15
+
16
+ Once authorized, choose the smallest bounded shape that earns its token and
17
+ elapsed-time overhead through concrete evidence, independent review,
18
+ specialization, useful parallelism, or needed isolation. A single child is
19
+ valid; writer, challenge, and review stages must each earn their overhead rather
20
+ than becoming default ceremony. The parent keeps user intent, constraints,
21
+ routing, arbitration, decisions, final acceptance, and publication authority,
22
+ and may perform the work directly where it is the most efficient owner.
26
23
 
27
24
  Children do not spawn subagents unless the parent explicitly delegated fanout
28
25
  and their resolved `tools` allow `subagent`.
@@ -50,6 +47,18 @@ use ordinary `runs.run(...)` / `runs.all(...)`. See the [canonical staged-lane
50
47
  example](../../docs/workflows.md#parallel-sequential-lanes). Keep assignments
51
48
  bounded, but do not add stages or ceremony just to satisfy this skill.
52
49
 
50
+ When composing `runs.run(...)`, `runs.all(...)`, or `runs.lanes(...)`, always
51
+ supply a short verb + behavior display `label` derived from the task, unless
52
+ the user supplied an explicit label; preserve that label. Keep the stable
53
+ machine `key` independent (for example, `issue2011-writer` with
54
+ `label: "Fix workflow steering"`). For `runs.lanes`, put labels on stage
55
+ items, not lane objects. Use stage-appropriate labels for reviews and retained-child
56
+ follow-ups too (for example, `Review workflow steering`). Generate labels in
57
+ the orchestrator while composing the launch—no extra model call, runtime
58
+ generator, or schema change. Native direct `{ agent, task }` calls have no
59
+ top-level `label` parameter; do not invent one or wrap a tiny single task in
60
+ a workflow just to label it.
61
+
53
62
  Use async/background by default. Set `async:false` only when the parent must
54
63
  block. Final reviews, validation gates, oracle checks, and publication checks
55
64
  stay async.
@@ -71,6 +80,8 @@ that runner explicitly supports the option.
71
80
 
72
81
  ## Read the reference for the branch
73
82
 
83
+ For exact API fields and worked examples, call `subagent({action:"guide",topic:"tool-reference"})` or `topic:"workflows"`. The compact tool definition is not the recipe catalog; use `topic:"missions"` for mission updates and schedules.
84
+
74
85
  | Branch | Read |
75
86
  | --- | --- |
76
87
  | Delegate or choose roles, prompts, models, or slash commands | `references/prompting-and-roles.md` |
@@ -80,9 +91,9 @@ that runner explicitly supports the option.
80
91
  | List, create, edit, disable, eject, or expose agents/RPC | `references/management-authoring-rpc.md` |
81
92
  | Check safety constraints, recipes, or error handling | `references/constraints-and-recipes.md` |
82
93
 
83
- For complex work, read `prompting-and-roles.md` and `execution-controls.md`, then
84
- load `review-and-validation.md` and `constraints-and-recipes.md` before launch or
85
- review.
94
+ For an authorized complex delegated workflow, read `prompting-and-roles.md` and
95
+ `execution-controls.md`, then load `review-and-validation.md` and
96
+ `constraints-and-recipes.md` before launch or review.
86
97
 
87
98
  ## Operating rules
88
99
 
@@ -52,10 +52,11 @@ This reference keeps cross-cutting policy and failure handling. Load the matchin
52
52
  | Independent lanes, repositories, worktrees, and handoffs | [`references/multi-lane-orchestration.md`](multi-lane-orchestration.md) |
53
53
  | Agent management, file authoring, prompt integration, or RPC | [`references/management-authoring-rpc.md`](management-authoring-rpc.md) |
54
54
 
55
- Choose the smallest recipe that fits:
55
+ After delegation is operator-authorized, choose the smallest recipe that earns
56
+ its overhead. Recipes select a shape; they do not authorize delegation:
56
57
 
57
58
  - **Recon → plan → implement:** run one focused `scout`, then one `worker` that consumes its findings.
58
- - **Non-trivial implementation:** clarify scope and acceptance, record user-owned decisions and seam/validation contracts, scout load-bearing code, plan when useful, use one writer, run fresh review/validation, apply only accepted fixes with one writer, then inspect direct evidence and the final diff before parent acceptance. Split large work into serial milestones instead of a writer swarm; do not stop at review without disposition.
59
+ - **Implementation:** clarify scope and acceptance, record user-owned decisions and seam/validation contracts, and use a bounded scout, writer, or fresh reviewer only where the requested delegation benefits from that stage. Keep one writer, inspect direct evidence, and require every added stage to earn its overhead. Split large work into serial milestones instead of a writer swarm; do not stop at review without disposition.
59
60
  - **Parallel analysis:** fan out only independent read/review/validation work, or isolate each writer in its own worktree. Never run concurrent writers in one checkout.
60
61
 
61
62
  ## Error Handling
@@ -24,7 +24,7 @@ Project settings resolve from the nearest parent directory containing `.pi` or `
24
24
 
25
25
  An agent may set `runner.type: external-cli` with a non-empty `command`, optional string `args`, and `promptDelivery: stdin` (the default). The command runs with `shell: false`, inherits the resolved cwd and environment, and receives the combined agent instructions and task through stdin. It must already be installed; pi-subagents adds no CLI dependency.
26
26
 
27
- External CLI profiles are async-only and one-shot. They support lifecycle artifacts, stdout/stderr logs, timeout, and stop. Full stdout and stderr are retained in their log files, while the final stdout response and stderr error kept in memory are each limited to their last 64 KiB. They do not support native Pi child options such as model override, structured output, acceptance/agent contract, tool budgets, fast mode, fork context, skills, or native Pi tools unless the runner explicitly implements them. Foreground/clarify, steer/resume/interrupt-as-pause, nested subagents, fallbacks, and sessions are also unsupported.
27
+ External CLI profiles are async-only and one-shot. They support lifecycle artifacts, stdout/stderr logs, timeout, and stop. Full stdout and stderr are retained in their log files, while the final stdout response and stderr error kept in memory are each limited to their last 64 KiB. They do not support native Pi child options such as model override, structured output, acceptance/agent contract, tool budgets, fast mode, fork context, skills, or native Pi tools unless the runner explicitly implements them. Foreground/clarify, steer/resume/interrupt-as-pause, nested subagents, and sessions are also unsupported.
28
28
 
29
29
  ### External job profiles
30
30
 
@@ -32,7 +32,7 @@ An agent may set `runner.type: external-job` with a non-empty `provider` and opt
32
32
 
33
33
  External job profiles are async-only. The provider owns the remote job and Pi owns the async run record. Status persists provider name, provider job id, prompt digest, provider options, handle/conversation URLs when supplied, result artifact path, last known state, and provider failure code/message. Recovery uses existing provider job metadata to call `reattach` and `result`; it refuses to redispatch a prompt when the persisted provider job does not match the prompt digest.
34
34
 
35
- External job profiles do not support foreground/clarify, steer/resume, Pi models/tools/extensions/skills, tool budgets, structured output, native child permissions, fallbacks, or Pi child sessions. Capacity conflicts fail closed and include the blocking provider job id when the provider supplies it.
35
+ External job profiles do not support foreground/clarify, steer/resume, Pi models/tools/extensions/skills, tool budgets, structured output, native child permissions, or Pi child sessions. Capacity conflicts fail closed and include the blocking provider job id when the provider supplies it.
36
36
 
37
37
  ### Single agent
38
38
 
@@ -83,10 +83,10 @@ lanes, or a fanout that the parent will consume together.
83
83
  ```js
84
84
  subagent({
85
85
  workflowScript: `
86
- const scan = await runs.run("scan", { agent: "scout", task: "Map the target" });
86
+ const scan = await runs.run("scan", { label: "Map target behavior", agent: "scout", task: "Map the target" });
87
87
  const reviews = await runs.all([
88
- { key: "correctness", agent: "reviewer", task: "Review correctness: " + scan.output },
89
- { key: "tests", agent: "reviewer", task: "Review tests: " + scan.output }
88
+ { key: "correctness", label: "Review target correctness", agent: "reviewer", task: "Review correctness: " + scan.output },
89
+ { key: "tests", label: "Review target test coverage", agent: "reviewer", task: "Review tests: " + scan.output }
90
90
  ]);
91
91
  return reviews.map(result => result.output);
92
92
  `
@@ -109,6 +109,7 @@ Terminal async workflows also persist `workflow-receipt.json` beside `status.jso
109
109
 
110
110
  ```js
111
111
  return runs.run("cross-oracle", {
112
+ label: "Challenge proposed direction",
112
113
  resume: { workflowRunId: "<pass-1-workflow-id>", key: "advisor-oracle", latest: true },
113
114
  task: "Review the focused challenge packet."
114
115
  });
@@ -120,7 +121,8 @@ Keyed resume reads that one exact receipt and revalidates the retained run at la
120
121
 
121
122
  For a broad plan with a known set of narrow, visible stages per lane, use
122
123
  `runs.lanes(...)` inside a `workflowScript`; it is a nested helper, not a
123
- top-level `subagent` mode. Give each lane and stage a stable key. The first
124
+ top-level `subagent` mode. Give each lane and stage a stable key; give stage
125
+ items a short verb + behavior `label`, preserving explicit user labels. The first
124
126
  stage from every lane is launched together, then later stages sequence per lane.
125
127
  `resume: "previous"` requires the retained predecessor, and a failed or blocked
126
128
  stage blocks only that lane. The returned board exposes lane/stage results for
@@ -246,9 +248,9 @@ Use diagnostics when setup or child startup looks wrong:
246
248
  subagent({ action: "doctor" })
247
249
  ```
248
250
 
249
- ### Failed lane recovery and execution-mode fallback
251
+ ### Failed lane recovery and execution-mode changes
250
252
 
251
- A failure in the subagent workflow, child launch, prompt runtime, extension loading, or child tooling setup is a lane infrastructure blocker, not permission to silently change execution mode. Stop and report the exact failure, run/status, and repo/cwd/worktree/branch/ref state. Retry or fix the `subagent` path only through a clear same-protocol retry; before retrying or asking the owner, verify the worktree is clean or capture the partial diff. For backlog lanes and other subagent-governed workflows, switching to `interactive_shell`, `pi -ne`, Codex/Claude/Cursor CLI, a foreground agent, or another external mode requires explicit owner approval. Pi core may print a generic `pi -ne` extension-load hint; that hint is outside this package and is not protocol-approved fallback. This execution-mode boundary does not prohibit configured native model/provider fallback.
253
+ A failure in the subagent workflow, child launch, prompt runtime, extension loading, or child tooling setup is a lane infrastructure blocker, not permission to silently change execution mode. Stop and report the exact failure, run/status, and repo/cwd/worktree/branch/ref state. Retry or fix the `subagent` path only through a clear same-protocol retry; before retrying or asking the owner, verify the worktree is clean or capture the partial diff. For backlog lanes and other subagent-governed workflows, switching to `interactive_shell`, `pi -ne`, Codex/Claude/Cursor CLI, a foreground agent, or another external mode requires explicit owner approval. Pi core may print a generic `pi -ne` extension-load hint; that hint is outside this package and is not protocol-approved. A verified compaction abort may continue the retained child session once on the same resolved model; provider failures never select another model automatically.
252
254
 
253
255
  ### External terminal work
254
256
 
@@ -338,7 +340,7 @@ subagent({ action: "steer", id: "abc123", mode: "follow_up", message: "After thi
338
340
  subagent({ action: "steer", id: "abc123", mode: "auto", message: "Switch to the failing test now." })
339
341
  ```
340
342
 
341
- Direct input acceptance returns `delivered`, not proof of model compliance. A live follow-up acknowledgment reports `queued`, meaning Pi accepted it into its follow-up queue, not that it was delivered. The runtime does not provide a later correlated live queued-to-delivered receipt.
343
+ For async runs, `delivered` records that the child consumed the correlated user input; foreground `delivered` records in-process transport acceptance. Neither is proof of model compliance. A live foreground follow-up acknowledgment reports `queued`, meaning Pi accepted it into its follow-up queue, not that it was delivered. The foreground transport does not provide a later correlated queued-to-delivered receipt.
342
344
 
343
345
  ## Watchdog
344
346
 
@@ -117,7 +117,6 @@ That is only a starting point. Omit `package` for the traditional unqualified ru
117
117
  - `defaultReads`
118
118
  - `output`
119
119
  - `aliases`
120
- - `fallbackModels`
121
120
  - `subagentOnlyExtensions`
122
121
  - `skills`
123
122
  - `skillPath`
@@ -2,7 +2,7 @@
2
2
 
3
3
  Use this reference when several independent tasks need coordinated workers, worktrees, or repositories. It defines lane ownership; use the other pi-subagents references for run controls, prompts, and mission details. The parent remains the final decision-maker.
4
4
 
5
- Create lanes only when delegation materially improves evidence, independent review, or isolated execution. Do not manufacture parallelism: keep dependent work serial, and only split work when each lane has a distinct decision and useful output.
5
+ Create lanes only after delegation is operator-authorized and each lane materially improves evidence, independent review, specialization, useful parallelism, or isolated execution. Do not manufacture parallelism: keep dependent work serial, and only split work when each lane has a distinct decision and useful output.
6
6
 
7
7
  ## Lane board and authority
8
8
 
@@ -8,12 +8,17 @@ Parent extensions may register a session-scoped, out-of-band ceiling through `pi
8
8
 
9
9
  ## When to Use
10
10
 
11
- - **Complex work orchestration**: keep the parent on its ordinary strong default model. Delegate only when another child materially improves evidence, independent review, or isolated execution; omission failures are cheaper than unnecessary commissions. For hard orchestration or root-cause questions, use a top-reasoning model only as a bounded read-only critic/oracle escalation, never as an autonomous root. Complex means the task has multiple moving parts, unclear acceptance, cross-cutting code, meaningful user-visible impact, expensive or irreversible validation, broad review surface, or the user asks for orchestration. Lightweight one-off delegation can stay lightweight.
11
+ All launch guidance below assumes delegation was requested by the operator in
12
+ the current request or applicable user/project instructions. Complexity,
13
+ workflow fit, and potential quality gains help choose a shape after that gate;
14
+ they do not authorize a launch.
15
+
16
+ - **Complex work orchestration**: after delegation is authorized, keep the parent on its ordinary strong default model and launch only when a bounded child materially improves evidence, independent review, specialization, useful parallelism, or isolated execution. For hard orchestration or root-cause questions, use a top-reasoning model only as a bounded read-only critic/oracle escalation, never as an autonomous root. Lightweight one-off delegation can stay lightweight.
12
17
  - **Advisory review**: use fresh-context `reviewer` agents for adversarial code review; fork to `oracle` only for rare escalation where inherited decisions, drift, model routing, root cause, or hard tradeoffs matter
13
18
  - **Implementation handoff**: have `oracle` advise, then `worker` implement only after an approved direction
14
19
  - **Recon and planning**: use `scout`, then write a plan when needed
15
20
  - **Parallel exploration**: run multiple non-conflicting tasks concurrently
16
- - **Regular skill specialists**: when discovery shows proactive skill subagent suggestions and the current work is broad enough, launch a small fresh-context fanout that asks one subagent per relevant regularly used skill to apply that skill's perspective to the task
21
+ - **Regular skill specialists**: when authorized delegation names or benefits from a relevant specialization, discovery suggestions may help select a small fresh-context fanout
17
22
  - **Long-running work**: launch async/background runs and inspect them later. For mutation-capable work, bound the delivery slice and elapsed runtime, then request checkpoints after active tool work returns. Reserve hard tool-call caps for explicitly read-only children.
18
23
  - **Subagent control**: watch needs-attention signals and soft-interrupt only when a delegated run is genuinely blocked
19
24
  - **Agent authoring**: create, update, or override project agents. Treat saved chain records as legacy inspection or migration inputs, not as a current authoring target.
@@ -29,7 +34,7 @@ Agents use the `subagent(...)` tool for execution, management, status, and contr
29
34
  - `/subagents-detach [run-id]` — detach an active foreground single-subagent run without terminating its child
30
35
  - `/subagents-steer <run-id> [--child <child-id>] <message>` — steer a live async run (or one child of it) from non-TUI sessions and RPC hosts
31
36
  - `/subagent-cost` — show parent plus child token usage and cost for the session
32
- - `/subagents-fleet` — open the live fleet inspector with per-child controls; `Ctrl+Alt+F` opens it during an active foreground turn, `↑↓`/`jk` selects children, `PgUp`/`PgDn` scrolls transcript detail, `s` steers the selected live async child, and `D` stops its top-level async run after confirmation
37
+ - `/subagents-fleet` — open the live fleet inspector with per-child controls; `↑↓`/`jk` selects children, `PgUp`/`PgDn` scrolls transcript detail, `s` steers the selected live async child, and `D` stops its top-level async run after confirmation
33
38
  - `/subagents-watchdog` — inspect or configure the opt-in adversarial change watchdog (model, on/off, recommend-model, check)
34
39
  - `/subagents-doctor` — diagnose setup, discovery, async paths, and intercom bridge state
35
40
  - `/subagents-models [agent]` — show the live runtime-loaded builtin model mapping
@@ -39,7 +44,7 @@ Agents use the `subagent(...)` tool for execution, management, status, and contr
39
44
  Prefer the tool when you are writing agent logic. Prefer the slash commands when
40
45
  you are guiding a human through an interactive flow.
41
46
 
42
- Packaged prompt shortcuts are also available for repeatable workflows. Treat them as reusable orchestration recipes, not just human slash commands. When the user asks for one of these shapes, or when the workflow clearly fits, apply the same pattern directly with `subagent(...)` and other tools:
47
+ Packaged prompt shortcuts are also available for repeatable workflows. Treat them as reusable orchestration recipes, not just human slash commands. When the user asks for one of these shapes, apply the same pattern directly with `subagent(...)` and other tools:
43
48
  - `/parallel-review` — fresh-context reviewers with distinct review angles, then synthesis
44
49
  - `/review-loop` — parent-orchestrated worker, fresh-reviewer, and fix-worker cycles until clean or capped
45
50
  - `/parallel-research` — combine `researcher` and `scout` for external evidence plus local code context
@@ -53,7 +58,7 @@ The prompt templates in `prompts/` encode workflows the parent agent can run on
53
58
 
54
59
  ### Commission-risk and cold-start packets
55
60
 
56
- Delegate only when the child materially improves evidence, independent review, or isolated execution; do not manufacture parallelism. Every child packet must be cold-start complete: state the goal, exact target/cwd/ref, authority and edit boundary, relevant context/evidence, success criteria, validation, output, and stop/escalation rules. For an orchestration audit by the critic tier, make the child read-only and request at most three omissions, each cited to a file, line, or decision; high thinking is an explicit escalation, not a default.
61
+ After the operator-authority gate above, delegate only when the child materially improves evidence, independent review, specialization, useful parallelism, or isolated execution; do not manufacture parallelism. Every child packet must be cold-start complete: state the goal, exact target/cwd/ref, authority and edit boundary, relevant context/evidence, success criteria, validation, output, and stop/escalation rules. For an orchestration audit by the critic tier, make the child read-only and request at most three omissions, each cited to a file, line, or decision; high thinking is an explicit escalation, not a default.
57
62
 
58
63
  ### Council Mode technique
59
64
 
@@ -63,11 +68,11 @@ Council advisors are read-only. User or project `council-*` profiles choose allo
63
68
 
64
69
  ### Parallel review technique
65
70
 
66
- Use this when the user wants adversarial review of a diff, plan, issue, file, or implemented work. Launch fresh-context `reviewer` agents with distinct angles generated from the actual target. Common angles are correctness/regressions, tests/validation, and simplicity/maintainability; adapt for TypeScript, UI, security, docs, or large structural changes. Reviewers should inspect files and diffs directly, return concise evidence-backed findings with file/line references, and avoid edits unless the user explicitly asks for a writer pass. Filter on evidence, not severity: report only concrete current issues caused or made reachable by the target diff, with source proof, a test or repro, or a contract contradiction. Label findings P0/P1/P2 and end with `Merge verdict: BLOCK`, `Merge verdict: OK`, or `Merge verdict: OK with notes`. Use `blockers only` only for final pre-merge re-checks after P1/P2 findings are already captured, or for explicit emergency hotfix lanes where non-blocking findings are intentionally deferred. For targeted follow-up, ask only whether the named finding was resolved, whether the fix introduced a new defect in the fix blast radius, and whether prior P1/P2 notes still stand. For bot or PR-comment triage, classify each comment as VALID, STALE, INVALID, or OUT-OF-POLICY against current HEAD, then assign P0/P1/P2 only to VALID comments. The parent synthesizes fixes worth doing now, optional improvements, and feedback to ignore/defer before applying anything.
71
+ Use this when the user wants adversarial review of a diff, plan, issue, file, or implemented work. Launch fresh-context `reviewer` agents with distinct angles generated from the actual target. Common angles are correctness/regressions, tests/validation, and simplicity/maintainability; adapt for TypeScript, UI, security, docs, or large structural changes. Reviewers should inspect files and diffs directly, return concise evidence-backed findings with file/line references, and avoid edits unless the user explicitly asks for a writer pass. Filter on evidence, not severity: report concrete current issues within the named review target, with source proof, a test or repro, or a contract contradiction. For a diff review, require that the issue is caused or made reachable by that diff. Label findings P0/P1/P2 and end with `Merge verdict: BLOCK`, `Merge verdict: OK`, or `Merge verdict: OK with notes`. Use `blockers only` only for final pre-merge re-checks after P1/P2 findings are already captured, or for explicit emergency hotfix lanes where non-blocking findings are intentionally deferred. For targeted follow-up, ask only whether the named finding was resolved, whether the fix introduced a new defect in the fix blast radius, and whether prior P1/P2 notes still stand. For bot or PR-comment triage, classify each comment as VALID, STALE, INVALID, or OUT-OF-POLICY against current HEAD, then assign P0/P1/P2 only to VALID comments. The parent synthesizes fixes worth doing now, optional improvements, and feedback to ignore/defer before applying anything.
67
72
 
68
73
  ### Proactive skill-specialist technique
69
74
 
70
- Use this when `{ action: "list" }` reports proactive skill subagent suggestions and the user's task would benefit from perspectives the parent regularly uses. These suggestions are conservative: a skill is recommended only when it is available and referenced repeatedly by configured agents or saved chains. Treat the list as an opt-in hint for the current task, not a command to always fan out.
75
+ Use this only within operator-authorized delegation when `{ action: "list" }` reports skill subagent suggestions relevant to the requested handoff. Availability is a selection hint, not authority or a command to fan out.
71
76
 
72
77
  Default guardrails:
73
78
  - Keep the fanout small: usually one or two skill-specialist children, never more than the listed recommendations or configured cap.
@@ -105,11 +110,11 @@ Use this when the question needs both external evidence and local implications.
105
110
 
106
111
  ### Gather-context-and-clarify technique
107
112
 
108
- Use this at the start of non-trivial work. Launch `scout` for local context and `researcher` only when external docs, recent sources, ecosystem context, or primary evidence would materially improve understanding. Ask children for concise findings plus remaining clarification questions. Then synthesize what is known and use `interview` to ask the unresolved questions needed for shared understanding before planning or implementing.
113
+ Use this when the operator requests delegated context gathering. Launch `scout` for local context and `researcher` only when external docs, recent sources, ecosystem context, or primary evidence would materially improve understanding. Ask children for concise findings plus remaining clarification questions. Then synthesize what is known and use `interview` to ask the unresolved questions needed for shared understanding before planning or implementing.
109
114
 
110
115
  ### Parallel cleanup technique
111
116
 
112
- Use this after implementation when the user wants cleanup review or when a final pass would reduce AI-slop. Launch two fresh-context `reviewer` tasks with `output: false` and `progress: false`: one deslop pass and one verbosity pass. If the `deslop` or `verbosity-cleaner` skills are available, pass the relevant skill to that reviewer; otherwise inline the criteria. Both reviewers are review-only and should flag concrete issues with severity, file/line references, and smallest safe fixes. Phrase the constraint as “Do not modify project/source files; returning findings through the configured output artifact is allowed” when you use `output` or `outputMode: "file-only"`. The parent decides what to apply and asks before making changes unless cleanup was already authorized.
117
+ Use this after implementation when the user or applicable instructions request delegated cleanup review. Launch two fresh-context `reviewer` tasks with `output: false` and `progress: false`: one deslop pass and one verbosity pass. If the `deslop` or `verbosity-cleaner` skills are available, pass the relevant skill to that reviewer; otherwise inline the criteria. Both reviewers are review-only and should flag concrete issues with severity, file/line references, and smallest safe fixes. Phrase the constraint as “Do not modify project/source files; returning findings through the configured output artifact is allowed” when you use `output` or `outputMode: "file-only"`. The parent decides what to apply and asks before making changes unless cleanup was already authorized.
113
118
 
114
119
  ### Staged fix orchestration technique
115
120
 
@@ -203,7 +208,7 @@ For one run, use inline config:
203
208
 
204
209
  For persistent tweaks, edit `subagents.agentOverrides` in user or project settings. User overrides apply everywhere. Project overrides apply only in that repo and win over user overrides. Use `/subagents-models` or `subagent({ action: "models" })` to inspect the live mapping after settings and overrides load.
205
210
 
206
- Provider-scoped entries can layer on top of the default override for the active parent session provider. The provider is selected once from the parent model before child model fallback starts, so fallback attempts cannot switch configuration. Within each settings file, the provider entry wins per field; project settings still win over user settings.
211
+ Provider-scoped entries can layer on top of the default override for the active parent session provider. The provider is selected once from the parent model. Within each settings file, the provider entry wins per field; project settings still win over user settings.
207
212
 
208
213
  ```json
209
214
  {
@@ -261,7 +266,6 @@ Direct settings example:
261
266
  "reviewer": {
262
267
  "model": "provider/strong-review-model",
263
268
  "thinking": "high",
264
- "fallbackModels": ["backup-provider/strong-review-model"],
265
269
  "acceptanceRole": "read-only"
266
270
  }
267
271
  }
@@ -269,7 +273,7 @@ Direct settings example:
269
273
  }
270
274
  ```
271
275
 
272
- Useful override fields: `description`, `model`, `fallbackModels`, `thinking`,
276
+ Useful override fields: `description`, `model`, `thinking`,
273
277
  `systemPromptMode`, `inheritProjectContext`, `inheritGlobalContext`, `inheritSkills`, `defaultContext`,
274
278
  `acceptanceRole`, `disabled`, `skills`, `tools`, `extensions`, and `systemPrompt`.
275
279
  `description` replaces the discovered description for builtin and custom agents
@@ -283,7 +287,7 @@ Keep the parent/orchestrator on the ordinary strong default model because omissi
283
287
 
284
288
  Examples are illustrative, not requirements. Map these tiers to concrete models in user/project settings or a profile. A non-OpenAI setup should choose comparable available models by capability.
285
289
 
286
- Use `fallbackModels` when a tier has provider quota or availability risk. Prefer fresh context for cross-provider children when inherited provider-specific reasoning blocks would force thinking off.
290
+ Each child launch uses one resolved model exactly once. If quota or availability fails, surface that failure and let the parent or operator explicitly launch a later attempt with another model. Forked children keep their requested thinking level even when provider-specific reasoning blocks are stripped from the inherited transcript.
287
291
 
288
292
  If a provider rejects model IDs with thinking suffixes, use
289
293
  `subagents.disableThinking: true` in user or project settings to clear bundled
@@ -1,6 +1,6 @@
1
1
  # Pi Subagents: Review And Validation
2
2
 
3
- Generic review and delivery guidance for delegated work. This file does not encode private backlog, merge, or release policy.
3
+ Generic review and delivery guidance for operator-authorized delegated work. This file does not encode private backlog, merge, or release policy.
4
4
 
5
5
  ## Delivery loop
6
6
 
@@ -9,7 +9,7 @@ Use the smallest loop that proves the change:
9
9
  1. Inspect the source, diff, issue, or plan directly.
10
10
  2. Keep one writer for each cwd or worktree.
11
11
  3. Run focused validation that can fail for the changed behavior.
12
- 4. Use fresh-context read-only review for substantial, risky, public, or hard-to-see changes.
12
+ 4. When the operator/project delegation contract calls for independent review, use a fresh-context read-only reviewer; otherwise parent inspection is valid.
13
13
  5. Apply only accepted findings inside the same writer boundary.
14
14
  6. Re-run affected validation and review only the changed blast radius.
15
15
  7. Inspect the final diff and evidence before parent acceptance.
@@ -61,7 +61,7 @@ Before reporting delegated work as done, verify the relevant subset:
61
61
 
62
62
  - final diff contains only intended files
63
63
  - focused validation covers changed behavior
64
- - substantial or risky changes have fresh-review evidence
64
+ - required independent review has fresh-review evidence
65
65
  - accepted findings are fixed and revalidated
66
66
  - publication authority exists before push, comment, close, merge, deploy, or release
67
67
  - external checks are exact-head when used as evidence