pi-subagents 0.59.0 → 0.61.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 (72) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/docs/agents.md +2 -2
  3. package/docs/configuration.md +9 -5
  4. package/docs/extension-api.md +14 -7
  5. package/docs/models.md +1 -1
  6. package/docs/observability.md +1 -1
  7. package/docs/tool-reference.md +15 -3
  8. package/docs/workflows.md +15 -14
  9. package/install.mjs +2 -1
  10. package/package.json +1 -1
  11. package/skills/council-mode/SKILL.md +48 -243
  12. package/skills/council-mode/references/pass-contracts.md +150 -0
  13. package/skills/pi-subagents/SKILL.md +89 -37
  14. package/skills/pi-subagents/references/constraints-and-recipes.md +30 -234
  15. package/skills/pi-subagents/references/execution-controls.md +79 -7
  16. package/skills/pi-subagents/references/management-authoring-rpc.md +2 -2
  17. package/skills/pi-subagents/references/multi-lane-orchestration.md +13 -1
  18. package/skills/pi-subagents/references/prompting-and-roles.md +35 -28
  19. package/skills/pi-subagents/references/review-and-validation.md +73 -0
  20. package/src/agents/agent-management.ts +256 -88
  21. package/src/agents/agents.ts +527 -221
  22. package/src/api/background-work.ts +7 -2
  23. package/src/api/external-runs.ts +67 -4
  24. package/src/api/preflight.ts +13 -8
  25. package/src/api/shared-types.ts +3 -0
  26. package/src/extension/index.ts +7 -4
  27. package/src/extension/public-execution.ts +48 -4
  28. package/src/extension/rpc.ts +62 -4
  29. package/src/extension/schemas.ts +12 -7
  30. package/src/extension/tool-description.ts +16 -16
  31. package/src/runs/background/async-execution.ts +53 -37
  32. package/src/runs/background/async-job-tracker.ts +65 -3
  33. package/src/runs/background/async-resume.ts +3 -1
  34. package/src/runs/background/async-status.ts +104 -11
  35. package/src/runs/background/auto-drain.ts +1 -1
  36. package/src/runs/background/control-channel.ts +3 -2
  37. package/src/runs/background/fleet-view.ts +1 -1
  38. package/src/runs/background/result-watcher.ts +1 -1
  39. package/src/runs/background/resume-guidance.ts +1 -1
  40. package/src/runs/background/run-status.ts +15 -4
  41. package/src/runs/background/subagent-runner.ts +6 -3
  42. package/src/runs/background/subagent-wait.ts +30 -23
  43. package/src/runs/background/wait-completions.ts +4 -1
  44. package/src/runs/background/wait-tool.ts +24 -18
  45. package/src/runs/foreground/execution.ts +72 -4
  46. package/src/runs/foreground/subagent-executor.ts +276 -59
  47. package/src/runs/shared/acceptance.ts +43 -18
  48. package/src/runs/shared/async-status-projection.ts +138 -4
  49. package/src/runs/shared/background-process-options.ts +9 -0
  50. package/src/runs/shared/host-step-status.ts +1 -0
  51. package/src/runs/shared/mcp-direct-tool-grant.ts +2 -5
  52. package/src/runs/shared/model-fallback.ts +61 -17
  53. package/src/runs/shared/mutation-evidence.ts +52 -3
  54. package/src/runs/shared/permissions.ts +1 -1
  55. package/src/runs/shared/pi-args.ts +47 -1
  56. package/src/runs/shared/single-output.ts +45 -18
  57. package/src/runs/shared/subagent-prompt-runtime.ts +20 -2
  58. package/src/runs/shared/tool-timeout.ts +1 -1
  59. package/src/runs/shared/workflow-graph.ts +16 -0
  60. package/src/shared/types.ts +74 -4
  61. package/src/shared/workflow-child-permit.ts +91 -0
  62. package/src/slash/prompt-template-bridge.ts +37 -1
  63. package/src/slash/slash-commands.ts +18 -26
  64. package/src/tui/fleet-status.ts +11 -3
  65. package/src/tui/render-helpers.ts +31 -0
  66. package/src/tui/render.ts +673 -145
  67. package/src/watchdog/change-signature.ts +40 -1
  68. package/src/workflows/host-command.ts +6 -1
  69. package/src/workflows/scripted-workflow.ts +206 -6
  70. package/src/workflows/workflow-child-summary.ts +1 -1
  71. package/src/workflows/workflow-receipt.ts +41 -4
  72. package/src/workflows/workflow-resources.ts +150 -0
