pi-subagents 0.53.0 → 0.55.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 +66 -5
- package/README.md +1 -1
- package/agents/reviewer.md +12 -2
- package/docs/agents.md +4 -4
- package/docs/configuration.md +6 -6
- package/docs/extension-api.md +14 -4
- package/docs/models.md +41 -6
- package/docs/observability.md +14 -3
- package/docs/tool-reference.md +21 -6
- package/docs/workflows.md +7 -1
- package/index.ts +10 -1
- package/package.json +1 -1
- package/prompts/council.md +19 -7
- package/prompts/parallel-review.md +5 -1
- package/prompts/review-loop.md +9 -5
- package/skills/council-mode/SKILL.md +50 -26
- package/skills/pi-subagents/SKILL.md +5 -1
- package/skills/pi-subagents/references/constraints-and-recipes.md +16 -1
- package/skills/pi-subagents/references/execution-controls.md +13 -4
- package/skills/pi-subagents/references/multi-lane-orchestration.md +3 -3
- package/skills/pi-subagents/references/prompting-and-roles.md +14 -7
- package/src/agents/agent-management.ts +115 -14
- package/src/agents/agent-serializer.ts +2 -2
- package/src/agents/agents.ts +195 -47
- package/src/api/external-job-provider.ts +10 -1
- package/src/api/preflight.ts +33 -19
- package/src/api/project-panes.ts +2 -0
- package/src/extension/doctor.ts +10 -0
- package/src/extension/fanout-child.ts +3 -2
- package/src/extension/index.ts +24 -4
- package/src/extension/public-execution.ts +12 -9
- package/src/extension/rpc.ts +77 -3
- package/src/extension/schemas.ts +2 -1
- package/src/extension/tool-description.ts +9 -6
- package/src/extension/tool-result.ts +19 -0
- package/src/inspectors/herdr/client.ts +3 -3
- package/src/inspectors/herdr/focus.ts +55 -0
- package/src/inspectors/herdr/project-panes.ts +228 -44
- package/src/integrations/herdr-status.ts +26 -4
- package/src/runs/background/async-execution.ts +112 -13
- package/src/runs/background/async-job-tracker.ts +33 -14
- package/src/runs/background/async-resume.ts +20 -2
- package/src/runs/background/async-retention.ts +1 -1
- package/src/runs/background/async-status.ts +10 -0
- package/src/runs/background/chain-root-attachment.ts +5 -0
- package/src/runs/background/control-channel.ts +98 -10
- package/src/runs/background/notify.ts +62 -1
- package/src/runs/background/result-watcher.ts +4 -3
- package/src/runs/background/run-status.ts +15 -1
- package/src/runs/background/stale-run-reconciler.ts +3 -0
- package/src/runs/background/subagent-runner.ts +251 -38
- package/src/runs/background/wait-completions.ts +2 -0
- package/src/runs/background/wait-tool.ts +4 -3
- package/src/runs/foreground/async-stop-action.ts +23 -2
- package/src/runs/foreground/execution.ts +110 -8
- package/src/runs/foreground/subagent-executor.ts +361 -45
- package/src/runs/foreground/workflow-detach-reconcile.ts +3 -0
- package/src/runs/shared/acceptance.ts +1 -0
- package/src/runs/shared/child-identity.ts +36 -0
- package/src/runs/shared/completion-guard.ts +50 -1
- package/src/runs/shared/external-job-bridge.ts +53 -37
- package/src/runs/shared/external-job-runner.ts +126 -23
- package/src/runs/shared/model-fallback.ts +46 -15
- package/src/runs/shared/model-scope.ts +106 -39
- package/src/runs/shared/orca-progress-tabs.ts +71 -9
- package/src/runs/shared/parallel-utils.ts +12 -0
- package/src/runs/shared/pi-args.ts +31 -1
- package/src/runs/shared/subagent-prompt-runtime.ts +39 -10
- package/src/runs/shared/tool-availability.ts +1 -3
- package/src/shared/launch-contract.ts +6 -5
- package/src/shared/thinking-ceiling.ts +52 -0
- package/src/shared/types.ts +72 -5
- package/src/tui/fleet-status.ts +66 -13
- package/src/tui/render.ts +5 -4
- package/src/watchdog/permission-arbiter.ts +59 -51
- package/src/workflows/scripted-workflow.ts +107 -10
package/prompts/council.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Run a bounded supervisor-mediated council of advisors and write a decision memo
|
|
3
|
-
argument-hint: "<question> [--advisors name
|
|
3
|
+
argument-hint: "<question> [--advisors name,name] [--max-passes 2|3] [--scope ...] [--non-goals ...]"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
Run a bounded, supervisor-mediated council on this question. You, the parent
|
|
@@ -13,13 +13,14 @@ Before you orchestrate, read `skills/council-mode/SKILL.md` and
|
|
|
13
13
|
|
|
14
14
|
Parse the invocation yourself. The flags below are conventions, not runtime
|
|
15
15
|
options. Record a brief with the question, scope, non-goals, evidence targets,
|
|
16
|
-
roster,
|
|
17
|
-
the question is trivial or settled, answer directly instead
|
|
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.
|
|
18
19
|
|
|
19
20
|
## Roster
|
|
20
21
|
|
|
21
|
-
- If `--advisors` is given, use exactly those
|
|
22
|
-
unknown agent.
|
|
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.
|
|
23
24
|
- Otherwise list agents with `subagent({ action: "list" })`, then prefer 2–3
|
|
24
25
|
executable names that start with `council-`.
|
|
25
26
|
- If fewer than two profiles are available, fill the roster with `oracle`, then
|
|
@@ -30,8 +31,19 @@ the question is trivial or settled, answer directly instead of convening a counc
|
|
|
30
31
|
- Use the normal single-oracle loop only when a requested roster or unavailable
|
|
31
32
|
builtins leaves fewer than two advisors. Label the memo as degraded mode.
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
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
|
+
Package advisors such as Surf's `gpt-pro` are valid only when the package Pi
|
|
40
|
+
extension is installed and its external-job provider is registered. For Surf,
|
|
41
|
+
that means the `surf-cli` Pi extension has loaded and `surf-oracle` appears in
|
|
42
|
+
`subagent({ action: "list" })` or the advisor is explicitly requested in
|
|
43
|
+
`--advisors` after that install. Treat them as external-runner advisors: omit
|
|
44
|
+
child `async` for normal attached council results, do not pass `outputSchema`,
|
|
45
|
+
include any needed evidence in the prompt, and use the fresh fallback cross-exam
|
|
46
|
+
path if the run is not resumable.
|
|
35
47
|
|
|
36
48
|
## Run the protocol
|
|
37
49
|
|
|
@@ -28,7 +28,11 @@ Choose or adapt angles when the work calls for it:
|
|
|
28
28
|
|
|
29
29
|
Prefer three strong reviewers over many vague reviewers.
|
|
30
30
|
|
|
31
|
-
Give every reviewer a specific task prompt naming its angle. Ask reviewers to return concise, evidence-backed findings with file/line references and suggested fixes. The response should be review feedback, not a context summary. Reviewers must not edit files unless I explicitly ask for a writer pass.
|
|
31
|
+
Give every reviewer a specific task prompt naming its angle. Ask reviewers to return concise, evidence-backed findings with file/line references and suggested fixes. Filter on evidence, not severity: a finding must be concrete, current, caused or made reachable by the target diff, and supported by source proof, a test or repro, or a contract contradiction. Label findings P0/P1/P2. P0 blocks merge. P1 should be fixed before release. P2 is report-only. End each review with `Merge verdict: BLOCK`, `Merge verdict: OK`, or `Merge verdict: OK with notes`. If nothing qualifies, ask the reviewer to say exactly `No issues found.` The response should be review feedback, not a context summary. Reviewers must not edit files unless I explicitly ask for a writer pass.
|
|
32
|
+
|
|
33
|
+
Do not default first-pass reviews to `blockers only`. That phrase is valid only for final pre-merge re-checks after P1/P2 findings are already inventoried, or for explicit emergency hotfix lanes where non-blocking findings are intentionally deferred.
|
|
34
|
+
|
|
35
|
+
For a targeted follow-up review, ask only whether the named finding was resolved, whether the fix introduced a new defect in the fix blast radius, and whether prior P1/P2 notes still stand. For bot or PR-comment triage, classify each comment as VALID, STALE, INVALID, or OUT-OF-POLICY against current HEAD, then assign P0/P1/P2 only to VALID comments.
|
|
32
36
|
|
|
33
37
|
While reviewers run, do your own narrow inspection if useful. After they return, synthesize the feedback into:
|
|
34
38
|
- fixes worth doing now
|
package/prompts/review-loop.md
CHANGED
|
@@ -6,7 +6,7 @@ Run a parent-orchestrated review loop for the requested work.
|
|
|
6
6
|
|
|
7
7
|
Use the `subagent` tool. Keep the parent session as the loop controller and final decision-maker. Child subagents must receive concrete role-specific tasks; they must not run subagents or manage the loop themselves unless the parent intentionally selected an explicit fanout agent whose builtin `tools` includes `subagent` for that assigned fanout.
|
|
8
8
|
|
|
9
|
-
Default to a maximum of 3 review rounds unless I specify a different cap. Count a review round each time fresh-context reviewers inspect the current diff after a worker pass. Stop early when reviewers find no
|
|
9
|
+
Default to a maximum of 3 review rounds unless I specify a different cap. Count a review round each time fresh-context reviewers inspect the current diff after a worker pass. Stop early when reviewers find no P0 findings, no P1 fixes worth doing now, and no approved P2 notes that should be handled in this loop.
|
|
10
10
|
|
|
11
11
|
If the invocation includes an implementation request, first launch one async `worker` to implement the approved scope. If the current diff is already the target, start with review. The sequence can be launched up front with `workflowScript` when it is already clear, or continued as follow-up single-agent runs after each async completion. For an initial workflowScript, pass `async: true` so the main chat is unblocked; do not set `clarify: true` unless I explicitly want the foreground clarify UI. Use only one writer against the active worktree at a time unless I explicitly ask for isolated worktrees.
|
|
12
12
|
|
|
@@ -14,12 +14,14 @@ As a conservative orchestration policy, do not set `turnBudget`, a hard `toolBud
|
|
|
14
14
|
|
|
15
15
|
For each review round, launch fresh-context `reviewer` agents in parallel. Reviewers must inspect the repository, relevant instructions, and current diff directly from files and commands. They must not rely on the main conversation history and must not edit files.
|
|
16
16
|
|
|
17
|
+
Tell reviewers to filter on evidence, not severity. They should report only concrete current issues caused or made reachable by the target diff, with source proof, a test or repro, or a contract contradiction. Ask them to label findings P0/P1/P2 and end with `Merge verdict: BLOCK`, `Merge verdict: OK`, or `Merge verdict: OK with notes`. P0 blocks merge. P1 should be fixed before release. P2 is report-only. Use `blockers only` only for final pre-merge re-checks after P1/P2 findings are already captured, or for explicit emergency hotfix lanes.
|
|
18
|
+
|
|
17
19
|
Choose review angles from the actual change. Common angles are correctness/regressions, tests/validation, and simplicity/maintainability. Add security, performance, docs/API contracts, or user-flow validation when the work calls for it. Prefer three strong reviewers over many vague reviewers.
|
|
18
20
|
|
|
19
21
|
After reviewers return, synthesize their feedback into:
|
|
20
|
-
- blockers or scope/product/architecture decisions that need user approval;
|
|
21
|
-
- fixes worth doing now;
|
|
22
|
-
- optional improvements;
|
|
22
|
+
- P0 blockers or scope/product/architecture decisions that need user approval;
|
|
23
|
+
- P1 fixes worth doing now;
|
|
24
|
+
- P2 report-only notes or optional improvements;
|
|
23
25
|
- feedback to ignore or defer, with a short reason.
|
|
24
26
|
|
|
25
27
|
Do not blindly apply every reviewer suggestion. If reviewers surface an unapproved product, scope, or architecture decision, pause and ask me before launching a fix worker.
|
|
@@ -30,8 +32,10 @@ When there are fixes worth doing now and the workflow is implementation-authoriz
|
|
|
30
32
|
|
|
31
33
|
After a fix worker returns, run another review round only when it made material changes or addressed non-trivial findings. Do not keep looping for optional polish, speculative improvements, or findings already deferred by the parent.
|
|
32
34
|
|
|
35
|
+
For a targeted follow-up review, ask only three questions: whether the named finding was resolved, whether the fix introduced a new concrete defect in the fix blast radius, and whether prior P1/P2 notes still stand. End with a fix verdict and the merge verdict.
|
|
36
|
+
|
|
33
37
|
Stop and summarize when one of these is true:
|
|
34
|
-
- reviewers find no blockers or fixes worth doing now;
|
|
38
|
+
- reviewers find no P0 blockers or P1 fixes worth doing now;
|
|
35
39
|
- remaining feedback is optional, speculative, or intentionally deferred;
|
|
36
40
|
- reviewers surface an unapproved decision that needs me;
|
|
37
41
|
- the max review-round cap is reached.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: council-mode
|
|
3
|
-
description: Run a bounded supervisor-mediated advisor council. Use when the user asks to convene advisors, debate a decision, cross-examine recommendations, or run /council.
|
|
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
4
|
---
|
|
5
5
|
|
|
6
6
|
# Council Mode
|
|
@@ -16,13 +16,23 @@ trivial or settled question, or for implementation work. Read
|
|
|
16
16
|
|
|
17
17
|
## Roster and limits
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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.
|
|
23
33
|
|
|
24
34
|
Create model-based profiles in your user or project agent directory. Do not add
|
|
25
|
-
them to this package. This is a valid example
|
|
35
|
+
them to this package. This is a valid example:
|
|
26
36
|
|
|
27
37
|
```markdown
|
|
28
38
|
---
|
|
@@ -38,9 +48,9 @@ defaultContext: fresh
|
|
|
38
48
|
acceptanceRole: read-only
|
|
39
49
|
---
|
|
40
50
|
|
|
41
|
-
Analyze
|
|
42
|
-
run mutating commands, commit, push, contact peers, or spawn subagents.
|
|
43
|
-
concise, cited advice using the report contract in the council task.
|
|
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.
|
|
44
54
|
```
|
|
45
55
|
|
|
46
56
|
After `subagent({ action: "list" })`, prefer 2–3 executable names that start with
|
|
@@ -60,9 +70,11 @@ be settled by evidence an advisor can produce. Never run an unbounded loop.
|
|
|
60
70
|
## Protocol
|
|
61
71
|
|
|
62
72
|
1. The parent writes a brief with the question, scope, non-goals, evidence targets,
|
|
63
|
-
roster,
|
|
64
|
-
|
|
65
|
-
|
|
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
|
|
66
78
|
workflow child. For example, use `advisor-oracle`, `phase: "Council pass 1"`,
|
|
67
79
|
and `label: "Oracle — intent and consistency"`.
|
|
68
80
|
3. Launch one async `workflowScript` with `runs.all` for independent advisor
|
|
@@ -72,7 +84,13 @@ be settled by evidence an advisor can produce. Never run an unbounded loop.
|
|
|
72
84
|
is known, omit `context` and disclose the unknown runtime default in the memo.
|
|
73
85
|
Each advisor is read-only and must not spawn children, edit files, run mutating
|
|
74
86
|
commands, commit, or push. Set `output: false` unless separate advisor artifacts
|
|
75
|
-
are explicitly requested or useful for the decision.
|
|
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.
|
|
76
94
|
4. Return one aggregate Pass 1 receipt. After it completes, tell the user the
|
|
77
95
|
completion count, agreement count, dispute count, and whether Pass 2 is needed.
|
|
78
96
|
5. The parent synthesizes a claim matrix in session. It contains agreements,
|
|
@@ -96,10 +114,12 @@ budgets on advisors. Bound work through the roster, pass cap, and report length.
|
|
|
96
114
|
|
|
97
115
|
## Advisor contracts and pass receipts
|
|
98
116
|
|
|
99
|
-
Pass-1 reports are at most about 600 words. Give
|
|
100
|
-
`outputSchema`, so reports are comparable without heading cleanup.
|
|
101
|
-
|
|
102
|
-
|
|
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:
|
|
103
123
|
|
|
104
124
|
```js
|
|
105
125
|
const pass1OutputSchema = {
|
|
@@ -150,7 +170,9 @@ const pass1OutputSchema = {
|
|
|
150
170
|
|
|
151
171
|
Include this contract in each Pass 1 task: inspect supplied evidence directly; do
|
|
152
172
|
not see or ask about other advisors; stay read-only; do not spawn children; return
|
|
153
|
-
only the structured report.
|
|
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.
|
|
154
176
|
|
|
155
177
|
After `runs.all`, return one aggregate receipt rather than making the parent find
|
|
156
178
|
separate artifacts. Preserve the result order or map it by stable key so each row
|
|
@@ -162,10 +184,9 @@ return {
|
|
|
162
184
|
advisors: results.map((result, index) => ({
|
|
163
185
|
key: result.key,
|
|
164
186
|
agent: result.agent,
|
|
165
|
-
role: roster[index].role,
|
|
166
187
|
requestedContext: roster[index].context ?? "runtime-default-unknown",
|
|
167
188
|
runId: result.runId,
|
|
168
|
-
report: result.structuredOutput
|
|
189
|
+
report: result.structuredOutput ?? result.output
|
|
169
190
|
}))
|
|
170
191
|
};
|
|
171
192
|
```
|
|
@@ -208,9 +229,11 @@ const pass2OutputSchema = {
|
|
|
208
229
|
```
|
|
209
230
|
|
|
210
231
|
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.
|
|
212
|
-
|
|
213
|
-
|
|
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`.
|
|
214
237
|
|
|
215
238
|
## Stop and memo
|
|
216
239
|
|
|
@@ -221,9 +244,10 @@ decisions. Never add a round for polish or symmetry.
|
|
|
221
244
|
|
|
222
245
|
The parent memo states the question and scope, recommendation, rationale, accepted
|
|
223
246
|
and rejected feedback with reasons, owner decisions, evidence and run ids,
|
|
224
|
-
confidence, what would change the decision, and the roster,
|
|
225
|
-
|
|
226
|
-
context-aware
|
|
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.
|
|
227
251
|
|
|
228
252
|
Council mode is not agent-to-agent chat, a transcript dump, mutation authority,
|
|
229
253
|
auto-escalation to writer lanes, or a council UI. Escalate to a writer only after
|
|
@@ -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
|
|
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.
|
|
@@ -21,7 +21,13 @@ This file is a detailed reference loaded from `skills/pi-subagents/SKILL.md`.
|
|
|
21
21
|
become second decision-makers.
|
|
22
22
|
- **Respect the fixed authority policy.** `authorityPolicy` is a small `auto` / `confirm` / `forbid` map for supported operational actions. Worktree discard, destructive cleanup, and spawn-budget grants default to confirmation; stop, steer, and schedule creation remain automatic. Use `worktree.discard` with the durable `handoffPath`; confirm-required actions refuse safely without an interactive UI and retained paths include manual Git recovery commands.
|
|
23
23
|
|
|
24
|
-
Runtime config can change orchestration behavior. `intercomBridge.resultDelivery: false` disables only external acknowledged grouped-result delivery when native parent notifications own completion; supervisor asks/progress stay active, and enabled transport failures are still reported. `asyncByDefault` and `forceTopLevelAsync` affect whether launches detach; `waitTool` can make direct `subagent_wait()` calls return immediately while headless auto-drain remains active, and its effective value is propagated to child runtimes; `globalConcurrencyLimit` bounds concurrent fanout, while a positive `maxSubagentSpawnsPerSession` optionally caps cumulative launches (`0` or unset is unlimited). Status and doctor report the budget; static work preflights declared capacity; only the settled root interactive parent can use `grant-spawn-budget` after native confirmation, with total grants bounded by the original cap. Compaction does not reset usage or grants; `singleRunOutputBaseDir` and `worktreeBaseDir` route outputs and worktrees; `completionBatch` groups async notifications. `artifactDir` is `
|
|
24
|
+
Runtime config can change orchestration behavior. `intercomBridge.resultDelivery: false` disables only external acknowledged grouped-result delivery when native parent notifications own completion; supervisor asks/progress stay active, and enabled transport failures are still reported. `asyncByDefault` and `forceTopLevelAsync` affect whether launches detach; `waitTool` can make direct `subagent_wait()` calls return immediately while headless auto-drain remains active, and its effective value is propagated to child runtimes; `globalConcurrencyLimit` bounds concurrent fanout, while a positive `maxSubagentSpawnsPerSession` optionally caps cumulative launches (`0` or unset is unlimited). Status and doctor report the budget; static work preflights declared capacity; only the settled root interactive parent can use `grant-spawn-budget` after native confirmation, with total grants bounded by the original cap. Compaction does not reset usage or grants; `singleRunOutputBaseDir` and `worktreeBaseDir` route outputs and worktrees; `completionBatch` groups async notifications. `artifactDir` is `session` (default), `project`, or `temp` and chooses where subagent artifacts are stored. Set `asyncWidget: false` to hide the above-editor background-run widget when a companion footer or dashboard owns that space (fleet inspector remains available). Per-run `artifacts: false` disables artifact capture for that launch. Async status and result artifacts include `lifecycleArtifactVersion` and fields such as `workflowGraph`, `steps`, `results`, `totalTokens`, `totalCost`, `turnCount`, `toolCount`, and nested `children`. Child protocol failures expose a structured `protocolError`; `protocol_output_limit` means a child emitted a JSONL line above the 16 MiB live-parser cap. Prefer these artifacts and `status` views over scraping terminal output.
|
|
25
|
+
|
|
26
|
+
### Keep report artifacts out of the repository root
|
|
27
|
+
|
|
28
|
+
Treat lane reports, review notes, council pass reports, and gate logs as scratch unless the user explicitly asks to keep them. Prefer `output: false` and the aggregate workflow result for short reports. When a later step needs a file, use the runtime-managed output artifact by setting a stable child key plus a relative `output` path such as `plans/deploy.md`; relative child outputs are saved under the run artifact directory, not the project root. Do not put `reports/...`, `*-report.json`, or similar repo-root paths in child task text.
|
|
29
|
+
|
|
30
|
+
For durable evidence, copy only the final summary to session memory, a PR body/comment, a mission artifact, or a user-approved docs path outside the repo. After the PR, issue, or gate reaches a terminal state, delete or move scratch reports from the active worktree before reporting completion. Keep a project `.gitignore` entry for ad-hoc report patterns only as a safety net; it is not the cleanup mechanism.
|
|
25
31
|
|
|
26
32
|
## Best Practices
|
|
27
33
|
|
|
@@ -62,6 +68,15 @@ user explicitly requests forked context.
|
|
|
62
68
|
Give subagents specific tasks rather than vague mandates.
|
|
63
69
|
`Review auth.ts for null-check gaps` works better than `Review everything`.
|
|
64
70
|
|
|
71
|
+
Before fanout, assign each child a lightweight task profile in the parent prompt:
|
|
72
|
+
work kind, required input, expected output, acceptance check, and context mode.
|
|
73
|
+
Keep the profile prose-only; do not invent runtime fields. Use coarse kinds such
|
|
74
|
+
as `code-write`, `code-read`, `transform`, `summarize`, and `search` only to
|
|
75
|
+
shape the task and choose an existing agent/model setting. If a child task is not
|
|
76
|
+
standalone enough for fresh context, add the missing facts to the prompt, switch
|
|
77
|
+
to forked context, or ask the user. Do not launch vague tasks and rely on
|
|
78
|
+
supervisor round-trips to recover missing context.
|
|
79
|
+
|
|
65
80
|
### Escalate decisions upward
|
|
66
81
|
|
|
67
82
|
If a subagent encounters an unapproved product, architecture, scope, merge, release, credential, or authority choice, it should use `contact_supervisor` and wait for the reply instead of deciding alone. Generic `intercom` is external or provider-supplied only. Use it only when external bridge instructions provide an explicit safe target. External checks, receipts, and review bots provide evidence only; they do not grant authority.
|
|
@@ -76,7 +76,9 @@ subagent({
|
|
|
76
76
|
})
|
|
77
77
|
```
|
|
78
78
|
|
|
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.
|
|
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. Do not ask children to write `reports/...` or other repo-root scratch paths in task text.
|
|
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.
|
|
80
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
|
|
|
@@ -114,7 +116,7 @@ subagent({
|
|
|
114
116
|
})
|
|
115
117
|
```
|
|
116
118
|
|
|
117
|
-
File-only output mode works for workflowScript child launches. Use
|
|
119
|
+
File-only output mode works for workflowScript child launches. Use relative child output paths for scratch reports so the runtime stores them under the run artifact directory and age-based cleanup can remove them. Use absolute paths only for user-approved durable destinations, such as session memory, a docs folder outside the repo, or a known handoff path. For cross-codebase waves, include the repo slug or lane key in each output path so reports from different repositories cannot collide.
|
|
118
120
|
|
|
119
121
|
For review fanout where the parent continues a local audit:
|
|
120
122
|
|
|
@@ -127,7 +129,7 @@ const run = subagent({
|
|
|
127
129
|
// Continue local inspection, then later call status with the returned id.
|
|
128
130
|
```
|
|
129
131
|
|
|
130
|
-
While children run, the persistent FleetView and the collapsed foreground tool-result card show live per-child detail: resolved model and thinking level, `[fresh]`/`[fork]` context, tool/token/elapsed counters, and current activity. The collapsed running card also prints the configured expand-key hint ("Press … for live detail"); expanding it shows nested children, recent tools, and recent output. Model badges appear once the child's model resolves at first attempt start. `/subagents-fleet` opens the live fleet inspector, which also has per-child controls (`s` steer, `D` stop with confirmation). When optional Herdr 0.7.5+ is available, `H` opens a raw inspector dashboard for the selected active async child; this mirrors artifacts rather than attaching to the headless child.
|
|
132
|
+
While children run, the persistent FleetView and the collapsed foreground tool-result card show live per-child detail: resolved model and thinking level, `[fresh]`/`[fork]` context, tool/token/elapsed counters, and current activity. The collapsed running card also prints the configured expand-key hint ("Press … for live detail"); expanding it shows nested children, recent tools, and recent output. Model badges appear once the child's model resolves at first attempt start. `/subagents-fleet` opens the live fleet inspector, which also has per-child controls (`s` steer, `D` stop with confirmation). When optional Herdr 0.7.5+ is available, `H` opens a raw inspector dashboard for the selected active async child; this mirrors artifacts rather than attaching to the headless child. When optional Orca progress tabs are enabled, Pi creates one passive Orca observer tab for the top-level subagent call. Parallel and chain children share that tab and write child section headers into the mirrored log instead of opening one tab per child. Pi remains authoritative for lifecycle, status, control, artifacts, and results; the Orca tab is display-only. Pi also writes passive display metadata under `.pi/subagents/views/orca/` when possible, so other surfaces can discover the observer without treating it as an owned child run. Use visual panes for confusing or long-running active async work when the human wants a dedicated surface or FleetView is insufficient, not for routine headless runs.
|
|
131
133
|
|
|
132
134
|
Inspect async runs with `subagent({ action: "status", id: "..." })` or `subagent({ action: "status" })` for active runs. Use `subagent({ action: "status", view: "fleet" })` when supervising several active foreground/background runs and `subagent({ action: "status", id: "...", view: "transcript", index: 0 })` when you need the latest child output without digging through artifacts. If a delegated fanout child launches nested runs, the parent status view shows them as a tree and you can target a nested run directly with its nested id.
|
|
133
135
|
|
|
@@ -135,8 +137,15 @@ Stop a current-session top-level async run with `stop` (or `/subagents-stop`). S
|
|
|
135
137
|
|
|
136
138
|
```typescript
|
|
137
139
|
subagent({ action: "stop", id: "run-id" })
|
|
140
|
+
subagent({ action: "stop", id: "run-id", childId: "child-id" })
|
|
138
141
|
```
|
|
139
142
|
|
|
143
|
+
Use `childId` only for active async/workflow runs whose status snapshot shows a
|
|
144
|
+
matching child. Observer hosts can listen for the advertised
|
|
145
|
+
`subagent:child-status` event to update child-stop UI quickly, but status
|
|
146
|
+
snapshots remain the source of truth after reconnects or duplicate event
|
|
147
|
+
delivery.
|
|
148
|
+
|
|
140
149
|
Use `steer` for top-level live async guidance and `resume` after a delegated run pauses or finishes. Routed nested runs retain their existing non-destructive live follow-up path:
|
|
141
150
|
|
|
142
151
|
```typescript
|
|
@@ -312,7 +321,7 @@ Routing rule:
|
|
|
312
321
|
- Several projects with independent work: one async `workflowScript` whose child keys include repo slugs and whose child calls set explicit `cwd`; keep publication and merge decisions serial per repo.
|
|
313
322
|
- Different project, substantial or long-running work: open a project-owned Herdr pane rooted there when a separate visible project session is useful, then give that project Pi session a narrow mission/result contract. Do not model it as ordinary child nesting, and do not expect existing headless runs to move into the pane.
|
|
314
323
|
|
|
315
|
-
Project panes run a separate Pi session from the target directory. Subagents launched inside that pane use that project's config, agents, skills, files, git state, and mission records. The pane binding lives under `<projectRoot>/.pi/subagents/project-panes/herdr.json`. For ordinary headless delegation to another repo, prefer explicit `cwd` first; reserve project panes for visible or persistent project ownership.
|
|
324
|
+
Project panes run a separate Pi session from the target directory. Subagents launched inside that pane use that project's config, agents, skills, files, git state, and mission records. The pane binding lives under `<projectRoot>/.pi/subagents/project-panes/herdr.json`. When Pi runs inside Herdr, the owning pane reports compact active-work status and title suffixes, and the parent inline status counts opened project panes. Use Herdr itself or `project.status` / `project.close` for pane-level follow-up. For ordinary headless delegation to another repo, prefer explicit `cwd` first; reserve project panes for visible or persistent project ownership.
|
|
316
325
|
|
|
317
326
|
```typescript
|
|
318
327
|
subagent({ action: "mission.create", mission: { title: "Ship auth refresh", objective: "Implement and validate refresh handling" } })
|
|
@@ -18,9 +18,9 @@ Use one writer per repo/cwd or worktree. Mutation lanes need distinct isolation
|
|
|
18
18
|
|
|
19
19
|
For Pi extension repositories, keep lane worktrees outside auto-discovered extension directories such as `~/.pi/agent/extensions`. A stale extension worktree there can auto-load duplicate tools and shortcuts. Remove or move it only after its handoff is durable, the worktree is clean, and no run owns it.
|
|
20
20
|
|
|
21
|
-
Partition fanout by repository, source seam, decision, or review angle. Each run needs a stable key, lane-specific task, and
|
|
21
|
+
Partition fanout by repository, source seam, decision, or review angle. Each run needs a stable key, lane-specific task, and a managed output path when a file is needed. Do not launch prompts that differ only by item name or broad file glob.
|
|
22
22
|
|
|
23
|
-
Use one async `workflowScript` for a coordinated wave. Use `runs.all` for independent lanes and `runs.run` for dependent lane stages. Give cross-repository runs explicit `cwd` values and lane-qualified outputs. Use `outputMode: "file-only"` when a report must survive the run or feed a later stage.
|
|
23
|
+
Use one async `workflowScript` for a coordinated wave. Use `runs.all` for independent lanes and `runs.run` for dependent lane stages. Give cross-repository runs explicit `cwd` values and lane-qualified outputs. Use `outputMode: "file-only"` when a report must survive the run or feed a later stage. Keep scratch outputs relative so they live under subagent artifacts; use absolute paths only for durable memory, approved docs paths, or final handoff files.
|
|
24
24
|
|
|
25
25
|
## Keep independent work moving
|
|
26
26
|
|
|
@@ -32,7 +32,7 @@ After a writer produces a candidate, run the required fresh-context, read-only r
|
|
|
32
32
|
|
|
33
33
|
## Handoff, cleanup, and recovery
|
|
34
34
|
|
|
35
|
-
Use stable lane-qualified paths for reports and review output. A handoff states the lane status, repository and worktree, changed files, validation, open decisions, next action, and artifact or receipt paths.
|
|
35
|
+
Use stable lane-qualified artifact paths for reports and review output. A handoff states the lane status, repository and worktree, changed files, validation, open decisions, next action, and artifact or receipt paths. Copy only the final evidence to memory, a mission record, or a PR/comment, then remove scratch files from the active worktree before closing the lane.
|
|
36
36
|
|
|
37
37
|
Keep a worktree until its handoff is durable, no run owns it, and no later gate needs it. Clean up only inside the recorded authority boundary. If a run stops or needs attention, preserve its worktree and artifacts, record the last known state and recovery owner, then resume that run or create one replacement lane from the handoff. Do not start another writer while worktree ownership is uncertain.
|
|
38
38
|
|
|
@@ -44,14 +44,21 @@ 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. Package advisors such as Surf's `gpt-pro` can join the roster only when the `surf-cli` Pi extension is installed and its `surf-oracle` provider is registered; treat them as external runners, omit child `async` for attached results, and do not pass `outputSchema` to them. 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
|
-
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.
|
|
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. Filter on evidence, not severity: report only concrete current issues caused or made reachable by the target diff, with source proof, a test or repro, or a contract contradiction. Label findings P0/P1/P2 and end with `Merge verdict: BLOCK`, `Merge verdict: OK`, or `Merge verdict: OK with notes`. Use `blockers only` only for final pre-merge re-checks after P1/P2 findings are already captured, or for explicit emergency hotfix lanes where non-blocking findings are intentionally deferred. For targeted follow-up, ask only whether the named finding was resolved, whether the fix introduced a new defect in the fix blast radius, and whether prior P1/P2 notes still stand. For bot or PR-comment triage, classify each comment as VALID, STALE, INVALID, or OUT-OF-POLICY against current HEAD, then assign P0/P1/P2 only to VALID comments. The parent synthesizes fixes worth doing now, optional improvements, and feedback to ignore/defer before applying anything.
|
|
55
62
|
|
|
56
63
|
### Proactive skill-specialist technique
|
|
57
64
|
|
|
@@ -81,7 +88,7 @@ subagent({
|
|
|
81
88
|
|
|
82
89
|
### Review-loop technique
|
|
83
90
|
|
|
84
|
-
Use this when the user wants implementation or current diff review to continue until reviewers stop finding fixes worth doing now. Keep the loop in the parent session: one async `worker` implements or fixes, fresh-context `reviewer` agents inspect the actual repo and diff, the parent synthesizes accepted fixes, and one async forked `worker` applies them. The parent can express the sequence up front as an async/background `workflowScript` when the workflow is known, or continue with explicit follow-up workflowScript runs after each async completion. For an initial workflow, pass `async: true` so the main chat is unblocked. Treat an async implementation worker handoff as an intermediate state, not final completion, unless the user explicitly asked for worker-only work, review-only output, or to stop after implementation. Stop when reviewers find no blockers or fixes worth doing now, remaining feedback is optional or deferred, an unapproved product/scope/architecture decision appears, or the max review-round cap is reached. Default to 3 review rounds unless the user sets a different cap. Do not loop for optional polish, and do not let children launch subagents or decide the loop outcome.
|
|
91
|
+
Use this when the user wants implementation or current diff review to continue until reviewers stop finding fixes worth doing now. Keep the loop in the parent session: one async `worker` implements or fixes, fresh-context `reviewer` agents inspect the actual repo and diff, the parent synthesizes accepted fixes, and one async forked `worker` applies them. The parent can express the sequence up front as an async/background `workflowScript` when the workflow is known, or continue with explicit follow-up workflowScript runs after each async completion. For an initial workflow, pass `async: true` so the main chat is unblocked. Treat an async implementation worker handoff as an intermediate state, not final completion, unless the user explicitly asked for worker-only work, review-only output, or to stop after implementation. Stop when reviewers find no P0 blockers or P1 fixes worth doing now, remaining P2 feedback is optional or deferred, an unapproved product/scope/architecture decision appears, or the max review-round cap is reached. Default to 3 review rounds unless the user sets a different cap. Do not loop for optional polish, and do not let children launch subagents or decide the loop outcome.
|
|
85
92
|
|
|
86
93
|
As a conservative orchestration policy, do not pass `turnBudget` or a hard `toolBudget` to an implementation worker, fix worker, reviewer with edit authority, or other mutation-capable child. The default tool budget blocks read/search tools rather than mutation tools, but count limits still do not measure delivery safety. Use a narrow task plus an outer elapsed deadline with enough margin, then request a checkpoint after the current tool returns. The checkpoint should report changed files, build/test state, remaining work, and commit or PR state. An elapsed timeout is not a mutation-safe boundary and must not be used as the checkpoint trigger.
|
|
87
94
|
|
|
@@ -127,20 +134,20 @@ subagent({
|
|
|
127
134
|
|
|
128
135
|
// Stage 2: single writer — the only child allowed to edit the active worktree.
|
|
129
136
|
// Under outputMode "file-only" the awaited .output is the saved-output
|
|
130
|
-
// reference, so pass
|
|
137
|
+
// reference, so pass those managed artifact references to the writer.
|
|
131
138
|
const worker = await runs.run("apply-fixes", {
|
|
132
139
|
agent: "worker",
|
|
133
140
|
phase: "Implementation",
|
|
134
141
|
label: "Apply accepted fixes",
|
|
135
|
-
task: "Apply only the accepted fixes from these planning summaries. You are the sole writer for the active worktree. Run focused validation and report changed files, commands, failures, and remaining issues.\\n\\nDeploy plan: plans
|
|
142
|
+
task: "Apply only the accepted fixes from these planning summaries. You are the sole writer for the active worktree. Run focused validation and report changed files, commands, failures, and remaining issues.\\n\\nDeploy plan: " + plans[0].output + "\\n\\nScheduler plan: " + plans[1].output + "\\n\\nSandbox plan: " + plans[2].output,
|
|
136
143
|
output: "worker/fixes.md",
|
|
137
144
|
outputMode: "file-only"
|
|
138
145
|
});
|
|
139
146
|
|
|
140
147
|
// Stage 3: parallel read-only validation fanout
|
|
141
148
|
const validations = await runs.all([
|
|
142
|
-
{ key: "validate-deploy-scheduler", agent: "reviewer", phase: "Validation", label: "Deploy/scheduler validation", task: "Validate the post-worker diff for deploy and scheduler fixes. Start from the worker result: " + worker.output + "
|
|
143
|
-
{ key: "validate-sandbox", agent: "reviewer", phase: "Validation", label: "Sandbox validation", task: "Validate the post-worker diff for sandbox/security fixes. Start from the worker result: " + worker.output + "
|
|
149
|
+
{ key: "validate-deploy-scheduler", agent: "reviewer", phase: "Validation", label: "Deploy/scheduler validation", task: "Validate the post-worker diff for deploy and scheduler fixes. Start from the worker result: " + worker.output + ". Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "validation/deploy-scheduler.md", outputMode: "file-only" },
|
|
150
|
+
{ key: "validate-sandbox", agent: "reviewer", phase: "Validation", label: "Sandbox validation", task: "Validate the post-worker diff for sandbox/security fixes. Start from the worker result: " + worker.output + ". Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "validation/sandbox.md", outputMode: "file-only" }
|
|
144
151
|
]);
|
|
145
152
|
|
|
146
153
|
return { worker: worker.output, validations: validations.map(v => v.output) };
|
|
@@ -201,7 +208,7 @@ A strong subagent prompt usually includes:
|
|
|
201
208
|
- **Success criteria**: what must be true before the child can finish.
|
|
202
209
|
- **Hard constraints**: true invariants only, such as no edits for review-only tasks, one writer thread, child must not run subagents unless it is an explicitly assigned `tools: subagent` fanout child, or escalation for unapproved decisions.
|
|
203
210
|
- **Validation**: targeted checks to run, or the next-best check when validation is impossible.
|
|
204
|
-
- **Output**: the expected summary shape, artifact path, or finding format. Use repo-qualified
|
|
211
|
+
- **Output**: the expected summary shape, artifact path, or finding format. Use managed artifact paths for scratch reports; reserve repo-qualified absolute paths for durable handoffs that the user approved.
|
|
205
212
|
- **Stop rules**: when to ask via `intercom` or `contact_supervisor`, when to stop after enough evidence, and when not to keep searching.
|
|
206
213
|
|
|
207
214
|
Give each role useful discovery anchors. Name source roots, filenames, symbols, types, methods, and paths for scouts. Give workers context files, plans, task paths, and named source seams before asking them to search. Give reviewers changed files, contracts, and any exhaustive-verification target. Tell oracle whether current source behavior, product/policy documents, plans, or inherited decisions are the evidence that matters.
|