pi-subagents 0.52.1 → 0.54.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 (67) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +4 -0
  3. package/docs/configuration.md +12 -2
  4. package/docs/extension-api.md +3 -1
  5. package/docs/models.md +17 -3
  6. package/docs/workflows.md +2 -0
  7. package/index.ts +10 -1
  8. package/package.json +2 -1
  9. package/prompts/council.md +51 -0
  10. package/skills/council-mode/SKILL.md +231 -0
  11. package/skills/pi-subagents/SKILL.md +5 -1
  12. package/skills/pi-subagents/references/constraints-and-recipes.md +1 -0
  13. package/skills/pi-subagents/references/execution-controls.md +13 -0
  14. package/skills/pi-subagents/references/prompting-and-roles.md +7 -0
  15. package/src/agents/agent-management.ts +107 -8
  16. package/src/agents/agent-serializer.ts +2 -0
  17. package/src/agents/agents.ts +96 -37
  18. package/src/agents/builtin-names.ts +9 -0
  19. package/src/agents/runtime-agent-registry.ts +418 -0
  20. package/src/api/agents.ts +7 -0
  21. package/src/api/preflight.ts +8 -3
  22. package/src/extension/config.ts +3 -0
  23. package/src/extension/doctor.ts +11 -0
  24. package/src/extension/fanout-child.ts +3 -2
  25. package/src/extension/index.ts +20 -4
  26. package/src/extension/public-execution.ts +1 -1
  27. package/src/extension/rpc.ts +41 -1
  28. package/src/extension/schemas.ts +6 -3
  29. package/src/extension/tool-description.ts +2 -2
  30. package/src/extension/tool-result.ts +19 -0
  31. package/src/inspectors/herdr/client.ts +3 -3
  32. package/src/runs/background/async-execution.ts +12 -6
  33. package/src/runs/background/async-job-tracker.ts +4 -3
  34. package/src/runs/background/async-resume.ts +2 -1
  35. package/src/runs/background/async-retention.ts +1 -1
  36. package/src/runs/background/async-status-snapshot.ts +14 -5
  37. package/src/runs/background/auto-drain.ts +1 -0
  38. package/src/runs/background/chain-root-attachment.ts +5 -0
  39. package/src/runs/background/result-watcher.ts +9 -0
  40. package/src/runs/background/stale-run-reconciler.ts +3 -0
  41. package/src/runs/background/subagent-runner.ts +32 -5
  42. package/src/runs/background/subagent-wait.ts +9 -5
  43. package/src/runs/background/terminal-run-index.ts +15 -6
  44. package/src/runs/background/wait-completions.ts +2 -0
  45. package/src/runs/background/wait-tool.ts +5 -3
  46. package/src/runs/foreground/execution.ts +34 -2
  47. package/src/runs/foreground/subagent-executor.ts +196 -52
  48. package/src/runs/foreground/workflow-detach-reconcile.ts +83 -15
  49. package/src/runs/shared/acceptance.ts +44 -1
  50. package/src/runs/shared/model-exclusions.ts +242 -0
  51. package/src/runs/shared/model-fallback.ts +72 -16
  52. package/src/runs/shared/model-scope.ts +106 -39
  53. package/src/runs/shared/pi-args.ts +34 -1
  54. package/src/runs/shared/subagent-control.ts +25 -3
  55. package/src/runs/shared/subagent-prompt-runtime.ts +36 -9
  56. package/src/shared/fork-context.ts +17 -1
  57. package/src/shared/model-info.ts +20 -0
  58. package/src/shared/settings.ts +2 -2
  59. package/src/shared/types.ts +47 -2
  60. package/src/slash/slash-commands.ts +20 -6
  61. package/src/slash/slash-live-state.ts +3 -3
  62. package/src/tui/fleet-status.ts +86 -1
  63. package/src/tui/fleet.ts +55 -2
  64. package/src/tui/render.ts +73 -3
  65. package/src/watchdog/permission-arbiter.ts +59 -51
  66. package/src/workflows/scripted-workflow.ts +100 -12
  67. package/src/workflows/workflow-receipt.ts +140 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,75 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.54.0] - 2026-08-21