@@ -5,250 +5,55 @@ description: Run a bounded supervisor-mediated advisor council. Use when the use
5
5
 
6
6
  # Council Mode
7
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
- Package advisors can also join the roster only when their package Pi extension is
24
- installed and their external-job provider is registered. For Surf, `gpt-pro` is
25
- available only after the `surf-cli` Pi extension loads Surf's `surf-oracle`
26
- provider. Treat it as a normal advisor name in `runs.all` after that provider is
27
- visible. It is background-only, so omit `async` unless you explicitly want
28
- detached receipt semantics; workflow execution will await the terminal provider
29
- result. External runners can lack repo tools, structured-output support, or
30
- resumability. For them, include the needed evidence or file excerpts in the task,
31
- use the text JSON contract below instead of `outputSchema`, and use the
32
- fresh-context fallback path for cross-exam when the run is not resumable.
33
-
34
- Create model-based profiles in your user or project agent directory. Do not add
35
- them to this package. This is a valid example:
36
-
37
- ```markdown
38
- ---
39
- name: council-sol
40
- description: Read-only fresh-context advisor for bounded council decisions
41
- tools: read, grep, find, ls
42
- model: openai-codex/gpt-5.6-sol
43
- thinking: high
44
- systemPromptMode: replace
45
- inheritProjectContext: true
46
- inheritSkills: false
47
- defaultContext: fresh
48
- acceptanceRole: read-only
49
- ---
8
+ Council mode is parent-supervised advice for a material decision with real tradeoffs. It is not free-form agent chat, implementation work, a transcript dump, mutation authority, or a council UI.
9
+
10
+ The parent selects the roster, relays only curated claims, decides validity, and writes the memo. Advisors stay read-only and do not see peer transcripts by default.
11
+
12
+ Before launch, read:
13
+
14
+ - `skills/pi-subagents/references/execution-controls.md`
15
+ - `skills/council-mode/references/pass-contracts.md`
16
+
17
+ ## Roster
18
+
19
+ Run `subagent({ action: "list" })`, then choose 2-3 executable advisor names that start with `council-`. The prefix is convention only. Never use more than four advisors.
20
+
21
+ If fewer than two council profiles are available, fill with `oracle`, then `reviewer`. Launch fallback `oracle` with `context: "fork"`; let fallback `reviewer` use its normal profile context. Note fallbacks and known context modes in the memo. If fewer than two advisors remain, use the normal one-oracle consultation loop and label it degraded mode.
22
+
23
+ `council-*` profiles live in user or project agent directories, not this package. A profile defines model, tools, context, output defaults, and persistent stance. Keep advisors read-only, disable inherited skills unless needed, and put stance in the profile body instead of inventing per-run role labels.
50
24
 
51
- Analyze the council question independently. Inspect evidence directly. Do not
52
- edit, run mutating commands, commit, push, contact peers, or spawn subagents.
53
- Return concise, cited advice using the report contract in the council task.
54
- ```
55
-
56
- After `subagent({ action: "list" })`, prefer 2–3 executable names that start with
57
- `council-`. The prefix is a naming convention, not runtime selection. If fewer
58
- than two profiles are available, fill the roster with `oracle`, then `reviewer`,
59
- until it has two advisors. Launch fallback `oracle` with `context: "fork"` so
60
- global defaults cannot remove its parent-chat context. Let fallback `reviewer`
61
- use its normal profile context. Note the fallback and known context modes in the
62
- memo. Use the normal single-oracle consultation loop only when a requested roster
63
- or unavailable builtins leaves fewer than two advisors.
64
- Label that result as degraded mode. Never use more than four advisors.
65
-
66
- Pass 1 is independent reports. Pass 2 is one cross-exam. The default pass cap is
67
- 2. Run pass 3 only when `--max-passes 3` was requested and a material dispute can
68
- be settled by evidence an advisor can produce. Never run an unbounded loop.
25
+ External-job/package advisors may join only when their provider is registered. Treat them as ordinary advisor names in `runs.all`, but honor their runner limits: they may lack repo tools, structured output, or resumability. Include evidence they cannot read, request JSON text instead of `outputSchema`, and use a fresh-context fallback when they cannot resume for cross-exam.
26
+
27
+ ## Passes
28
+
29
+ Pass 1 is independent reports. Pass 2 is one cross-exam. Run Pass 3 only when `--max-passes 3` was requested and a material dispute can still be settled by evidence. Never run an unbounded loop.
69
30
 
