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.
- package/CHANGELOG.md +69 -0
- package/docs/agents.md +2 -2
- package/docs/configuration.md +9 -5
- package/docs/extension-api.md +14 -7
- package/docs/models.md +1 -1
- package/docs/observability.md +1 -1
- package/docs/tool-reference.md +15 -3
- package/docs/workflows.md +15 -14
- package/install.mjs +2 -1
- package/package.json +1 -1
- package/skills/council-mode/SKILL.md +48 -243
- package/skills/council-mode/references/pass-contracts.md +150 -0
- package/skills/pi-subagents/SKILL.md +89 -37
- package/skills/pi-subagents/references/constraints-and-recipes.md +30 -234
- package/skills/pi-subagents/references/execution-controls.md +79 -7
- package/skills/pi-subagents/references/management-authoring-rpc.md +2 -2
- package/skills/pi-subagents/references/multi-lane-orchestration.md +13 -1
- package/skills/pi-subagents/references/prompting-and-roles.md +35 -28
- package/skills/pi-subagents/references/review-and-validation.md +73 -0
- package/src/agents/agent-management.ts +256 -88
- package/src/agents/agents.ts +527 -221
- package/src/api/background-work.ts +7 -2
- package/src/api/external-runs.ts +67 -4
- package/src/api/preflight.ts +13 -8
- package/src/api/shared-types.ts +3 -0
- package/src/extension/index.ts +7 -4
- package/src/extension/public-execution.ts +48 -4
- package/src/extension/rpc.ts +62 -4
- package/src/extension/schemas.ts +12 -7
- package/src/extension/tool-description.ts +16 -16
- package/src/runs/background/async-execution.ts +53 -37
- package/src/runs/background/async-job-tracker.ts +65 -3
- package/src/runs/background/async-resume.ts +3 -1
- package/src/runs/background/async-status.ts +104 -11
- package/src/runs/background/auto-drain.ts +1 -1
- package/src/runs/background/control-channel.ts +3 -2
- package/src/runs/background/fleet-view.ts +1 -1
- package/src/runs/background/result-watcher.ts +1 -1
- package/src/runs/background/resume-guidance.ts +1 -1
- package/src/runs/background/run-status.ts +15 -4
- package/src/runs/background/subagent-runner.ts +6 -3
- package/src/runs/background/subagent-wait.ts +30 -23
- package/src/runs/background/wait-completions.ts +4 -1
- package/src/runs/background/wait-tool.ts +24 -18
- package/src/runs/foreground/execution.ts +72 -4
- package/src/runs/foreground/subagent-executor.ts +276 -59
- package/src/runs/shared/acceptance.ts +43 -18
- package/src/runs/shared/async-status-projection.ts +138 -4
- package/src/runs/shared/background-process-options.ts +9 -0
- package/src/runs/shared/host-step-status.ts +1 -0
- package/src/runs/shared/mcp-direct-tool-grant.ts +2 -5
- package/src/runs/shared/model-fallback.ts +61 -17
- package/src/runs/shared/mutation-evidence.ts +52 -3
- package/src/runs/shared/permissions.ts +1 -1
- package/src/runs/shared/pi-args.ts +47 -1
- package/src/runs/shared/single-output.ts +45 -18
- package/src/runs/shared/subagent-prompt-runtime.ts +20 -2
- package/src/runs/shared/tool-timeout.ts +1 -1
- package/src/runs/shared/workflow-graph.ts +16 -0
- package/src/shared/types.ts +74 -4
- package/src/shared/workflow-child-permit.ts +91 -0
- package/src/slash/prompt-template-bridge.ts +37 -1
- package/src/slash/slash-commands.ts +18 -26
- package/src/tui/fleet-status.ts +11 -3
- package/src/tui/render-helpers.ts +31 -0
- package/src/tui/render.ts +673 -145
- package/src/watchdog/change-signature.ts +40 -1
- package/src/workflows/host-command.ts +6 -1
- package/src/workflows/scripted-workflow.ts +206 -6
- package/src/workflows/workflow-child-summary.ts +1 -1
- package/src/workflows/workflow-receipt.ts +41 -4
- 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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`skills/
|
|
16
|
-
|
|
17
|
-
## Roster
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
|
5
|
-
scripted
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
12
|
+
Choose a mode:
|
|
14
13
|
|
|
15
|
-
|
|
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
|
-
|
|
27
|
+
Children do not spawn subagents unless the parent explicitly delegated fanout
|
|
28
|
+
and their resolved `tools` allow `subagent`.
|
|
18
29
|
|
|
19
|
-
##
|
|
30
|
+
## Launch shape
|
|
20
31
|
|
|
21
|
-
|
|
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
|
-
|
|
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
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
| Coordinate
|
|
29
|
-
| List
|
|
30
|
-
| Check safety constraints,
|
|
31
|
-
|
|
32
|
-
For
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
##
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
- For
|
|
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
|
-
-
|
|
47
|
-
-
|
|
48
|
-
- Preserve
|
|
49
|
-
-
|
|
50
|
-
-
|
|
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
|
|
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.
|