6
+
7
+ ### Highlights
8
+ - Subagent model selection is more precise with per-agent restrictions and an `inherit` shortcut for the current parent model.
9
+ - Package agents are easier to discover because list and detail output now shows where they come from and whether their external provider is ready.
10
+ - Workflow runs are less fragile: tool-result backfill, context-overflow handling, resumed children, and permission asks now behave more predictably.
11
+ - Child launches are lighter and safer because subagent processes avoid loading the parent extension graph and avoid unnecessary permission bridge setup.
12
+ - Council Mode is easier to use from natural language and no longer requires invented advisor role labels.
13
+
14
+ ### Added
15
+ - Add per-agent model restrictions and a current-parent `inherit` allow-list alias. Thanks to [@hieudmg](https://github.com/hieudmg) for #1328.
16
+
17
+ ### Changed
18
+ - Show package names, versions, and external-job provider status in subagent list and detail output so package agents such as Surf's `gpt-pro` are easier to find and use.
19
+ - Make scripted workflow helper support and stale-session recovery easier to see in `doctor` and the workflow guide (#1344).
20
+ - Keep structured single-child execution receipts quieter by removing an internal conversion log from public workflow output.
21
+ - Route natural-language requests for advisor councils, plan critique, cross-exam, or multiple model perspectives to the Council Mode protocol.
22
+ - Simplify Council Mode advisor selection so model-based profiles provide the perspective and the question supplies the decision frame.
23
+
24
+ ### Fixed
25
+ - Layer custom-agent user and project overrides without dropping user-only fields, while preserving project precedence. Thanks to [@jagaliano](https://github.com/jagaliano) for #1348.
26
+ - Avoid child tool-call hangs by loading the external permission-system bridge only for explicit native permission rules and by failing stalled ask decisions closed. Thanks to [@moekyo](https://github.com/moekyo) for #1339.
27
+ - Keep foreground workflow children from timing out after a tool result is backfilled without a separate execution-end event. Thanks to [@moekyo](https://github.com/moekyo) for #1339.
28
+ - Mark completed foreground workflow children as resumable in keyed receipts when their persisted session file is available (#1335).
29
+ - Avoid loading the parent extension graph in subagent child processes. Thanks to [@ccharname](https://github.com/ccharname) for #1330.
30
+ - Stop model fallback on context-overflow failures and surface `contextOverflow`. Thanks to [@srcKod](https://github.com/srcKod) for #1323.
31
+ - Stop empty slow result scans from spamming the session transcript. Thanks to [@afrodao2394](https://github.com/afrodao2394) for #1329.
32
+ - Surface logical tool failures so subagent tool results backfill correctly. Thanks to [@abdwhb-png](https://github.com/abdwhb-png) for #1332 and [@moekyo](https://github.com/moekyo) for #1331.
33
+
34
+ ## [0.53.0] - 2026-08-20
35
+
36
+ ### Highlights
37
+ - New `/council` mode helps with material decisions by running a small, bounded group of advisors and ending with a parent-written decision memo.
38
+ - Pi extensions can now register runtime agents without writing user or project config.
39
+ - Async workflows are easier to resume because completed children now have durable keyed receipts.
40
+ - Model fallback is less noisy and less wasteful when a model fails or the prompt is too large.
41
+ - Extension RPC hosts can safely inspect status, launch async work, steer children, and manage schedules.
42
+
43
+ ### Added
44
+ - Carry full model registry metadata, including tiered pricing, into normalized model information. Thanks to [@srcKod](https://github.com/srcKod) for #1317.
45
+ - Add runtime agent registration for Pi extensions, with name and alias collision checks. Thanks to [@fmoda3](https://github.com/fmoda3) for #1310.
46
+ - Skip recently failed fallback models for a TTL-backed window during model selection. Thanks to [@srcKod](https://github.com/srcKod) for #1318.
47
+ - Add a schedule-only `manage` method to extension RPC for list/show/history/pause/resume/run/delete, while rejecting unrelated management actions. Thanks to [@aboubakrine](https://github.com/aboubakrine) for #1319.
48
+ - Let agent definitions and `agentOverrides` set a default `outputMode`, while
49
+ call-level output mode stays higher priority. Thanks to [@bbbRye007](https://github.com/bbbRye007) for #1305.
50
+ - Add `context: "profile"` for workflow children that should use the selected
51
+ agent profile's declared context instead of the global default (#1303).
52
+ - Add durable keyed async workflow receipts and resume-by-key selectors for
53
+ retained workflow children (#1302).
54
+ - Add the `resultScanLogging` config to control result scan logging. Thanks to [@apoapostolov](https://github.com/apoapostolov) for #1293.
55
+ - Add `/council` and `council-mode` for bounded advisor councils. Use it for material decisions that need multiple perspectives: the parent picks 2–3 advisors, collects independent reports, optionally runs one cross-exam pass, and writes the final decision memo. The package also documents model-based `council-*` profile examples (#1295).
56
+
57
+ ### Changed
58
+ - Show bounded workflow progress in Fleet detail views while keeping workflow
59
+ parents as the only actionable async items (#1304).
60
+ - Make `/council` easier to supervise with structured advisor contracts,
61
+ aggregate pass receipts, and visible pass checkpoints (#1301).
62
+ - Reuse validated workflow launch fingerprints during `runs.all` batch setup, reducing focused fingerprint bookkeeping time by 48.7% (#1287).
63
+ - Speed up recent terminal run history reads when the marker history is large and the requested limit is small.
64
+ - Reduce repeated serialization while applying async status snapshot byte caps (#1288).
65
+
66
+ ### Fixed
67
+ - Add tolerant `subagent_wait({ stopOnAttention: false })` blocking waits and scale idle attention defaults for higher-thinking children. Thanks to [@elecnix](https://github.com/elecnix) for #1315 and #1316.
68
+ - Add a separate classifier for model context-overflow errors. Thanks to [@srcKod](https://github.com/srcKod) for #1312.
69
+ - Normalize child result metadata before workflow return persistence (#1307).
70
+ - Quote only confidently identified leading Windows executable paths in acceptance verification commands. Thanks to [@srcKod](https://github.com/srcKod) for #1294.
71
+ - Keep forked subagent sessions out of top-level `pi -c` discovery by storing them under the parent session root. Thanks to [@xz-dev](https://github.com/xz-dev) for #1297.
72
+ - Preserve `/council` advisor context defaults during fallback and cross-exam runs (#1298).
73
+
5
74
  ## [0.52.1] - 2026-08-20
6
75
 
7
76
  ### Highlights
package/README.md CHANGED
@@ -67,12 +67,16 @@ Rule of thumb: `scout` before you understand the code, `researcher` before you t
67
67
 
68
68
  ## Common workflows
69
69
 
70
+ The package includes `/council` and `council-mode`, plus documented model-based
71
+ `council-*` profile examples that you add in your own agent directory.
72
+
70
73
  | Want | Ask naturally |
71
74
  |------|---------------|
72
75
  | Get a second opinion | "Ask oracle to review this plan and challenge assumptions." |
73
76
  | Solve a hard problem | "Use oracle to investigate this bug before we edit." |
74
77
  | Review a diff | "Use reviewer to review this diff." |
75
78
  | Run parallel reviewers | "Run reviewers for correctness, tests, and cleanup." |
79
+ | Debate a material decision | "Use `/council` with model-based advisors to compare this decision." |
76
80
  | Implement then review | "Implement this, then review it." |
77
81
  | Review until clean | "Run a review loop on this change with a max of 3 rounds." |
78
82
  | Execute a plan carefully | "Have worker implement this approved plan, then run reviewers and apply the feedback." |
@@ -2,7 +2,7 @@
2
2
 
3
3
  `pi-subagents` reads optional JSON config from `~/.pi/agent/extensions/subagent/config.json`. This page lists every key, plus the environment variables and the settings-file keys that affect config resolution.
4
4
 
5
- Settings-level keys (`subagents.defaultModel`, `defaultThinking`, `defaultExtensions`, `agentOverrides`, `modelScope`, `disableThinking`, `disableBuiltins`, watchdog settings) live in Pi settings files, not this config file. See [models.md](models.md), [agents.md](agents.md), and [watchdog.md](watchdog.md).
5
+ Settings-level keys (`subagents.defaultModel`, `defaultThinking`, `defaultExtensions`, `agentOverrides`, `modelScope`, `disableThinking`, `disableBuiltins`, watchdog settings) live in Pi settings files, not this config file. `modelScope.agents.<name>` adds per-agent restrictions, and `allow: ["inherit"]` permits the current parent model. See [models.md](models.md), [agents.md](agents.md), and [watchdog.md](watchdog.md).
6
6
 
7
7
  ## Project root resolution (settings)
8
8
 
@@ -160,10 +160,20 @@ Controls the under-editor widget for active background runs. It defaults to `tru
160
160
 
161
161
  Keeps the `subagent_wait` tool registered but makes direct calls return immediately instead of blocking on active subagent or provider work. The default is enabled. You can also set `"waitTool": false`; set `PI_SUBAGENT_WAIT_TOOL_ENABLED=false` (or `0`, `off`, `disabled`) to override config for one process. The effective value is passed explicitly to child runtimes. Headless `agent_end` auto-drain remains a lifecycle safeguard even when direct wait calls are disabled. Invalid config or environment values fail instead of being coerced.
162
162
 
163
- Blocking `subagent_wait({ id: "..." })` keeps the current tool call open until that run changes. In a long-lived interactive parent session, `subagent_wait({ id: "...", nonBlocking: true })` instead resolves the prefix once, persists the exact run identity, returns a subscription token immediately, and wakes that session on completion, failure, attention, reconciliation failure, or timeout. Armed subscriptions appear in ordinary `subagent({ action: "status" })` output and are not counted as active child work.
163
+ Blocking `subagent_wait({ id: "..." })` keeps the current tool call open until that run changes. By default it returns when a run needs attention. Use `subagent_wait({ stopOnAttention: false })` only for run-to-completion flows that should wait through idle or long-thinking attention; supervisor/contact requests still stop the wait. In a long-lived interactive parent session, `subagent_wait({ id: "...", nonBlocking: true })` instead resolves the prefix once, persists the exact run identity, returns a subscription token immediately, and wakes that session on completion, failure, attention, reconciliation failure, or timeout. Armed subscriptions appear in ordinary `subagent({ action: "status" })` output and are not counted as active child work.
164
164
 
165
165
  This is different from `waitTool.enabled=false`, which returns immediately without registering any future wake. Provider items remain available only to blocking fleet-wide waits; non-blocking subscriptions require one async or remembered detached foreground run id.
166
166
 
167
+ ## `resultScanLogging`
168
+
169
+ ```json
170
+ { "resultScanLogging": "activity" }
171
+ ```
172
+
173
+ Controls how slow result-index scans are logged. Defaults to `"activity"`; valid values are `"all"`, `"activity"`, and `"off"`.
174
+
175
+ The watcher logs `Subagent result scan inspected … scheduled …` through `console.error` whenever a result-index scan passes the slow threshold (500ms). With `"activity"` (default), it logs only scans that inspected or scheduled actual work. Use `"all"` to log every slow scan, including the periodic healthy rescan that inspects zero files while no async runs are pending, or `"off"` to silence slow-scan logging entirely. `"off"` does not disable result delivery or the watcher itself, only its slow-scan log line.
176
+
167
177
  ## `forceTopLevelAsync`
168
178
 
169
179
  ```json
@@ -23,10 +23,11 @@ pi.events.emit("subagents:rpc:v1:request", {
23
23
  });
24
24
  ```
25
25
 
26
- The RPC methods are `ping`, `status`, `spawn`, `steer`, `interrupt`, `stop`, and `resume`. `status`, `steer`, `interrupt`, and `resume` reuse the normal package-owned actions.
26
+ The RPC methods are `ping`, `status`, `manage`, `spawn`, `steer`, `interrupt`, `stop`, and `resume`. `status`, `manage`, `steer`, `interrupt`, and `resume` reuse normal package-owned actions.
27
27
 
28
28
  Method notes:
29
29
 
30
+ - `manage` exposes a narrow schedule-only allowlist: `schedule.list`, `schedule.show`, `schedule.history`, `schedule.pause`, `schedule.resume`, `schedule.run`, and `schedule.delete`. All actions except `schedule.list` require `id`. Mission, agent, config, worktree, and arbitrary management actions are rejected before executor dispatch. `ping.capabilities.managementActions` advertises the exact allowlist.
30
31
  - `spawn` requires `workflowScript` and is async-only: omit `async` or set `async: true`, omit `clarify`, and do not pass management `action` values. It goes through the same executor as the `subagent` tool, so agent discovery, validation, session attribution, configured spawn caps, child-safety depth, artifacts, and async status all behave the same.
31
32
  - `steer` requires an async run `id` (plus optional child `index`) and a non-empty `message`; its reply preserves the normal acknowledged-delivery result. Optional `mode` values are `steer` (default), `follow_up`, and `auto`, and receipts include `deliveryStatus: "delivered" | "queued"`. RPC steering disables the direct tool's pause-and-revive recovery in every mode so an extension keeps authority over the exact child it spawned; `ping.capabilities.nonRecoveringSteer` advertises this guarantee.
32
33
  - `resume` requires a run target and non-empty `message`. It delegates to the existing revival path, which validates current-session ownership, persisted session/recovery metadata, stopped/live state, capability ceilings, and the exclusive session lease before returning the new async run details. Callers may request a `file-only` output path for the revived result without overriding its model, tools, or budgets. `ping.capabilities.resume` advertises this seam.
@@ -35,6 +36,7 @@ Method notes:
35
36
  Capability advertisements on `ping`:
36
37
 
37
38
  - `events.asyncComplete` — exact process-local completion correlation after RPC `spawn`.
39
+ - `managementActions` — exact schedule management actions accepted by RPC `manage`.
38
40
  - `launchResolvedExtensions` — the optional launch-resolved extension projection in status details.
39
41
  - `runtimeAcknowledgedExtensions` — the optional child-runtime acknowledgement projection and event name.
40
42
  - `processTerminalProof` — the process-terminal proof status (see [observability.md](observability.md#process-terminal-proof)).
package/docs/models.md CHANGED
@@ -10,6 +10,8 @@ Builtin agents inherit your current Pi default model. This keeps new installs fr
10
10
 
11
11
  Precedence, strongest first: per-run override → agent frontmatter `model` → `agentOverrides.<name>.model` → `subagents.defaultModel` → the parent session model.
12
12
 
13
+ Use `model: "inherit"` in agent frontmatter or `agentOverrides.<name>.model` to select the current parent session model explicitly.
14
+
13
15
  ## Setting defaults and overrides
14
16
 
15
17
  In `~/.pi/agent/settings.json` (user) or the project config settings file (`.pi/settings.json` in standard Pi; project wins):
@@ -153,17 +155,29 @@ To keep subagents inside a budget or compliance profile, enforce a model scope.
153
155
  "modelScope": {
154
156
  "enforce": true,
155
157
  "strict": true,
156
- "allow": ["anthropic/*", "openai/gpt-5-*"]
158
+ "allow": ["inherit", "openai/gpt-5-*"],
159
+ "agents": {
160
+ "worker": { "allow": ["openai/gpt-5-mini"] },
161
+ "reviewer": { "allow": ["inherit"] }
162
+ }
157
163
  }
158
164
  }
159
165
  }
160
166
  ```
161
167
 
162
- - `allow` is a list of glob patterns matched against the resolved `provider/id` (only `*` is special, case-insensitive). A resolved model that matches none of the patterns is rejected.
168
+ - `allow` is a list of glob patterns matched against the resolved `provider/id` (only `*` is special, case-insensitive). The literal `inherit` means the current parent session model.
169
+ - `agents.<name>` adds a second allow-list for that agent. The model must pass both the global list and the matching agent list, so an agent rule cannot weaken the global rule. Agent rules inherit `enforce` and `strict` when those fields are absent.
170
+ - A top-level `enforce: true` with only agent allow-lists restricts only those named agents. Unknown names are allowed so settings can be shared across projects and machines.
163
171
  - Models you pass explicitly — the tool-call `model`, `--model`, or a clarify pick — error and abort the run.
164
172
  - By default, models from agent frontmatter, `subagents.defaultModel`, the inherited parent session model, or fallback chains only warn and remain available, so existing configurations keep working while you tighten the scope.
165
173
  - Set `strict: true` with `enforce: true` to reject every resolved out-of-scope model. This includes inherited models and fallback candidates. An invalid fallback fails the run instead of being removed from the candidate chain.
166
- - `enforce: true` requires a non-empty `allow` list; otherwise the config is rejected at load time.
174
+ - `enforce: true` requires at least one non-empty global or agent `allow` list; otherwise the config is rejected at load time.
175
+
176
+ Model scope is policy only. It rejects or warns; it does not select a cheaper model. Set `agentOverrides.worker.model` to choose a worker model and use `modelScope.agents.worker` to prevent a per-run override or fallback from escaping that restriction.
177
+
178
+ `inherit` expands in the parent process at each launch. It is never sent to the child as a model id. A nested child therefore inherits its immediate parent's current model, not the original top-level model. If no parent model is available, an enforced `inherit` entry does not match and fails closed.
179
+
180
+ Project `modelScope` settings replace the complete user `modelScope`, as with the existing project-over-user settings precedence. Project settings are trusted and can therefore replace user restrictions.
167
181
 
168
182
  ## Profiles and provider model catalogs
169
183
 
package/docs/workflows.md CHANGED
@@ -37,6 +37,8 @@ Add `autofix` to `/parallel-review` or `/parallel-cleanup` to apply only the syn
37
37
 
38
38
  All model-facing subagent execution is expressed through `workflowScript` in the `subagent` tool. Use stable keys and ordinary JavaScript for one child, sequence, and parallelism. For ordinary parallel fanout, use `await runs.all([{ key, agent, task }, ...])`; 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:
39
39
 
40
+ 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.
41
+
40
42
  ```js
41
43
  subagent({ workflowScript: `
42
44
  const scan = await runs.run("scan", { agent: "scout", task: "Scan the codebase" });
package/index.ts CHANGED
@@ -1 +1,10 @@
1
- export { default } from "./src/extension/index.ts";
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import type {} from "./src/types/pi-runtime-compat.d.ts";
3
+
4
+ const registerParentExtension = process.env.PI_SUBAGENT_CHILD === "1"
5
+ ? undefined
6
+ : (await import("./src/extension/index.ts")).default;
7
+
8
+ export default function registerSubagentExtension(pi: ExtensionAPI): void {
9
+ registerParentExtension?.(pi);
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-subagents",
3
- "version": "0.52.1",
3
+ "version": "0.54.0",
4
4
  "description": "Pi extension for single-agent delegation and scripted multi-agent workflows",
5
5
  "author": "Nico Bailon",
6
6
  "license": "MIT",
@@ -10,6 +10,7 @@
10
10
  "./background-work": "./src/api/background-work.ts",
11
11
  "./external-job-provider": "./src/api/external-job-provider.ts",
12
12
  "./external-runs": "./src/api/external-runs.ts",
13
+ "./agents": "./src/api/agents.ts",
13
14
  "./delegation": "./src/api/delegation.ts",
14
15
  "./capability-ceiling": "./src/api/capability-ceiling.ts",
15
16
  "./preflight": "./src/api/preflight.ts",
@@ -0,0 +1,51 @@
1
+ ---
2
+ description: Run a bounded supervisor-mediated council of advisors and write a decision memo
3
+ argument-hint: "<question> [--advisors name,name] [--max-passes 2|3] [--scope ...] [--non-goals ...]"
4
+ ---
5
+
6
+ Run a bounded, supervisor-mediated council on this question. You, the parent
7
+ session, are the supervisor. You select the roster, curate cross-advisor packets,
8
+ decide which feedback is valid, and write the final memo. Advisors do not talk
9
+ directly or see peer transcripts by default. This is not free-form agent chat.
10
+
11
+ Before you orchestrate, read `skills/council-mode/SKILL.md` and
12
+ `skills/pi-subagents/references/execution-controls.md`.
13
+
14
+ Parse the invocation yourself. The flags below are conventions, not runtime
15
+ options. Record a brief with the question, scope, non-goals, evidence targets,
16
+ roster, known advisor context modes, and pass cap. Default `--max-passes` to 2.
17
+ Clamp it to 2 or 3. If the question is trivial or settled, answer directly instead
18
+ of convening a council.
19
+
20
+ ## Roster
21
+
22
+ - If `--advisors` is given, use exactly those agent names. Fail clearly on an
23
+ unknown agent. Do not require or invent per-advisor role labels.
24
+ - Otherwise list agents with `subagent({ action: "list" })`, then prefer 2–3
25
+ executable names that start with `council-`.
26
+ - If fewer than two profiles are available, fill the roster with `oracle`, then
27
+ `reviewer`, until it has two advisors. Launch fallback `oracle` with
28
+ `context: "fork"` so global defaults cannot remove its parent-chat context.
29
+ Let `reviewer` use its normal profile context. Note the fallback and known
30
+ context modes in the memo.
31
+ - Use the normal single-oracle loop only when a requested roster or unavailable
32
+ builtins leaves fewer than two advisors. Label the memo as degraded mode.
33
+
34
+ Profiles provide the model, tools, context, and advisor stance. The council
35
+ question and scope provide the decision frame. If the user wants a specific lens,
36
+ they should put it in the question, scope, or profile definition. Keep the roster
37
+ at 2–3 and never exceed 4.
38
+
39
+ ## Run the protocol
40
+
41
+ Use the canonical workflow, structured advisor contracts, aggregate pass receipts,
42
+ and memo requirements in `skills/council-mode/SKILL.md`. Keep the parent as the
43
+ only synthesizer and decision maker. Do not introduce a chair advisor, peer chat,
44
+ or transcript sharing.
45
+
46
+ Use its required boundary checkpoints, yield for each async workflow without
47
+ polling, and write its required final memo.
48
+
49
+ Question and options from the slash command invocation:
50
+
51
+ $@
@@ -0,0 +1,231 @@
1
+ ---
2
+ name: council-mode
3
+ description: Run a bounded supervisor-mediated advisor council. Use when the user asks for council mode, asks to convene advisors, debate a decision, cross-examine recommendations, or run /council.
4
+ ---
5
+
6
+ # Council Mode
7
+
8
+ This skill is for the parent supervisor only. Do not inject it into advisors. The
9
+ parent selects the roster, curates all cross-advisor communication, decides which
10
+ feedback is valid, and writes the decision memo. Advisors do not talk directly or
11
+ see peer transcripts by default. This is not free-form agent chat.
12
+
13
+ Use council mode for a material decision with real tradeoffs. Do not use it for a
14
+ trivial or settled question, or for implementation work. Read
15
+ `skills/pi-subagents/references/execution-controls.md` before you launch advisors.
16
+
17
+ ## Roster and limits
18
+
19
+ Use advisor profile names directly. A `council-*` profile defines model, tools,
20
+ context, output defaults, and any persistent stance in the profile body. Its
21
+ profile configuration or explicit invocation owns its context choice.
22
+
23
+ Create model-based profiles in your user or project agent directory. Do not add
24
+ them to this package. This is a valid example:
25
+
26
+ ```markdown
27
+ ---
28
+ name: council-sol
29
+ description: Read-only fresh-context advisor for bounded council decisions
30
+ tools: read, grep, find, ls
31
+ model: openai-codex/gpt-5.6-sol
32
+ thinking: high
33
+ systemPromptMode: replace
34
+ inheritProjectContext: true
35
+ inheritSkills: false
36
+ defaultContext: fresh
37
+ acceptanceRole: read-only
38
+ ---
39
+
40
+ Analyze the council question independently. Inspect evidence directly. Do not
41
+ edit, run mutating commands, commit, push, contact peers, or spawn subagents.
42
+ Return concise, cited advice using the report contract in the council task.
43
+ ```
44
+
45
+ After `subagent({ action: "list" })`, prefer 2–3 executable names that start with
46
+ `council-`. The prefix is a naming convention, not runtime selection. If fewer
47
+ than two profiles are available, fill the roster with `oracle`, then `reviewer`,
48
+ until it has two advisors. Launch fallback `oracle` with `context: "fork"` so
49
+ global defaults cannot remove its parent-chat context. Let fallback `reviewer`
50
+ use its normal profile context. Note the fallback and known context modes in the
51
+ memo. Use the normal single-oracle consultation loop only when a requested roster
52
+ or unavailable builtins leaves fewer than two advisors.
53
+ Label that result as degraded mode. Never use more than four advisors.
54
+
55
+ Pass 1 is independent reports. Pass 2 is one cross-exam. The default pass cap is
56
+ 2. Run pass 3 only when `--max-passes 3` was requested and a material dispute can
57
+ be settled by evidence an advisor can produce. Never run an unbounded loop.
58
+
59
+ ## Protocol
60
+
61
+ 1. The parent writes a brief with the question, scope, non-goals, evidence targets,
62
+ roster, known advisor context modes, and pass cap. If the user wants a specific
63
+ lens, keep it in the question, scope, or profile body instead of inventing a
64
+ per-advisor label.
65
+ 2. Before Pass 1, tell the user the roster, requested or known context modes, and
66
+ pass cap. Use a stable key, `phase`, and concise `label` for every
67
+ workflow child. For example, use `advisor-oracle`, `phase: "Council pass 1"`,
68
+ and `label: "Oracle — intent and consistency"`.
69
+ 3. Launch one async `workflowScript` with `runs.all` for independent advisor
70
+ reports. Set `context` when the selected advisor has a known profile context or
71
+ a fallback rule requests one, because a global default can otherwise override
72
+ that profile. Set `context: "fork"` for fallback `oracle`. If no advisor context
73
+ is known, omit `context` and disclose the unknown runtime default in the memo.
74
+ Each advisor is read-only and must not spawn children, edit files, run mutating
75
+ commands, commit, or push. Set `output: false` unless separate advisor artifacts
76
+ are explicitly requested or useful for the decision.
77
+ 4. Return one aggregate Pass 1 receipt. After it completes, tell the user the
78
+ completion count, agreement count, dispute count, and whether Pass 2 is needed.
79
+ 5. The parent synthesizes a claim matrix in session. It contains agreements,
80
+ disputed claims, missing proof, owner decisions, and a relay set of at most five
81
+ high-impact claims per advisor. Do not delegate this synthesis.
82
+ 6. Before Pass 2, tell the user how many claims are relayed and why each is
83
+ material. Launch a second async `workflowScript` with `runs.all` resume calls.
84
+ Each task is a curated challenge packet, not a peer transcript. A resume requires
85
+ a retained run id and a non-empty task. It excludes `agent` and rejects `gate`.
86
+ Record the new run id from every resume. Pass 3 resumes those latest ids. Return
87
+ one aggregate Pass 2 receipt.
88
+ 7. After Pass 2, tell the user whether the council converged or which owner
89
+ decisions remain. The parent writes the final memo. Do not delegate it.
90
+
91
+ If an advisor is not resumable, run the same profile in fresh context with its own
92
+ pass-1 report and the challenge packet. Label that response as a fresh-context
93
+ fallback, not a true cross-exam.
94
+
95
+ Do not set `clarify`, `worktree`, `gate`, turn budgets, tool budgets, or tight usage
96
+ budgets on advisors. Bound work through the roster, pass cap, and report length.
97
+
98
+ ## Advisor contracts and pass receipts
99
+
100
+ Pass-1 reports are at most about 600 words. Give each advisor the same
101
+ `outputSchema`, so reports are comparable without heading cleanup. The following
102
+ shape is a contract template. Use the runtime schema syntax supported by the
103
+ workflow and keep narrative fields as strings:
104
+
105
+ ```js
106
+ const pass1OutputSchema = {
107
+ type: "object",
108
+ required: [
109
+ "recommendation", "evidence", "assumptions", "risks", "confidence",
110
+ "challengeClaims", "ownerDecisions", "changeMyMind"
111
+ ],
112
+ properties: {
113
+ recommendation: { type: "string" },
114
+ evidence: {
115
+ type: "array",
116
+ items: {
117
+ type: "object",
118
+ required: ["claim", "sources"],
119
+ properties: {
120
+ claim: { type: "string" },
121
+ sources: { type: "array", items: { type: "string" } }
122
+ }
123
+ }
124
+ },
125
+ assumptions: {
126
+ type: "array",
127
+ items: {
128
+ type: "object",
129
+ required: ["assumption", "status"],
130
+ properties: {
131
+ assumption: { type: "string" },
132
+ status: { enum: ["verified", "unverified"] }
133
+ }
134
+ }
135
+ },
136
+ risks: { type: "array", items: { type: "string" } },
137
+ confidence: {
138
+ type: "object",
139
+ required: ["level", "reason"],
140
+ properties: {
141
+ level: { enum: ["high", "medium", "low"] },
142
+ reason: { type: "string" }
143
+ }
144
+ },
145
+ challengeClaims: { type: "array", items: { type: "string" }, maxItems: 3 },
146
+ ownerDecisions: { type: "array", items: { type: "string" } },
147
+ changeMyMind: { type: "array", items: { type: "string" } }
148
+ }
149
+ };
150
+ ```
151
+
152
+ Include this contract in each Pass 1 task: inspect supplied evidence directly; do
153
+ not see or ask about other advisors; stay read-only; do not spawn children; return
154
+ only the structured report.
155
+
156
+ After `runs.all`, return one aggregate receipt rather than making the parent find
157
+ separate artifacts. Preserve the result order or map it by stable key so each row
158
+ contains the advisor identity and report:
159
+
160
+ ```js
161
+ return {
162
+ pass: 1,
163
+ advisors: results.map((result, index) => ({
164
+ key: result.key,
165
+ agent: result.agent,
166
+ requestedContext: roster[index].context ?? "runtime-default-unknown",
167
+ runId: result.runId,
168
+ report: result.structuredOutput
169
+ }))
170
+ };
171
+ ```
172
+
173
+ Do not replace `runtime-default-unknown` with a guessed context. It records that
174
+ the launch intentionally omitted context.
175
+
176
+ A challenge packet contains only disputed claims, strong conflicting evidence,
177
+ missing proof, owner decisions, and high-impact risks. Attribute peer content as
178
+ "another advisor". Do not include full peer reports. Use a common Pass 2 contract:
179
+
180
+ ```js
181
+ const pass2OutputSchema = {
182
+ type: "object",
183
+ required: ["responses", "recommendationChanged", "outOfScopeFindings"],
184
+ properties: {
185
+ responses: {
186
+ type: "array",
187
+ items: {
188
+ type: "object",
189
+ required: ["claimId", "disposition", "reason", "sources"],
190
+ properties: {
191
+ claimId: { type: "string" },
192
+ disposition: {
193
+ enum: ["accept", "reject", "refine", "owner-decision"]
194
+ },
195
+ reason: { type: "string" },
196
+ sources: { type: "array", items: { type: "string" } }
197
+ }
198
+ }
199
+ },
200
+ recommendationChanged: {
201
+ type: "object",
202
+ required: ["changed", "reason"],
203
+ properties: { changed: { type: "boolean" }, reason: { type: "string" } }
204
+ },
205
+ outOfScopeFindings: { type: "array", items: { type: "string" } }
206
+ }
207
+ };
208
+ ```
209
+
210
+ Use stable resume keys such as `cross-oracle`, `phase: "Council pass 2"`, concise
211
+ labels, and `output: false` unless separate artifacts are requested or useful. The
212
+ aggregate Pass 2 receipt uses the same row shape as Pass 1, with the new `runId`
213
+ and `structuredOutput`.
214
+
215
+ ## Stop and memo
216
+
217
+ Converged means no disputed claim remains that both materially affects the
218
+ recommendation and can plausibly be settled by evidence. Stop at convergence, the
219
+ pass cap, failed fallback, or user interruption. Put unresolved disputes in owner
220
+ decisions. Never add a round for polish or symmetry.
221
+
222
+ The parent memo states the question and scope, recommendation, rationale, accepted
223
+ and rejected feedback with reasons, owner decisions, evidence and run ids,
224
+ confidence, what would change the decision, and the roster, passes, fallbacks, and
225
+ known advisor context modes. Identify advisors by profile name or model-based
226
+ profile, not by invented role labels. State that fallback `oracle` is context-aware
227
+ and forked.
228
+
229
+ Council mode is not agent-to-agent chat, a transcript dump, mutation authority,
230
+ auto-escalation to writer lanes, or a council UI. Escalate to a writer only after
231
+ the parent memo and only when the user explicitly requests it.
@@ -14,6 +14,8 @@ This skill is for the main parent orchestrator only. Do not inject or follow it
14
14
 
15
15
  Use this skill when the parent orchestrator needs one specialized child or composed orchestration. Use `workflowScript` for all execution, including one isolated child. Chaining is still supported, but it is code-driven: use `await runs.run(...)` for sequential steps, `runs.all([...])` for parallel fanout, and ordinary JavaScript for branching, retries, gate monitors, and aggregation. Keep workflow helpers portable: use plain helper functions or explicit Promise chains, not nested `async function` helpers, async arrows, or async methods. Do not use legacy top-level `chain` / `tasks` inputs or durable `.chain.md` execution. Scripted workflows normally start asynchronously unless config sets `asyncByDefault:false`; set `async:true` explicitly when async behavior matters. Pass `async:false` only when the parent must block until completion. Async mode still shows progress. Do not use `async:false` for final reviews, backlog gates, run-to-completion convenience, or because no other work is available.
16
16
 
17
+ Package-installed agents appear in `subagent({ action: "list" })` with builtin, user, and project agents. If `surf-cli` is installed as a Pi package, the Surf browser extension is loaded, and Chrome is logged into a ChatGPT Pro account, Surf can expose `gpt-pro`: a read-only async advisor that reaches ChatGPT web through Surf Oracle. Check it with `subagent({ action: "get", agent: "gpt-pro" })` and run it with `subagent({ agent: "gpt-pro", task: "Review this plan and identify release risks." })`.
18
+
17
19
  ## How to use this router
18
20
 
19
21
  Read the matching reference file before acting. Paths are relative to this `SKILL.md`; resolve them against `skills/pi-subagents/` and load them with the read tool.
@@ -21,6 +23,7 @@ Read the matching reference file before acting. Paths are relative to this `SKIL
21
23
  | Task | Read |
22
24
  | --- | --- |
23
25
  | Decide whether to delegate, choose agents, compare tool versus slash commands, apply prompt techniques, or understand builtin roles | `references/prompting-and-roles.md` |
26
+ | Use council mode, convene several advisors, debate a decision, cross-examine recommendations, critique or improve a plan with multiple model perspectives, or run `/council` | `../council-mode/SKILL.md` |
24
27
  | Run one-child, scripted, async, scheduled, mission-backed, forked, watchdog, oracle, or intercom-coordinated workflows | `references/execution-controls.md` |
25
28
  | Coordinate several independent tasks, worktrees, repositories, or writer lanes | `references/multi-lane-orchestration.md` |
26
29
  | List/create/update/delete/eject/disable agents, inspect legacy chain records, edit agent files, use prompt-template integration, or expose extension RPC | `references/management-authoring-rpc.md` |
@@ -32,7 +35,8 @@ For broad or uncertain requests, read more than one reference. For complex work,
32
35
 
33
36
  - Keep the parent as orchestrator and final decision-maker.
34
37
  - Before multiple mutation-capable lanes, record a lane board and each lane's isolation path.
35
- - For plan, design, or architecture advice that asks to consult, discuss with, or come to agreement with `oracle`, use a short same-session consultation loop: read the first result, resume once with a targeted challenge when material tradeoffs remain, then synthesize the parent decision. Keep explicit one-shot, trivial, and fully settled consultations one-shot.
38
+ - For plan, design, or architecture advice that asks for council mode, asks to convene several advisors, compare model perspectives, debate a decision, cross-examine recommendations, or critique and improve a plan, read `../council-mode/SKILL.md` and use Council Mode instead of ad hoc parallel oracle calls.
39
+ - For plan, design, or architecture advice that asks to consult, discuss with, or come to agreement with one `oracle`, use a short same-session consultation loop: read the first result, resume once with a targeted challenge when material tradeoffs remain, then synthesize the parent decision. Keep explicit one-shot, trivial, and fully settled consultations one-shot.
36
40
  - Use one writer per cwd/worktree unless isolated worktrees are intentional.
37
41
  - For cross-codebase work, record the target repo, explicit `cwd`, authority boundary, and expected output before launch. Do not assume the parent session cwd is the child repo.
38
42
  - For parallel fanout, compare child prompts before launch. Do not send clone prompts with only issue numbers, titles, or broad file globs swapped; each child needs a lane-specific task, source seam, prior evidence, and decision that remains distinct without the item number. Launch that fanout as one async `workflowScript` with stable keys and aggregate output unless there is truly only one child.
@@ -36,6 +36,7 @@ In an interactive chat, do not call `subagent_wait()` merely to wait after launc
36
36
  - `subagent_wait()` — return when the next initially active async run or registered provider item finishes, or a subagent needs attention.
37
37
  - `subagent_wait({ all: true })` — block until every async run and provider item active at call time finishes, or a subagent needs attention.
38
38
  - `subagent_wait({ id: "..." })` — block on one async or remembered detached foreground run (id or prefix). Provider items are not selected through this parameter.
39
+ - `subagent_wait({ stopOnAttention: false })` — for blocking waits only, keep waiting through idle or long-thinking attention; supervisor/contact requests still stop the wait.
39
40
  - `subagent_wait({ timeoutMs })` — cap the block; active work keeps running if it elapses.
40
41
 
41
42
  Providers are discovered through the `pi-subagents/background-work` registry and must return stable item IDs with exact owning session IDs. Child agents receive no provider automatically: keep `subagent_wait` in the child `tools` allowlist and load provider extensions through `extensions` or `subagentOnlyExtensions`.
@@ -78,10 +78,23 @@ subagent({
78
78
 
79
79
  Scripts run in a timed worker with only `runs.run`, `runs.all`, `runs.status`, `runs.ref/refs`, `emit`, captured `console`, and standard JavaScript. Pass explicit task text to `runs.run`. Mission-attached workflows also get `await state.get(key)` and `await state.set(key, value)` for durable JSON state shared across workflows on the same mission; `mission: false` workflows have no `state` global. Stable keys are required. Child launches follow ordinary single-agent execution controls. Give each child a distinct decision and output path when reports must outlive the workflow, then consume the aggregate workflow result before opening individual reports.
80
80
 
81
+ If `runs.all` is missing in a running session, reload or update `pi-subagents` before retrying. The current runtime supports `runs.all`; `await Promise.all([runs.run(...)])` is also supported for advanced dynamic fanout.
82
+
81
83
  For one host-run verification command, pass `gate: "npm test"` on a `runs.run`/`runs.all` item (or at the top level as a workflow default). It is shorthand for verified acceptance with that single command: the runtime executes it on the host, records the result as evidence, and memoizes it per tracked workspace state and effective environment. `gate` cannot be combined with `acceptance`; use explicit `acceptance.verify` for multiple commands or custom criteria.
82
84
 
83
85
  Completed workflow children from this parent session stay addressable as retained children. `subagent({ action: "children.list" })` lists up to the last 10 with run ids and reports each row as `resumable` or `not resumable` with a reason. Resume only rows reported `resumable`. For a retained-child challenge, use `resume` instead of `steer` when the child is complete. If no retained child is resumable, launch a same-role fallback challenge and label it as fallback. A later workflow continues a resumable child with `runs.run(key, { resume: "<run-id>", task: "follow-up" })`. Inside `workflowScript`, awaiting that call waits for the revived child to finish and returns its completed output and new `runId`; top-level `{ action: "resume" }` remains detached. Pass explicit follow-up task text. Assign each returned child result back to the loop variable because every resume can return a new retained `runId`; always resume the latest returned id. `resume` and `agent` are mutually exclusive, the revived child keeps its stored agent/model/tool contract, and `gate` is rejected on retained resume items.
84
86
 
87
+ Terminal async workflows also persist `workflow-receipt.json` beside `status.json`. It maps each stable child key to its agent, requested and resolved context when known, latest run id, resumability, output reference, and continuation lineage. A later workflow can resume the latest retained child without copying its run id:
88
+
89
+ ```js
90
+ return runs.run("cross-oracle", {
91
+ resume: { workflowRunId: "<pass-1-workflow-id>", key: "advisor-oracle", latest: true },
92
+ task: "Review the focused challenge packet."
93
+ });
94
+ ```
95
+
96
+ Keyed resume reads that one exact receipt and revalidates the retained run at launch. It fails when the workflow or key is missing, the receipt is stale, `latest` is not `true`, or the recorded child is no longer resumable. Foreground workflow results expose the same receipt in `details.workflow.receipt`, but cross-workflow keyed lookup requires the durable receipt from an async workflow.
97
+
85
98
  ### Async/background
86
99
 
87
100
  Prefer async mode for every subagent launch. Set `async: true` no matter the task unless the parent must block until completion. This applies to scouts, researchers, workers, reviewers, validators, oracle checks, one-off delegates, final review gates, backlog gates, and scripted workflows. Keep the write path single-threaded even when the run is async.
@@ -44,11 +44,18 @@ Packaged prompt shortcuts are also available for repeatable workflows. Treat the
44
44
  - `/parallel-research` — combine `researcher` and `scout` for external evidence plus local code context
45
45
  - `/gather-context-and-clarify` — scout/research first, then ask the user clarifying questions with `interview`
46
46
  - `/parallel-cleanup` — two fresh-context reviewers (deslop + verbosity passes) for an adversarial cleanup review of the current diff
47
+ - `/council` — bounded advisor council for material decisions, plan critique, cross-exam, and parent-written decision memos
47
48
 
48
49
  ## Applying Prompt Techniques Without Slash Commands
49
50
 
50
51
  The prompt templates in `prompts/` encode workflows the parent agent can run on demand. If the user provides a URL, issue, PR, plan, local file, screenshot, or freeform target, treat that target as the primary scope: read or fetch it before launching children, then include it explicitly in every child task. For targets outside the parent cwd, include the exact repository, explicit `cwd`, authority boundary, and expected output path in each child task. Do not depend on the parent conversation history when the recipe calls for fresh context.
51
52
 
53
+ ### Council Mode technique
54
+
55
+ Use Council Mode when the user asks to convene advisors, debate a material decision, cross-examine recommendations, or critique and improve a plan with several model perspectives. This includes requests such as “run a council on this architecture,” “have Sol, Fable, and Kimi critique this plan,” or “get multiple oracles to debate the tradeoffs.” Read `../council-mode/SKILL.md` and follow its bounded parent-supervised protocol instead of launching ad hoc parallel oracle calls.
56
+
57
+ Council advisors are read-only. User or project `council-*` profiles can pin models such as GPT 5.6 Sol, Fable, or Kimi and define any persistent stance in the profile body. The council question and scope provide the decision frame; do not invent per-advisor role labels. The parent collects independent reports, optionally sends curated cross-exam packets, and writes the final memo. Do not treat the council as agent-to-agent chat, implementation authority, or a writer swarm.
58
+
52
59
  ### Parallel review technique
53
60
 
54
61
  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. The parent synthesizes fixes worth doing now, optional improvements, and feedback to ignore/defer before applying anything.