70
31
  ## Protocol
71
32
 
72
- 1. The parent writes a brief with the question, scope, non-goals, evidence targets,
73
- roster, known advisor context modes, and pass cap. If the user wants a specific
74
- lens, keep it in the question, scope, or profile body instead of inventing a
75
- per-advisor label.
76
- 2. Before Pass 1, tell the user the roster, requested or known context modes, and
77
- pass cap. Use a stable key, `phase`, and concise `label` for every
78
- workflow child. For example, use `advisor-oracle`, `phase: "Council pass 1"`,
79
- and `label: "Oracle — intent and consistency"`.
80
- 3. Launch one async `workflowScript` with `runs.all` for independent advisor
81
- reports. Set `context` when the selected advisor has a known profile context or
82
- a fallback rule requests one, because a global default can otherwise override
83
- that profile. Set `context: "fork"` for fallback `oracle`. If no advisor context
84
- is known, omit `context` and disclose the unknown runtime default in the memo.
85
- Each advisor is read-only and must not spawn children, edit files, run mutating
86
- commands, commit, or push. Set `output: false` unless separate advisor artifacts
87
- are explicitly requested or useful for the decision. When separate artifacts are
88
- useful, give advisors relative output paths so the runtime stores them under its
89
- managed artifact directory; do not ask them to write root-level council report
90
- files. For installed
91
- external-runner advisors such as Surf `gpt-pro` after `surf-oracle` is
92
- registered, do not pass `outputSchema`; put the schema request in the task text
93
- and accept `result.output` as the report.
94
- 4. Return one aggregate Pass 1 receipt. After it completes, tell the user the
95
- completion count, agreement count, dispute count, and whether Pass 2 is needed.
96
- 5. The parent synthesizes a claim matrix in session. It contains agreements,
97
- disputed claims, missing proof, owner decisions, and a relay set of at most five
98
- high-impact claims per advisor. Do not delegate this synthesis.
99
- 6. Before Pass 2, tell the user how many claims are relayed and why each is
100
- material. Launch a second async `workflowScript` with `runs.all` resume calls.
101
- Each task is a curated challenge packet, not a peer transcript. A resume requires
102
- a retained run id and a non-empty task. It excludes `agent` and rejects `gate`.
103
- Record the new run id from every resume. Pass 3 resumes those latest ids. Return
104
- one aggregate Pass 2 receipt.
105
- 7. After Pass 2, tell the user whether the council converged or which owner
106
- decisions remain. The parent writes the final memo. Do not delegate it.
107
-
108
- If an advisor is not resumable, run the same profile in fresh context with its own
109
- pass-1 report and the challenge packet. Label that response as a fresh-context
110
- fallback, not a true cross-exam.
111
-
112
- Do not set `clarify`, `worktree`, `gate`, tool budgets, or tight usage
113
- budgets on advisors. Bound work through the roster, pass cap, and report length.
114
-
115
- ## Advisor contracts and pass receipts
116
-
117
- Pass-1 reports are at most about 600 words. Give native Pi advisors the same
118
- `outputSchema`, so reports are comparable without heading cleanup. For
119
- external-runner advisors, do not pass `outputSchema`; ask them to return compact
120
- JSON text with the same fields. The following shape is a contract template. Use
121
- the runtime schema syntax supported by the workflow for native advisors and keep
122
- narrative fields as strings:
123
-
124
- ```js
125
- const pass1OutputSchema = {
126
- type: "object",
127
- required: [
128
- "recommendation", "evidence", "assumptions", "risks", "confidence",
129
- "challengeClaims", "ownerDecisions", "changeMyMind"
130
- ],
131
- properties: {
132
- recommendation: { type: "string" },
133
- evidence: {
134
- type: "array",
135
- items: {
136
- type: "object",
137
- required: ["claim", "sources"],
138
- properties: {
139
- claim: { type: "string" },
140
- sources: { type: "array", items: { type: "string" } }
141
- }
142
- }
143
- },
144
- assumptions: {
145
- type: "array",
146
- items: {
147
- type: "object",
148
- required: ["assumption", "status"],
149
- properties: {
150
- assumption: { type: "string" },
151
- status: { enum: ["verified", "unverified"] }
152
- }
153
- }
154
- },
155
- risks: { type: "array", items: { type: "string" } },
156
- confidence: {
157
- type: "object",
158
- required: ["level", "reason"],
159
- properties: {
160
- level: { enum: ["high", "medium", "low"] },
161
- reason: { type: "string" }
162
- }
163
- },
164
- challengeClaims: { type: "array", items: { type: "string" }, maxItems: 3 },
165
- ownerDecisions: { type: "array", items: { type: "string" } },
166
- changeMyMind: { type: "array", items: { type: "string" } }
167
- }
168
- };
169
- ```
170
-
171
- Include this contract in each Pass 1 task: inspect supplied evidence directly; do
172
- not see or ask about other advisors; stay read-only; do not spawn children; return
173
- only the structured report. For external-runner advisors, say `Return only JSON
174
- matching this shape. Do not wrap it in Markdown.` and include any evidence they
175
- cannot read through tools.
176
-
177
- After `runs.all`, return one aggregate receipt rather than making the parent find
178
- separate artifacts. Preserve the result order or map it by stable key so each row
179
- contains the advisor identity and report:
180
-
181
- ```js
182
- return {
183
- pass: 1,
184
- advisors: results.map((result, index) => ({
185
- key: result.key,
186
- agent: result.agent,
187
- requestedContext: roster[index].context ?? "runtime-default-unknown",
188
- runId: result.runId,
189
- report: result.structuredOutput ?? result.output
190
- }))
191
- };
192
- ```
193
-
194
- Do not replace `runtime-default-unknown` with a guessed context. It records that
195
- the launch intentionally omitted context.
196
-
197
- A challenge packet contains only disputed claims, strong conflicting evidence,
198
- missing proof, owner decisions, and high-impact risks. Attribute peer content as
199
- "another advisor". Do not include full peer reports. Use a common Pass 2 contract:
200
-
201
- ```js
202
- const pass2OutputSchema = {
203
- type: "object",
204
- required: ["responses", "recommendationChanged", "outOfScopeFindings"],
205
- properties: {
206
- responses: {
207
- type: "array",
208
- items: {
209
- type: "object",
210
- required: ["claimId", "disposition", "reason", "sources"],
211
- properties: {
212
- claimId: { type: "string" },
213
- disposition: {
214
- enum: ["accept", "reject", "refine", "owner-decision"]
215
- },
216
- reason: { type: "string" },
217
- sources: { type: "array", items: { type: "string" } }
218
- }
219
- }
220
- },
221
- recommendationChanged: {
222
- type: "object",
223
- required: ["changed", "reason"],
224
- properties: { changed: { type: "boolean" }, reason: { type: "string" } }
225
- },
226
- outOfScopeFindings: { type: "array", items: { type: "string" } }
227
- }
228
- };
229
- ```
230
-
231
- Use stable resume keys such as `cross-oracle`, `phase: "Council pass 2"`, concise
232
- labels, and `output: false` unless separate artifacts are requested or useful. Keep
233
- any artifact outputs under the managed run artifact directory. Do not pass
234
- `outputSchema` to external-runner fallback launches; ask for compact JSON text
235
- instead. The aggregate Pass 2 receipt uses the same row shape as Pass 1, with the
236
- new `runId` and `structuredOutput ?? output`.
237
-
238
- ## Stop and memo
239
-
240
- Converged means no disputed claim remains that both materially affects the
241
- recommendation and can plausibly be settled by evidence. Stop at convergence, the
242
- pass cap, failed fallback, or user interruption. Put unresolved disputes in owner
243
- decisions. Never add a round for polish or symmetry.
244
-
245
- The parent memo states the question and scope, recommendation, rationale, accepted
246
- and rejected feedback with reasons, owner decisions, evidence and run ids,
247
- confidence, what would change the decision, and the roster, passes, fallbacks, and
248
- known advisor context modes. Identify advisors by profile name or model-based
249
- profile, not by invented role labels. State that fallback `oracle` is context-aware
250
- and forked.
251
-
252
- Council mode is not agent-to-agent chat, a transcript dump, mutation authority,
253
- auto-escalation to writer lanes, or a council UI. Escalate to a writer only after
254
- the parent memo and only when the user explicitly requests it.
33
+ 1. Write the council brief: question, scope, non-goals, evidence targets, roster, known advisor context modes, and pass cap.
34
+ 2. Tell the user the roster, context modes, and pass cap.
35
+ 3. Launch one async `workflowScript` with `runs.all` for Pass 1. Use stable keys, `phase: "Council pass 1"`, concise labels, and `output: false` unless separate artifacts are useful. Set `context` only when the profile context is known or a fallback rule requires it.
36
+ 4. Return one aggregate Pass 1 receipt. On completion, tell the user completion count, agreement count, dispute count, and whether Pass 2 is needed.
37
+ 5. Synthesize the claim matrix in the parent: agreements, disputed claims, missing proof, owner decisions, and at most five material relay claims per advisor.
38
+ 6. For Pass 2, tell the user which claims are relayed and why they matter. Resume each advisor with a curated challenge packet. A resume needs a retained run id and task; it excludes `agent` and rejects `gate`. Record each new run id; Pass 3 resumes those latest ids with new stable keys.
39
+ 7. Stop at convergence, pass cap, failed fallback, or user interruption. The parent writes the final memo.
40
+
41
+ If an advisor is not resumable, run the same profile fresh with its Pass 1 report and challenge packet. Label it a fresh-context fallback, not true cross-exam.
42
+
43
+ Do not set `clarify`, `worktree`, `gate`, tool budgets, or tight usage budgets on advisors. Bound work through the roster, pass cap, and report length.
44
+
45
+ ## Memo
46
+
47
+ Converged means no disputed claim remains that both affects the recommendation and can plausibly be settled by advisor evidence. Put unresolved disputes in owner decisions. Do not add a round for polish or symmetry.
48
+
49
+ The memo states:
50
+
51
+ - question and scope
52
+ - recommendation and rationale
53
+ - accepted and rejected feedback with reasons
54
+ - owner decisions
55
+ - evidence and run ids
56
+ - confidence and what would change the decision
57
+ - roster, passes, fallbacks, and known advisor context modes
58
+
59
+ Identify advisors by profile name. State when fallback `oracle` was forked and context-aware. Escalate to a writer only after the memo and only when the user requests it.
@@ -0,0 +1,150 @@
1
+ # Council Mode Pass Contracts
2
+
3
+ Load this before launching council advisors.
4
+
5
+ ## Pass 1 report
6
+
7
+ Native Pi advisors should receive this `outputSchema`. External runners should receive the same shape as plain JSON text and no `outputSchema`.
8
+
9
+ ```js
10
+ const pass1OutputSchema = {
11
+ type: "object",
12
+ required: [
13
+ "recommendation",
14
+ "evidence",
15
+ "assumptions",
16
+ "risks",
17
+ "confidence",
18
+ "challengeClaims",
19
+ "ownerDecisions",
20
+ "changeMyMind"
21
+ ],
22
+ properties: {
23
+ recommendation: { type: "string" },
24
+ evidence: {
25
+ type: "array",
26
+ items: {
27
+ type: "object",
28
+ required: ["claim", "sources"],
29
+ properties: {
30
+ claim: { type: "string" },
31
+ sources: { type: "array", items: { type: "string" } }
32
+ }
33
+ }
34
+ },
35
+ assumptions: {
36
+ type: "array",
37
+ items: {
38
+ type: "object",
39
+ required: ["assumption", "status"],
40
+ properties: {
41
+ assumption: { type: "string" },
42
+ status: { enum: ["verified", "unverified"] }
43
+ }
44
+ }
45
+ },
46
+ risks: { type: "array", items: { type: "string" } },
47
+ confidence: {
48
+ type: "object",
49
+ required: ["level", "reason"],
50
+ properties: {
51
+ level: { enum: ["high", "medium", "low"] },
52
+ reason: { type: "string" }
53
+ }
54
+ },
55
+ challengeClaims: { type: "array", items: { type: "string" }, maxItems: 3 },
56
+ ownerDecisions: { type: "array", items: { type: "string" } },
57
+ changeMyMind: { type: "array", items: { type: "string" } }
58
+ }
59
+ };
60
+ ```
61
+
62
+ Task text:
63
+
64
+ - inspect supplied evidence directly
65
+ - do not ask other advisors or read peer reports
66
+ - stay read-only
67
+ - do not spawn children
68
+ - return only the structured report
69
+ - keep the report under about 600 words
70
+
71
+ For external runners, say: `Return only JSON matching this shape. Do not wrap it in Markdown.` Include any evidence they cannot read with tools.
72
+
73
+ ## Pass 1 aggregate receipt
74
+
75
+ Return one aggregate receipt. Preserve result order or map it by stable key.
76
+
77
+ ```js
78
+ return {
79
+ pass: 1,
80
+ advisors: results.map((result, index) => ({
81
+ key: result.key,
82
+ agent: result.agent,
83
+ requestedContext: roster[index].context ?? "runtime-default-unknown",
84
+ runId: result.runId,
85
+ report: result.structuredOutput ?? result.output
86
+ }))
87
+ };
88
+ ```
89
+
90
+ Do not replace `runtime-default-unknown` with a guessed context.
91
+
92
+ ## Pass 2 challenge
93
+
94
+ A challenge packet contains only disputed claims, strong conflicting evidence, missing proof, owner decisions, and high-impact risks. Attribute peer content as "another advisor". Do not include full peer reports.
95
+
96
+ Native Pi advisors receive `pass2OutputSchema`. External runners and fresh external fallbacks receive the same shape as JSON-only task text and no `outputSchema`.
97
+
98
+ ```js
99
+ const pass2OutputSchema = {
100
+ type: "object",
101
+ required: ["responses", "recommendationChanged", "outOfScopeFindings"],
102
+ properties: {
103
+ responses: {
104
+ type: "array",
105
+ items: {
106
+ type: "object",
107
+ required: ["claimId", "disposition", "reason", "sources"],
108
+ properties: {
109
+ claimId: { type: "string" },
110
+ disposition: { enum: ["accept", "reject", "refine", "owner-decision"] },
111
+ reason: { type: "string" },
112
+ sources: { type: "array", items: { type: "string" } }
113
+ }
114
+ }
115
+ },
116
+ recommendationChanged: {
117
+ type: "object",
118
+ required: ["changed", "reason"],
119
+ properties: {
120
+ changed: { type: "boolean" },
121
+ reason: { type: "string" }
122
+ }
123
+ },
124
+ outOfScopeFindings: { type: "array", items: { type: "string" } }
125
+ }
126
+ };
127
+ ```
128
+
129
+ Use stable resume keys such as `cross-oracle`, `phase: "Council pass 2"`, concise labels, and `output: false` unless separate artifacts are useful. The aggregate Pass 2 receipt uses the Pass 1 row shape with the new `runId` and `structuredOutput ?? output`. Pass 3 resumes those latest ids with new stable keys.
130
+
131
+ ## Advisor profile template
132
+
133
+ Create model-based advisors in the user or project agent directory, not in this package:
134
+
135
+ ```markdown
136
+ ---
137
+ name: council-sol
138
+ description: Read-only fresh-context advisor for bounded council decisions
139
+ tools: read, grep, find, ls
140
+ model: provider/top-reasoning-model
141
+ thinking: high
142
+ systemPromptMode: replace
143
+ inheritProjectContext: true
144
+ inheritSkills: false
145
+ defaultContext: fresh
146
+ acceptanceRole: read-only
147
+ ---
148
+
149
+ Analyze the council question independently. Inspect evidence directly. Do not edit, run mutating commands, commit, push, contact peers, or spawn subagents. Return concise, cited advice using the report contract in the council task.
150
+ ```
@@ -1,51 +1,103 @@
1
1
  ---
2
2
  name: pi-subagents
3
3
  description: |
4
- Delegate work to builtin or custom subagents with single-agent, parallel,
5
- scripted-chaining, async, forked-context, and coordinated workflows. Use
6
- for advisory review, implementation handoffs, and multi-step tasks where a
7
- single agent should stay in control while other agents contribute context,
8
- planning, or execution.
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.
9
8
  ---
10
9
 
11
10
  # Pi Subagents
12
11
 
13
- This skill is for the main parent orchestrator only. Do not inject or follow it inside spawned child subagents. The parent session owns delegation, orchestration, review fanout, and final fix-worker launches. Ordinary children should not run their own subagent workflows; the explicit exception is a delegated fanout child whose resolved builtin `tools` includes `subagent`, and that child may use `subagent` only for the fanout work the parent assigned.
12
+ Choose a mode:
14
13
 
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.
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.
16
26
 
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." })`.
27
+ Children do not spawn subagents unless the parent explicitly delegated fanout
28
+ and their resolved `tools` allow `subagent`.
18
29
 
19
- ## How to use this router
30
+ ## Launch shape
20
31
 
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.
32
+ | Need | Use |
33
+ | --- | --- |
34
+ | One bounded task for one child | direct `{ agent, task }` |
35
+ | JavaScript control flow or data-dependent branching; sequence, fanout, retry, rolling fanout, or aggregation | `workflowScript` with `runs.run(...)` / `runs.all(...)` |
36
+ | A broad plan split into visible narrow stages per lane | `workflowScript` with `runs.lanes([{ key, stages: [...] }])` |
37
+ | Independent worktree or repository lanes | `references/multi-lane-orchestration.md` |
38
+ | Council of advisors | `../council-mode/SKILL.md` |
39
+ | Management, status, steering, authoring, or inspection | `action` |
40
+
41
+ `workflowScript` is code-driven: `runs.run(...)` for keyed steps,
42
+ `runs.all([...])` for fanout, plain JavaScript for branching and aggregation.
43
+ Keep scripts portable: use top-level `await`, plain helpers, or explicit Promise
44
+ chains, not nested async helpers. Legacy top-level `chain` / `tasks` inputs and
45
+ durable `.chain.md` execution are inspection or migration material only.
46
+
47
+ Use `runs.lanes(...)` only inside a `workflowScript`, not as a top-level mode,
48
+ when a broad, predeclared plan benefits from visible per-lane stages; otherwise
49
+ use ordinary `runs.run(...)` / `runs.all(...)`. See the [canonical staged-lane
50
+ example](../../docs/workflows.md#parallel-sequential-lanes). Keep assignments
51
+ bounded, but do not add stages or ceremony just to satisfy this skill.
52
+
53
+ Use async/background by default. Set `async:false` only when the parent must
54
+ block. Final reviews, validation gates, oracle checks, and publication checks
55
+ stay async.
56
+
57
+ In an ordinary interactive session, yield after launching or triaging useful
58
+ async lanes and let Pi wake the parent on completion; ordinary async subagents
59
+ already have native completion notifications, so do not call `bg_wait()` merely
60
+ because a child is active. Use blocking `bg_wait()` only for provider,
61
+ detached, or other background work without a native notification when a
62
+ headless/run-to-completion contract or a required same-turn artifact makes the
63
+ result necessary before this turn ends. For
64
+ “continue/orchestrate/work until done,” keep the lane board moving while a safe
65
+ immediate action remains; if only async lanes are running, record the revisit
66
+ trigger and yield.
22
67
 
23
- | Task | Read |
68
+ Package agents appear in `subagent({ action: "list" })`. External CLI/job agents
69
+ use their own runner contract. Do not pass native Pi child options to them unless
70
+ that runner explicitly supports the option.
71
+
72
+ ## Read the reference for the branch
73
+
74
+ | Branch | Read |
24
75
  | --- | --- |
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` |
27
- | Run one-child, scripted, async, scheduled, mission-backed, forked, watchdog, oracle, or intercom-coordinated workflows | `references/execution-controls.md` |
28
- | Coordinate several independent tasks, worktrees, repositories, or writer lanes | `references/multi-lane-orchestration.md` |
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` |
30
- | Check safety constraints, best practices, standard workflows, or error handling | `references/constraints-and-recipes.md` |
31
-
32
- For broad or uncertain requests, read more than one reference. For complex work, start with `references/prompting-and-roles.md` and `references/execution-controls.md`, then consult `references/constraints-and-recipes.md` before launching or reviewing child work.
33
-
34
- External CLI agents such as `codex-exec`, `codex-exec-writer`, `claude-code`, and `cursor-agent` use their own runner contract. Do not pass 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 that runner explicitly implements them.
35
-
36
- ## Always-on constraints
37
-
38
- - Keep the parent as orchestrator and final decision-maker.
39
- - Before multiple mutation-capable lanes, record a lane board and each lane's isolation path.
40
- - 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.
41
- - 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.
42
- - Use one writer per cwd/worktree unless isolated worktrees are intentional.
43
- - 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.
44
- - 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.
76
+ | Delegate or choose roles, prompts, models, or slash commands | `references/prompting-and-roles.md` |
77
+ | Execute single, scripted, async, scheduled, mission, forked, watchdog, oracle, or intercom workflows | `references/execution-controls.md` |
78
+ | Review, validate, triage gate failures, or prepare delivery | `references/review-and-validation.md` |
79
+ | Coordinate lanes, worktrees, repositories, or writer waves | `references/multi-lane-orchestration.md` |
80
+ | List, create, edit, disable, eject, or expose agents/RPC | `references/management-authoring-rpc.md` |
81
+ | Check safety constraints, recipes, or error handling | `references/constraints-and-recipes.md` |
82
+
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.
86
+
87
+ ## Operating rules
88
+
89
+ - Avoid duplicate scouts, overlapping writers, and vague prompts without a concrete deliverable.
90
+ - Keep the parent on the ordinary strong default model. Route workers/scouts to a fast capable tier, serious reviews to a strong tier, and top reasoning to bounded read-only critique.
91
+ - Exact model names are deployment policy. Put them in user/project settings or profiles, not package guidance.
92
+ - Give every child a compact meta-prompt checklist: objective; repo/cwd/ref; authority/edit boundary; relevant files/contracts and constraints; success/acceptance criteria; validation; expected output/report; and stop/ask conditions. See `references/prompting-and-roles.md`.
93
+ - For mutation work, use an isolated lane/worktree when isolation, overlap, or concurrent juggling matters; keep one writer per cwd/worktree. See `references/multi-lane-orchestration.md` for lane mechanics.
94
+ - Keep long/high-output validation out of chat: prefer `interactive_shell` dispatch/background monitors, bounded logs, or subagent-owned reports; return a concise summary plus report path unless same-turn output is required. See `references/execution-controls.md`.
95
+ - For cross-codebase work, record the repo, explicit `cwd`, authority boundary, and expected output before launch.
96
+ - Make parallel prompts distinct by source seam, evidence, and decision. Do not clone prompts with only item numbers swapped.
45
97
  - Prefer fresh-context review/validation fanout, then synthesize and apply fixes in the parent.
46
- - Use async/background by default. Final reviews, gate checks, oracle checks, and backlog lanes stay async. Use `async:false` only when the parent must block until completion. Do not poll just to wait. For adaptive gates, branch in `workflowScript`.
47
- - For Pi extension repos whose canonical checkout is under `~/.pi/agent/extensions`, never create lane worktrees as sibling directories there. Pi auto-loads `~/.pi/agent/extensions/*/index.ts`, so sibling worktrees can register duplicate tools. Put lanes under `~/.pi/agent/worktrees`, another worktree base outside auto-discovery, or a temporary clone. If a lane must run the modified extension itself, use an isolated Pi config home with `PI_CODING_AGENT_DIR=<lane-config> pi --no-extensions -e <lane>/index.ts`. Use full containers only when path and config isolation are insufficient.
48
- - Preserve capability ceilings, including child tool restrictions and session-scoped allowed-agent restrictions.
49
- - Escalate unresolved product, architecture, authority, release, merge, or safety decisions upward instead of letting a child decide silently.
50
- - Treat receipts, CI, review bots, and external-run records as evidence, not authority to merge, close, comment, publish, or release.
51
- - As a conservative orchestration policy, do not pass a hard `toolBudget` or tight `usageBudget` to mutation-capable workers. The default tool budget blocks read/search tools rather than mutation tools, and reported usage has no reservation model. If a worker is interrupted after a tool call starts, checkpoint after the current tool returns with changed files, build/test state, and commit or PR state.
98
+ - For Pi extension repos under `~/.pi/agent/extensions`, put lane worktrees outside extension auto-discovery, such as `~/.pi/agent/worktrees`.
99
+ - Preserve capability ceilings, including child tool limits and allowed-agent restrictions.
100
+ - Preserve parent authority and escalate unresolved choices.
101
+ - Treat receipts, CI, review bots, and external-run records as evidence, not authority.
102
+ - For backlog maintenance, releases, merge queues, or other public-repo mutation policy, load the matching user/project skill. This package defines delegation primitives, not private policy.
103
+ - As a conservative orchestration policy, do not pass a hard `toolBudget` or tight `usageBudget` to mutation-capable workers. The default tool budget blocks read/search tools rather than mutation tools. If interrupted after a tool call starts, checkpoint after the current tool returns with changed files, build/test state, and commit or PR state.