pi-subagents 0.42.0 → 0.43.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 +35 -0
- package/README.md +3 -5
- package/package.json +1 -1
- package/skills/pi-subagents/SKILL.md +2 -2
- package/skills/pi-subagents/references/constraints-and-recipes.md +35 -32
- package/skills/pi-subagents/references/execution-controls.md +27 -43
- package/skills/pi-subagents/references/management-authoring-rpc.md +20 -3
- package/skills/pi-subagents/references/prompting-and-roles.md +16 -49
- package/src/agents/agent-refinements.ts +624 -0
- package/src/agents/agents.ts +0 -2
- package/src/agents/proactive-skills.ts +1 -1
- package/src/api/delegation.ts +1 -2
- package/src/extension/control-notices.ts +2 -2
- package/src/extension/fanout-child.ts +46 -22
- package/src/extension/index.ts +29 -12
- package/src/extension/public-execution.ts +71 -0
- package/src/extension/rpc.ts +7 -8
- package/src/extension/schemas.ts +17 -17
- package/src/extension/tool-description.ts +14 -14
- package/src/missions/actions.ts +47 -11
- package/src/missions/goal-driver.ts +162 -0
- package/src/missions/lifecycle.ts +44 -12
- package/src/missions/store.ts +68 -3
- package/src/missions/types.ts +25 -3
- package/src/missions/workflow-state.ts +77 -0
- package/src/profiles/profiles.ts +1 -3
- package/src/runs/background/async-execution.ts +3 -0
- package/src/runs/background/async-job-tracker.ts +2 -17
- package/src/runs/background/control-channel.ts +50 -6
- package/src/runs/background/retained-children.ts +68 -0
- package/src/runs/background/scheduled-runs.ts +17 -13
- package/src/runs/background/steering.ts +7 -5
- package/src/runs/background/subagent-runner.ts +10 -4
- package/src/runs/foreground/async-steering-action.ts +36 -10
- package/src/runs/foreground/chain-clarify.ts +13 -16
- package/src/runs/foreground/execution.ts +4 -0
- package/src/runs/foreground/subagent-executor.ts +200 -59
- package/src/runs/shared/acceptance.ts +154 -9
- package/src/runs/shared/subagent-prompt-runtime.ts +94 -25
- package/src/shared/types.ts +17 -3
- package/src/slash/delegation-adapters.ts +0 -13
- package/src/slash/prompt-template-bridge.ts +14 -12
- package/src/slash/prompt-workflows.ts +10 -4
- package/src/slash/slash-bridge.ts +8 -6
- package/src/slash/slash-commands.ts +27 -12
- package/src/slash/slash-live-state.ts +4 -2
- package/src/tui/fleet-status.ts +8 -4
- package/src/tui/fleet.ts +15 -5
- package/src/tui/render.ts +13 -31
- package/src/workflows/chat-progress.ts +2 -2
- package/src/workflows/scripted-workflow.ts +97 -10
- package/agents/context-builder.md +0 -46
- package/agents/planner.md +0 -56
- package/prompts/parallel-context-build.md +0 -55
- package/prompts/parallel-handoff-plan.md +0 -61
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,41 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.43.0] - 2026-08-07
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Added explicit project-local subagent refinement overlays through `/subagents-refine <agent>` and `refine`, `refine.show`, and `refine.rollback` actions.
|
|
9
|
+
- Added opt-in goal missions that send one needs-attention continuation notice after idle parent turns, account linked-run token usage against a mission budget, pause or stop through `mission.update`, and name retained children when resume is the next ready action.
|
|
10
|
+
- Added `steer`, `follow_up`, and `auto` delivery modes with delivered/queued receipts, bounded FIFO follow-ups, retained-child revival briefs, RPC parity, and Fleet mode selection.
|
|
11
|
+
- Added one-command `gate` verification for direct and scripted workflow children, with host evidence and tracked-workspace memoization.
|
|
12
|
+
- Added mission-scoped durable JSON state to `workflowScript` through `state.get(key)` and `state.set(key, value)`.
|
|
13
|
+
- Added a session-scoped `children.list` roster for the last 10 completed retained workflow children and let `workflowScript` resume one through `runs.run` without changing its stored agent, model, or tool contract.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- Documented the one-command `gate` shorthand, retained `children.list`/`resume` flow, and refinement overlays in the tool reference and agents docs, and refreshed the packaged `pi-subagents` skill for the current mission `objective` shape, workflow `state`, and child-protocol limits.
|
|
17
|
+
- Removed the bundled `planner` and `context-builder` roles and their stale context-handoff prompt templates.
|
|
18
|
+
- Made `workflowScript` the only public subagent execution surface, including one-child and scheduled runs. Scripts now use ordinary JavaScript statement-body semantics and require an explicit `return` for useful results.
|
|
19
|
+
- Require workflowScript-only persisted schedule targets. Removed legacy agent-target restore conversion.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
- Represent gate normalization with explicit success and failure results, removing ambiguous internal states without changing gate behavior.
|
|
23
|
+
- Preserve live composite child tool-call ids for APIs that normalize them, preventing context rewriting from breaking the next tool-loop turn.
|
|
24
|
+
- Sanitize inherited child tool history ids so forked subagent context stays provider-portable.
|
|
25
|
+
- Prevent async workflow result finalization from reading stale extension contexts after session replacement or reload.
|
|
26
|
+
- Create default missions for static parallel-only chain launches, reject invalid explicit mission ids, and reject legacy `parallel` workflow child params.
|
|
27
|
+
- Keep very narrow TUI result wrapping within its width budget and simplify Fleet nested status row construction.
|
|
28
|
+
- Clean up fanout-child nested-control listeners on reload so stale listeners cannot duplicate resume handling.
|
|
29
|
+
- Prevent path-resolution tests from modifying or deleting the user's real `~/.agents` directory. Thanks to @meatcar for the report and fix in #865.
|
|
30
|
+
- Show the target agent for simple scheduled one-child workflow scripts and mark dynamic scripts clearly.
|
|
31
|
+
- Stop quiet async status widget animation redraws from spilling progress updates into the editor input area.
|
|
32
|
+
|
|
33
|
+
## [0.42.1] - 2026-08-06
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
- Prevent Pi from crashing when subagent status widgets and overlays are shown in narrow or resized terminal layouts. Thanks to @alanvardy for the report in #858 and @meatcar for the fix.
|
|
37
|
+
- Keep async scripted workflows running without an implicit 30-minute timeout, while preserving the foreground default and explicit timeout controls.
|
|
38
|
+
- Limit `workflowScript` chat progress to the supported `auto`, `off`, and `live-card` projections.
|
|
39
|
+
|
|
5
40
|
## [0.42.0] - 2026-08-06
|
|
6
41
|
|
|
7
42
|
### Added
|
package/README.md
CHANGED
|
@@ -58,14 +58,12 @@ The extension ships with agents you can use immediately:
|
|
|
58
58
|
|-------|--------------------------|
|
|
59
59
|
| `scout` | Fast local codebase recon: relevant files, entry points, data flow, risks. |
|
|
60
60
|
| `researcher` | Web/docs research with sources and a concise research brief. |
|
|
61
|
-
| `planner` | A concrete implementation plan from existing context. Reads and plans, does not edit. |
|
|
62
61
|
| `worker` | Implementation work. Edits files, validates, escalates unapproved decisions instead of guessing. |
|
|
63
62
|
| `reviewer` | Code review and small fixes against the task/plan, tests, edge cases, and simplicity. |
|
|
64
|
-
| `context-builder` | A setup pass before planning: gathers code context and writes handoff material. |
|
|
65
63
|
| `oracle` | A second opinion before acting. Challenges assumptions without editing. |
|
|
66
64
|
| `delegate` | A lightweight general delegate that behaves close to the parent session. |
|
|
67
65
|
|
|
68
|
-
Rule of thumb: `scout` before you understand the code, `researcher` before you trust external facts, `
|
|
66
|
+
Rule of thumb: `scout` before you understand the code, `researcher` before you trust external facts, `worker` to implement, `reviewer` to check, and `oracle` when the decision itself feels risky.
|
|
69
67
|
|
|
70
68
|
## Common workflows
|
|
71
69
|
|
|
@@ -85,7 +83,7 @@ Rule of thumb: `scout` before you understand the code, `researcher` before you t
|
|
|
85
83
|
| See running work | "Show active async runs." or "Show the subagent fleet." |
|
|
86
84
|
| Check setup | "Check whether subagents are configured correctly." |
|
|
87
85
|
|
|
88
|
-
For implementation work, the recommended loop is `clarify →
|
|
86
|
+
For implementation work, the recommended loop is `clarify → scout → worker → fresh reviewers → worker`. Packaged prompt shortcuts like `/parallel-review` and `/review-loop` make these patterns repeatable — see [Workflows](https://github.com/nicobailon/pi-subagents/blob/main/docs/workflows.md).
|
|
89
87
|
|
|
90
88
|
## Where running work shows up
|
|
91
89
|
|
|
@@ -111,7 +109,7 @@ The full reference lives in `docs/`:
|
|
|
111
109
|
|-----|--------------|
|
|
112
110
|
| [Agents](https://github.com/nicobailon/pi-subagents/blob/main/docs/agents.md) | Custom agents, frontmatter reference, overriding builtins, tools, extensions, skills, per-agent memory. |
|
|
113
111
|
| [Models](https://github.com/nicobailon/pi-subagents/blob/main/docs/models.md) | Default models, per-role overrides, recommended tiering, fallbacks, thinking levels, model scope enforcement, profiles. |
|
|
114
|
-
| [Workflows](https://github.com/nicobailon/pi-subagents/blob/main/docs/workflows.md) | Orchestration patterns, prompt shortcuts, scripted workflows, worktree isolation,
|
|
112
|
+
| [Workflows](https://github.com/nicobailon/pi-subagents/blob/main/docs/workflows.md) | Orchestration patterns, prompt shortcuts, scripted workflows, worktree isolation, child-to-parent coordination, the recursion guard. |
|
|
115
113
|
| [Watchdog](https://github.com/nicobailon/pi-subagents/blob/main/docs/watchdog.md) | The opt-in adversarial change reviewer, scope monitoring, LSP checks, and child tool permissions. |
|
|
116
114
|
| [Tool reference](https://github.com/nicobailon/pi-subagents/blob/main/docs/tool-reference.md) | Every `subagent` parameter, management actions, status/control actions, acceptance gates, external CLI runners. |
|
|
117
115
|
| [Observability](https://github.com/nicobailon/pi-subagents/blob/main/docs/observability.md) | FleetView, the fleet inspector, lifecycle artifacts, events, logs, session sharing. |
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ description: |
|
|
|
12
12
|
|
|
13
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.
|
|
14
14
|
|
|
15
|
-
Use this skill when the parent orchestrator needs one specialized child or composed orchestration. Use `
|
|
15
|
+
Use this skill when the parent orchestrator needs one specialized child or composed orchestration. Use `workflowScript` for all execution, including one isolated child. Use `return runs.run("main", { agent, task })` for one child and `runs.all([...])` for coordinated waves: sequence, parallelism, branching, retries, gate monitors, and aggregation. Scripted workflows start asynchronously by default; pass `async:false` only for a small foreground run.
|
|
16
16
|
|
|
17
17
|
## How to use this router
|
|
18
18
|
|
|
@@ -21,7 +21,7 @@ Read the matching reference file before acting. Paths are relative to this `SKIL
|
|
|
21
21
|
| Task | Read |
|
|
22
22
|
| --- | --- |
|
|
23
23
|
| Decide whether to delegate, choose agents, compare tool versus slash commands, apply prompt techniques, or understand builtin roles | `references/prompting-and-roles.md` |
|
|
24
|
-
| Run
|
|
24
|
+
| Run one-child, scripted, async, scheduled, mission-backed, forked, watchdog, oracle, or intercom-coordinated workflows | `references/execution-controls.md` |
|
|
25
25
|
| List/create/update/delete/eject/disable agents or chains, edit agent files, use prompt-template integration, or expose extension RPC | `references/management-authoring-rpc.md` |
|
|
26
26
|
| Check safety constraints, best practices, standard workflows, or error handling | `references/constraints-and-recipes.md` |
|
|
27
27
|
|
|
@@ -5,8 +5,8 @@ This file is a detailed reference loaded from `skills/pi-subagents/SKILL.md`.
|
|
|
5
5
|
## Important Constraints
|
|
6
6
|
|
|
7
7
|
- **Forking requires a persisted parent session.** If the current session does not
|
|
8
|
-
have a persisted session file, forked runs fail. Packaged `
|
|
9
|
-
|
|
8
|
+
have a persisted session file, forked runs fail. Packaged `worker`, `oracle`,
|
|
9
|
+
and `advisor` default to forked context, so use `context: "fresh"` explicitly
|
|
10
10
|
when that is not available or not wanted.
|
|
11
11
|
- **Forked runs inherit parent history.** They are branched threads, not fresh
|
|
12
12
|
filtered contexts. Use fresh context for adversarial reviewers unless the user explicitly asks for forked context.
|
|
@@ -19,13 +19,13 @@ This file is a detailed reference loaded from `skills/pi-subagents/SKILL.md`.
|
|
|
19
19
|
become second decision-makers.
|
|
20
20
|
- **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.
|
|
21
21
|
|
|
22
|
-
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 `project` (default), `session`, 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
|
|
22
|
+
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 `project` (default), `session`, 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.
|
|
23
23
|
|
|
24
24
|
## Best Practices
|
|
25
25
|
|
|
26
26
|
### Prefer async orchestration
|
|
27
27
|
|
|
28
|
-
Launch every subagent asynchronously by default. Use `async: true` for scouts, researchers, workers, reviewers, validators, oracle checks, one-off delegates, and scripted workflows unless you intentionally need a foreground/blocking run.
|
|
28
|
+
Launch every subagent asynchronously by default. Use `async: true` for scouts, researchers, workers, reviewers, validators, oracle checks, one-off delegates, and scripted workflows unless you intentionally need a foreground/blocking run. Launch all execution through `workflowScript`; use `return runs.run("main", { agent, task })` for one isolated child and `runs.all([...])` when two or more child lanes, monitors, or dependent steps should move together. The parent should keep moving: inspect code while scouts run, prepare validation while a worker implements, do a local diff pass while reviewers review, and synthesize or verify while a fix worker applies accepted feedback. Async is the default orchestration posture; foreground runs are the explicit opt-out.
|
|
29
29
|
|
|
30
30
|
### Use subagent_wait() to block until async runs finish
|
|
31
31
|
|
|
@@ -78,8 +78,7 @@ Use `/name` so intercom targeting stays stable.
|
|
|
78
78
|
```js
|
|
79
79
|
subagent({ workflowScript: `
|
|
80
80
|
const context = await runs.run("recon", { agent: "scout", task: "Inspect the codebase and identify the implementation seam" });
|
|
81
|
-
|
|
82
|
-
return (await runs.run("implement", { agent: "worker", task: "Implement this approved plan: " + plan.output })).output;
|
|
81
|
+
return (await runs.run("implement", { agent: "worker", task: "Implement from: " + context.output })).output;
|
|
83
82
|
` })
|
|
84
83
|
```
|
|
85
84
|
|
|
@@ -89,9 +88,9 @@ Fable mode is the default orchestration posture for complex work. It is not a se
|
|
|
89
88
|
|
|
90
89
|
Run the work through seven gated phases:
|
|
91
90
|
|
|
92
|
-
1. **Understand** — use `scout`
|
|
91
|
+
1. **Understand** — use `scout` fanout for breadth, but the parent personally reads the load-bearing files and lets direct source reading decide disagreements. Gate: the parent can quote the exact code or behavior being changed and knows the repo's verification harness.
|
|
93
92
|
2. **Decide** — separate user-owned decisions from implementation judgments. Use `interview` for product, naming, cost, taste, risk, release, merge, or authority decisions; decide routine engineering details in the parent and state them. Gate: every user-owned decision needed for design is answered or recorded as a blocked follow-up.
|
|
94
|
-
3. **Design** — use
|
|
93
|
+
3. **Design** — use read-only design/review children for parallel perspectives. Before parallel workstreams, write seam contracts: ownership boundaries, composition points, assumptions, and validation handoffs. Gate: one parent-synthesized plan and written seams for parallel work.
|
|
95
94
|
4. **Implement** — capture a baseline first, then launch one async `worker` as the sole writer for the active worktree unless isolated worktrees were intentionally requested. For cross-codebase work, launch separate async workers only when each has its own repo/worktree, explicit `cwd`, and non-overlapping authority. Break large work into serial milestones instead of concurrent writes. Gate: build/typecheck is green and every output or diff delta is characterized as intended or fixed.
|
|
96
95
|
5. **Verify** — climb the spend ladder: static checks, free end-to-end/dry-run, cheapest live probe, targeted changed-path live test, then full realistic run when warranted. Observe the artifact itself, not only exit codes or scores, and confirm the changed code actually executed. Gate: the highest necessary rung has directly observed evidence matching intent.
|
|
97
96
|
6. **Iterate** — when a gate or reviewer finds a defect, the parent names the failure class, searches for siblings, synthesizes fixes, and sends exactly one fix worker for accepted changes. For LLM judges, gates, or detectors, trigger on concrete findings rather than scores, record pass/violations/error verdicts, cache nondeterministic verdicts by input hash, budget enough output tokens, and sanitize judge text before reusing it downstream. Gate: the class is fixed or explicitly bounded, and recurrence detection exists when feasible.
|
|
@@ -101,7 +100,7 @@ Run the work through seven gated phases:
|
|
|
101
100
|
|
|
102
101
|
For straightforward non-trivial work, this sequence is the lightweight version of the parent-owned loop. When the task is complex, use Fable mode above. In either case, factor in the packaged prompt workflows without literally invoking slash commands. Use the same patterns through tools and subagents.
|
|
103
102
|
|
|
104
|
-
Keep builtin agent defaults unless the user explicitly asks for a different model, thinking level, skills, output behavior, context mode, or other override. Do not add overrides just because you are orchestrating; the defaults encode the intended role behavior. In particular, packaged `
|
|
103
|
+
Keep builtin agent defaults unless the user explicitly asks for a different model, thinking level, skills, output behavior, context mode, or other override. Do not add overrides just because you are orchestrating; the defaults encode the intended role behavior. In particular, packaged `worker`, `oracle`, and `advisor` default to forked context.
|
|
105
104
|
|
|
106
105
|
When the user approves launching a subagent to carry out a plan or workflow, treat that as approval to generate a proper role-specific meta prompt for that subagent. Include the approved plan path or summary, clarified requirements, non-goals, relevant context, role boundaries, files or areas to inspect, acceptance criteria, expected output, and validation expectations. Do not pass vague instructions like “implement the plan fully” or “review this” by themselves.
|
|
107
106
|
|
|
@@ -109,33 +108,31 @@ When the user approves launching a subagent to carry out a plan or workflow, tre
|
|
|
109
108
|
- `/parallel-review` maps to: launch fresh-context `reviewer` agents with distinct review angles; synthesize the feedback before applying anything.
|
|
110
109
|
- `/review-loop` maps to: keep the parent in charge of worker → fresh reviewers → synthesized fix worker cycles until no fixes worth doing now remain, an unapproved decision appears, or the review-round cap is reached.
|
|
111
110
|
- `/parallel-research` maps to: combine local `scout` context with external `researcher` evidence when current docs, ecosystem behavior, or API details matter.
|
|
112
|
-
- `/parallel-context-build` maps to: use `workflowScript` with `runs.all` for distinct `context-builder` lanes, then synthesize their context and meta-prompt sections.
|
|
113
|
-
- `/parallel-handoff-plan` maps to: run external `researcher` plus local/strategy `context-builder` passes, then a synthesis `context-builder` that writes an implementation handoff plan and implementation-ready meta-prompt.
|
|
114
111
|
- `/parallel-cleanup` maps to: use review-only cleanup passes after implementation, especially for simplicity, verbosity, and redundant tests.
|
|
115
112
|
|
|
116
113
|
For feature work, use this sequence as scaffolding for parent-agent behavior:
|
|
117
114
|
|
|
118
115
|
```text
|
|
119
|
-
clarify → validation contract →
|
|
116
|
+
clarify → validation contract → scout → async worker → parallel async fresh-context reviewers/validators → async fix worker → follow-up review when warranted → parent review
|
|
120
117
|
```
|
|
121
118
|
|
|
122
119
|
The validation contract defines acceptance before code is written: expected behavior, acceptance checks, commands or user flows to exercise, and evidence the worker should return. Keep it lightweight for small tasks, but make it explicit enough that reviewers and validators are checking the intended outcome rather than the worker’s own assumptions.
|
|
123
120
|
|
|
124
|
-
Use the structured `acceptance` field when the run should carry an explicit acceptance contract. If omitted, subagents infer an effective policy from role, mode, and risk. Evidence levels end at `verified`: use `level: "checked"` for ordinary writer evidence and `level: "verified"` when the runtime should run explicit validation commands. Independent review is orthogonal; use `review: { required: true, agent: "reviewer" }` and orchestrate the reviewer separately. `review-required` means evidence passed but review is pending, while `reviewed` means a real independent result found no blockers. For reviewer/read-only calls, omit `acceptance`. Never explicitly request `level: "reviewed"`; that value remains recognized only so preflight can return an actionable correction. To disable gates, use `{ level: "none", reason: "..." }`; the bare string `"none"` is rejected, and `false` is accepted only as a deprecated shorthand. Child-reported command success is evidence, not runtime verification.
|
|
121
|
+
For one host-run verification command, `gate: "npm test"` on the child is shorthand for verified acceptance with that command; it cannot be combined with `acceptance` and is rejected on retained resume items. Use the structured `acceptance` field when the run should carry an explicit acceptance contract. If omitted, subagents infer an effective policy from role, mode, and risk. Evidence levels end at `verified`: use `level: "checked"` for ordinary writer evidence and `level: "verified"` when the runtime should run explicit validation commands. Independent review is orthogonal; use `review: { required: true, agent: "reviewer" }` and orchestrate the reviewer separately. `review-required` means evidence passed but review is pending, while `reviewed` means a real independent result found no blockers. For reviewer/read-only calls, omit `acceptance`. Never explicitly request `level: "reviewed"`; that value remains recognized only so preflight can return an actionable correction. To disable gates, use `{ level: "none", reason: "..." }`; the bare string `"none"` is rejected, and `false` is accepted only as a deprecated shorthand. Child-reported command success is evidence, not runtime verification.
|
|
125
122
|
|
|
126
|
-
The first `worker` implements the approved plan. The parent continues with independent inspection or validation prep while it runs, not parallel edits to the same worktree. When the async worker completes, treat its handoff as the transition into review, not as final completion, unless the user explicitly asked for worker-only work, review-only output, or to stop after implementation. Parallel reviewers inspect the resulting diff from fresh context. Validators check behavior with the best available evidence: commands, tests, browser/CLI interaction, screenshots, logs, or manual reproduction notes. The final `worker` applies synthesized review fixes in forked context, then the parent looks over the final diff before completing. The parent may launch these steps as an initial async
|
|
123
|
+
The first `worker` implements the approved plan. The parent continues with independent inspection or validation prep while it runs, not parallel edits to the same worktree. When the async worker completes, treat its handoff as the transition into review, not as final completion, unless the user explicitly asked for worker-only work, review-only output, or to stop after implementation. Parallel reviewers inspect the resulting diff from fresh context. Validators check behavior with the best available evidence: commands, tests, browser/CLI interaction, screenshots, logs, or manual reproduction notes. The final `worker` applies synthesized review fixes in forked context, then the parent looks over the final diff before completing. The parent may launch these steps as an initial async `workflowScript` when the workflow is already clear, or as follow-up workflowScript runs after each async completion. Initial workflows should pass `async: true` so the main chat is unblocked. Do not stop after parallel review unless the user explicitly asked for review-only output or the review surfaced a decision that needs approval first.
|
|
127
124
|
|
|
128
125
|
For complex work, risky changes, broad refactors, or many changed lines, increase review and validation fanout rather than trusting one reviewer. Use distinct angles such as correctness/regressions, tests/validation, simplicity/maintainability, security/privacy, performance, docs/API contracts, and user-flow behavior. When reviewers find non-trivial issues or the fix worker touches many lines, run another focused review round before final validation.
|
|
129
126
|
|
|
130
|
-
When review has already produced concrete findings across several independent areas, use staged fix orchestration: parallel read-only
|
|
127
|
+
When review has already produced concrete findings across several independent areas, use staged fix orchestration: parallel read-only reviewers for each issue cluster, one sole writer worker for the active worktree, then parallel fresh-context validators. This is the safest way to handle a dirty worktree with many prior changes because it parallelizes judgment without parallelizing writes. Non-blocking suggestions may go into the writer prompt only if they are small, safe, and inside the approved scope; otherwise defer them explicitly.
|
|
131
128
|
|
|
132
129
|
For very large work, split into serial milestones instead of launching a swarm of writers. Each milestone gets one writer, a validation contract, fresh-context review/validation, a fix pass, and parent acceptance before the next milestone starts. Use parallel subagents inside a milestone for read-only context, research, review, and validation only.
|
|
133
130
|
|
|
134
131
|
Keep orchestration authority in the parent session. Child subagents should not launch more subagents, read this skill, or run their own orchestration loops unless the parent intentionally selected a fanout agent whose builtin `tools` includes `subagent`. Spawned subagents do not receive the `pi-subagents` skill, parent-only status/control/slash messages, or prior parent `subagent` tool-call/tool-result artifacts. Ordinary children also do not receive the `subagent` extension tool. Child context filtering strips old hidden orchestration-instruction messages when they appear in inherited history. Every child receives a boundary instruction: ordinary children are told the parent owns orchestration and they must not propose or run subagents; explicit fanout children are told to use `subagent` only for the assigned fanout work, with `maxSubagentDepth` still enforced. Implementation children must call real edit/write tools instead of printing pseudo tool calls. Pass children concrete role-specific work instead.
|
|
135
132
|
|
|
136
|
-
1. Clarify first. This is mandatory. Gather code context with `scout
|
|
133
|
+
1. Clarify first. This is mandatory. Gather code context with `scout`, add `researcher` only when external evidence matters, then ask the user clarifying questions with `interview` until scope, acceptance criteria, constraints, and non-goals are clear.
|
|
137
134
|
2. Define the validation contract. State acceptance before implementation: expected behavior, checks to run, user flows to exercise, and evidence required in the worker handoff. For UI, CLI, integration, or workflow changes, include at least one validator angle that uses the product the way a user would rather than only reading code.
|
|
138
|
-
3. Plan when useful. For complex work,
|
|
135
|
+
3. Plan when useful. For complex work, write a plan doc yourself and get approval before implementation. For simple work, confirm shared understanding and explicitly note why planning is skipped.
|
|
139
136
|
4. Implement with one writer. After approval, launch `worker` asynchronously with a proper meta prompt that includes clarified requirements, relevant context, plan path or summary, the validation contract, and output expectations. Packaged `worker` defaults to forked context; pass `context: "fresh"` only when you intentionally want a fresh child. While it runs, prepare validation or inspect adjacent code instead of editing the same worktree.
|
|
140
137
|
5. Require a useful worker handoff. Ask the worker to report changed files, what was implemented, what was left undone, commands run with exit codes, validation evidence, surprises or new risks, decisions made inside approved scope, and decisions needing parent approval.
|
|
141
138
|
6. Review after implementation. After the worker completes, launch parallel async fresh-context `reviewer` agents for correctness/regressions, tests/validation, and simplicity/maintainability. Add security, performance, docs/API, domain-specific, or user-flow validators for complex work, risky changes, broad refactors, or many changed lines. Use `output: false` unless review artifacts are explicitly needed.
|
|
@@ -147,12 +144,14 @@ Example implementation handoff after clarification and optional planning:
|
|
|
147
144
|
|
|
148
145
|
```typescript
|
|
149
146
|
subagent({
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
147
|
+
workflowScript: `return runs.run("implementation", {
|
|
148
|
+
agent: "worker",
|
|
149
|
+
task: "Implement the approved feature.\n\nClarified requirements:\n- ...\n\nPlan: see ~/Documents/docs/...-plan.md\n\nValidation contract:\n- ...\n\nReturn a handoff with changed files, what was implemented, what was left undone, commands run with exit codes, validation evidence, surprises/new risks, and decisions needing parent approval.",
|
|
150
|
+
acceptance: {
|
|
151
|
+
level: "checked",
|
|
152
|
+
evidence: ["changed-files", "tests-added", "commands-run", "residual-risks", "no-staged-files"]
|
|
153
|
+
}
|
|
154
|
+
})`,
|
|
156
155
|
async: true
|
|
157
156
|
})
|
|
158
157
|
```
|
|
@@ -161,12 +160,14 @@ Example review pass after implementation:
|
|
|
161
160
|
|
|
162
161
|
```typescript
|
|
163
162
|
subagent({
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
163
|
+
workflowScript: `
|
|
164
|
+
const results = await runs.all([
|
|
165
|
+
{ key: "correctness", agent: "reviewer", task: "Review the current diff for correctness and regressions. Inspect changed files directly; do not rely on the worker's reasoning.", output: false },
|
|
166
|
+
{ key: "tests", agent: "reviewer", task: "Review the current diff for tests and validation quality against the validation contract. Inspect changed files directly.", output: false },
|
|
167
|
+
{ key: "simplicity", agent: "reviewer", task: "Review the current diff for simplicity and maintainability. Inspect changed files directly.", output: false }
|
|
168
|
+
]);
|
|
169
|
+
return results.map(result => result.output);
|
|
170
|
+
`,
|
|
170
171
|
context: "fresh",
|
|
171
172
|
async: true
|
|
172
173
|
})
|
|
@@ -176,8 +177,10 @@ Example fix worker after parallel reviews:
|
|
|
176
177
|
|
|
177
178
|
```typescript
|
|
178
179
|
subagent({
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
workflowScript: `return runs.run("fix", {
|
|
181
|
+
agent: "worker",
|
|
182
|
+
task: "Apply the synthesized reviewer feedback below. Only apply fixes worth doing now; preserve user-approved scope; ask before unapproved product or architecture changes. Run focused validation and summarize what changed.\n\nReviewer synthesis:\n..."
|
|
183
|
+
})`,
|
|
181
184
|
async: true
|
|
182
185
|
})
|
|
183
186
|
```
|
|
@@ -186,7 +189,7 @@ subagent({
|
|
|
186
189
|
|
|
187
190
|
Do not treat review as the final step for implementation work. Run reviewers and validators, synthesize their findings against user scope and the validation contract, then launch one `worker` for accepted fixes when implementation is authorized.
|
|
188
191
|
|
|
189
|
-
When an async implementation worker completes, treat the worker handoff as an intermediate state. The next parent action is review fanout, then synthesis, then a fix worker if reviewers found fixes worth doing now. This can be planned as an initial async
|
|
192
|
+
When an async implementation worker completes, treat the worker handoff as an intermediate state. The next parent action is review fanout, then synthesis, then a fix worker if reviewers found fixes worth doing now. This can be planned as an initial async `workflowScript` when the whole workflow is known, or continued as follow-up workflowScript runs when the parent only launched the first worker initially. Initial workflows should pass `async: true` so the main chat is unblocked.
|
|
190
193
|
|
|
191
194
|
For explicit review-loop requests, repeat worker → fresh-reviewer → synthesized-fix-worker cycles until reviewers find no blockers or fixes worth doing now, remaining feedback is optional or intentionally deferred, an unapproved product/scope/architecture decision needs the user, or the max review-round cap is reached. Default to 3 review rounds unless the user sets a different cap. For complex work, many changed lines, or any fix pass that materially changes the diff, run another focused review round before the parent’s final look; otherwise stop instead of chasing optional polish.
|
|
192
195
|
|
|
@@ -30,8 +30,7 @@ External CLI profiles are async-only and one-shot. They support lifecycle artifa
|
|
|
30
30
|
|
|
31
31
|
```typescript
|
|
32
32
|
subagent({
|
|
33
|
-
agent: "oracle",
|
|
34
|
-
task: "Review my current direction and challenge assumptions."
|
|
33
|
+
workflowScript: `return runs.run("oracle-check", { agent: "oracle", task: "Review my current direction and challenge assumptions." })`
|
|
35
34
|
})
|
|
36
35
|
```
|
|
37
36
|
|
|
@@ -39,9 +38,7 @@ subagent({
|
|
|
39
38
|
|
|
40
39
|
```typescript
|
|
41
40
|
subagent({
|
|
42
|
-
agent: "oracle",
|
|
43
|
-
task: "Review my current direction and challenge assumptions.",
|
|
44
|
-
context: "fork"
|
|
41
|
+
workflowScript: `return runs.run("oracle-check", { agent: "oracle", task: "Review my current direction and challenge assumptions.", context: "fork" })`
|
|
45
42
|
})
|
|
46
43
|
```
|
|
47
44
|
|
|
@@ -56,7 +53,7 @@ its resolved launch context as `[fresh]` or `[fork]`. Aggregate headers show
|
|
|
56
53
|
|
|
57
54
|
### Scripted workflows
|
|
58
55
|
|
|
59
|
-
`workflowScript` is the sole public
|
|
56
|
+
`workflowScript` is the sole public execution surface. Use `runs.run(key, { agent, task, ... })` for one child, `runs.all([...])` for parallel children, and ordinary JavaScript for sequence, branching, filtering, retries, and aggregation. Scripts are ordinary JavaScript statement bodies, so use an explicit return such as `workflowScript: "return runs.run('main', { agent: 'worker', task: '...' })"` for a useful one-child result. Prefer a single scripted workflow whenever the parent is starting a coordinated wave, such as multiple reviews, review plus gate monitor, worker then monitor setup, cross-repo prep lanes, or a fanout that the parent will consume together.
|
|
60
57
|
|
|
61
58
|
```js
|
|
62
59
|
subagent({
|
|
@@ -71,7 +68,11 @@ subagent({
|
|
|
71
68
|
})
|
|
72
69
|
```
|
|
73
70
|
|
|
74
|
-
Scripts run in a timed worker with only `runs.run`, `runs.all`, `runs.status`, `runs.ref/refs`, `emit`, captured `console`, and standard JavaScript. 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.
|
|
71
|
+
Scripts run in a timed worker with only `runs.run`, `runs.all`, `runs.status`, `runs.ref/refs`, `emit`, captured `console`, and standard JavaScript. 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.
|
|
72
|
+
|
|
73
|
+
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.
|
|
74
|
+
|
|
75
|
+
Completed workflow children from this parent session stay addressable as retained children. `subagent({ action: "children.list" })` lists up to the last 10 with run ids, and a later workflow continues one with `runs.run(key, { resume: "<run-id>", task: "follow-up" })`. `resume` and `agent` are mutually exclusive, the revived child keeps its stored agent/model/tool contract, and `gate` is rejected on retained resume items.
|
|
75
76
|
|
|
76
77
|
### Async/background
|
|
77
78
|
|
|
@@ -87,20 +88,18 @@ In an interactive chat, normally return control when ready to yield and let Pi w
|
|
|
87
88
|
|
|
88
89
|
```typescript
|
|
89
90
|
subagent({
|
|
90
|
-
agent: "worker",
|
|
91
|
-
task: "Run the full test suite",
|
|
91
|
+
workflowScript: `return runs.run("main", { agent: "worker", task: "Run the full test suite" })`,
|
|
92
92
|
async: true
|
|
93
93
|
})
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
File-only output mode works for
|
|
96
|
+
File-only output mode works for workflowScript child launches. Use distinct absolute or durable output paths when later script steps need stable references. For cross-codebase waves, include the repo slug or lane key in each output path so reports from different repositories cannot collide.
|
|
97
97
|
|
|
98
98
|
For review fanout where the parent continues a local audit:
|
|
99
99
|
|
|
100
100
|
```typescript
|
|
101
101
|
const run = subagent({
|
|
102
|
-
agent: "reviewer",
|
|
103
|
-
task: "Review the current diff for correctness issues. Do not edit files.",
|
|
102
|
+
workflowScript: `return runs.run("correctness", { agent: "reviewer", task: "Review the current diff for correctness issues. Do not edit files." })`,
|
|
104
103
|
async: true,
|
|
105
104
|
context: "fresh"
|
|
106
105
|
})
|
|
@@ -163,7 +162,7 @@ Schedules are durable project records under `.pi-subagents/schedules/`. They are
|
|
|
163
162
|
|
|
164
163
|
```typescript
|
|
165
164
|
// One-shot reviewer
|
|
166
|
-
subagent({ action: "schedule.create", id: "evening-review", name: "Evening review", at: "+30m", agent:
|
|
165
|
+
subagent({ action: "schedule.create", id: "evening-review", name: "Evening review", at: "+30m", workflowScript: "return runs.run('main', { agent: 'reviewer', task: 'Review the diff.' })" })
|
|
167
166
|
|
|
168
167
|
// Fixed recurring workflow
|
|
169
168
|
subagent({ action: "schedule.create", id: "backlog", every: "6h", catchUp: "latest", workflowScript: "..." })
|
|
@@ -178,7 +177,7 @@ subagent({ action: "schedule.run-due" })
|
|
|
178
177
|
subagent({ action: "schedule.delete", id: "backlog" })
|
|
179
178
|
```
|
|
180
179
|
|
|
181
|
-
`schedule.create` accepts exactly one target
|
|
180
|
+
`schedule.create` accepts exactly one target, `workflowScript`, and exactly one trigger (`at`, or a fixed `every` interval using `m`, `h`, `d`, or `w`). Runs always launch async with fresh context and no automatic mission; mission attachment is deferred from this first slice. `overlap` is currently `skip`; `catchUp` supports `latest` and `none`. `schedule.run-due` is the headless external-launcher seam. Calendar recurrence, cron, and the schedule inspector are deferred from this first safe slice. Definitions, bounded history, append-only events, and per-run receipts remain project-scoped across Pi sessions.
|
|
182
181
|
|
|
183
182
|
Humans can use `/subagents-doctor` for the same read-only report. It checks runtime paths, discovery counts, async support, current session context, and intercom bridge state.
|
|
184
183
|
|
|
@@ -207,12 +206,14 @@ Per-run control thresholds can be overridden when a task legitimately runs witho
|
|
|
207
206
|
|
|
208
207
|
```typescript
|
|
209
208
|
subagent({
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
209
|
+
workflowScript: `return runs.run("slow-tests", {
|
|
210
|
+
agent: "worker",
|
|
211
|
+
task: "Run the slow migration test suite",
|
|
212
|
+
control: {
|
|
213
|
+
needsAttentionAfterMs: 300000,
|
|
214
|
+
notifyOn: ["needs_attention"]
|
|
215
|
+
}
|
|
216
|
+
})`
|
|
216
217
|
})
|
|
217
218
|
```
|
|
218
219
|
|
|
@@ -266,21 +267,6 @@ subagent({ action: "watchdog.check" })
|
|
|
266
267
|
when the user asked. Use ordinary fresh-context `reviewer` fanout for planned review
|
|
267
268
|
waves; enable the watchdog when you want an automatic second pass on real edits.
|
|
268
269
|
|
|
269
|
-
## Clarify TUI
|
|
270
|
-
|
|
271
|
-
Single and parallel runs support a clarification TUI when you want to preview or
|
|
272
|
-
edit parameters before launch:
|
|
273
|
-
|
|
274
|
-
```typescript
|
|
275
|
-
subagent({
|
|
276
|
-
agent: "worker",
|
|
277
|
-
task: "Implement feature X",
|
|
278
|
-
clarify: true
|
|
279
|
-
})
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
Ordinary tool calls launch in the background by default. Set `async: false` when the current turn needs a foreground result, or `clarify: true` when you want the clarify UI; clarify always stays foreground. Clarify edits affect only the next run; use management actions, settings, or markdown files for persistent changes.
|
|
283
|
-
|
|
284
270
|
## Missions and cross-project routing
|
|
285
271
|
|
|
286
272
|
Missions are the durable orchestration layer. Use this noun map:
|
|
@@ -290,7 +276,7 @@ Missions are the durable orchestration layer. Use this noun map:
|
|
|
290
276
|
- **Run** — one actual subagent execution.
|
|
291
277
|
- **Receipt** — proof or a link for an external outcome, such as a PR, CI check, deployment, or release.
|
|
292
278
|
|
|
293
|
-
Ordinary launches with a task create a mission by default, so substantial delegated work has a persisted
|
|
279
|
+
Ordinary launches with a task create a mission by default, so substantial delegated work has a persisted objective, status, run links, decisions, artifacts, and delivery receipts that survive compaction or a new parent chat. Automatic persistence failures leave the run intact and set `details.missionWarning`; explicit `missionId` or `mission` remains strict before launch. Human receipts end with a mission id/status line, while structured JSON text remains untouched and `details.missionId` is authoritative. Pass `missionId` to attach an existing mission, use `mission: { title, objective?, goal?, budget?, labels? }` to control the auto-created record, pass `mission: false` for intentionally ephemeral work, or set `missions.enabled: false` to opt out globally. `objective` is the intent string; `goal: true` requires `budget.tokens` and turns the open mission into a continuation driver that sends one needs-attention notice after idle parent turns until the budget is exhausted, the goal is paused with `mission.update` `{ goal: { paused: true } }`, or the mission closes.
|
|
294
280
|
|
|
295
281
|
Use `mission.update` while work runs to record decisions, artifacts, labels, summaries, or delivery receipts. A receipt records a pull request, CI, deployment, or release link with a concise status; it does not authorize or automate merge, CI polling, or deployment. Record open product, architecture, or safety decisions there and escalate them upward; do not let a child decide silently. Use `mission.attach-run` only for runs launched outside the normal mission-backed path, and use `mission.close` with a terminal status and concise summary when the mission is done.
|
|
296
282
|
|
|
@@ -305,9 +291,9 @@ Routing rule:
|
|
|
305
291
|
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.
|
|
306
292
|
|
|
307
293
|
```typescript
|
|
308
|
-
subagent({ action: "mission.create", mission: { title: "Ship auth refresh",
|
|
309
|
-
subagent({ agent: "worker", task: "Implement the approved plan"
|
|
310
|
-
subagent({ agent: "scout", task: "Quickly answer whether this file exists"
|
|
294
|
+
subagent({ action: "mission.create", mission: { title: "Ship auth refresh", objective: "Implement and validate refresh handling" } })
|
|
295
|
+
subagent({ workflowScript: `return runs.run("main", { agent: "worker", task: "Implement the approved plan" })`, missionId: "<mission-id>" })
|
|
296
|
+
subagent({ workflowScript: `return runs.run("main", { agent: "scout", task: "Quickly answer whether this file exists" })`, mission: false })
|
|
311
297
|
subagent({ action: "mission.list", missionScope: "global" })
|
|
312
298
|
subagent({ action: "project.open", cwd: "/path/to/other-repo", message: "Own this mission for the project and report back with receipts." })
|
|
313
299
|
subagent({ action: "project.status", cwd: "/path/to/other-repo" })
|
|
@@ -364,14 +350,12 @@ The intended oracle loop is:
|
|
|
364
350
|
```typescript
|
|
365
351
|
// Advisory review in a branched thread. Oracle defaults to forked context.
|
|
366
352
|
subagent({
|
|
367
|
-
agent: "oracle",
|
|
368
|
-
task: "Review my current direction, challenge assumptions, and propose the best next move."
|
|
353
|
+
workflowScript: `return runs.run("oracle-check", { agent: "oracle", task: "Review my current direction, challenge assumptions, and propose the best next move." })`
|
|
369
354
|
})
|
|
370
355
|
|
|
371
356
|
// Implementation only after explicit approval. Worker defaults to forked context.
|
|
372
357
|
subagent({
|
|
373
|
-
agent: "worker",
|
|
374
|
-
task: "Implement the approved approach: ..."
|
|
358
|
+
workflowScript: `return runs.run("implementation", { agent: "worker", task: "Implement the approved approach: ..." })`
|
|
375
359
|
})
|
|
376
360
|
```
|
|
377
361
|
|
|
@@ -12,6 +12,24 @@ The `subagent(...)` tool also supports management actions.
|
|
|
12
12
|
subagent({ action: "list" })
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
### List retained children
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
subagent({ action: "children.list" })
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Lists up to the last 10 completed retained workflow children from this parent session with their run ids. Continue one in a later workflow with `runs.run(key, { resume: "<run-id>", task: "follow-up" })`; the revived child keeps its stored agent, model, and tool contract.
|
|
22
|
+
|
|
23
|
+
### Refinement overlays
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
subagent({ action: "refine", agent: "reviewer" })
|
|
27
|
+
subagent({ action: "refine.show", agent: "reviewer" })
|
|
28
|
+
subagent({ action: "refine.rollback", agent: "reviewer" })
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`refine` builds a bounded project-local guidance overlay for one agent from recent run evidence, using a fresh read-only proposal child; validated guidance is stored under `.pi-subagents/refinements/<agent>.md` with revision snapshots and is injected into that agent's child system prompt for this project. `refine.show` prints the current overlay and history; `refine.rollback` restores the previous revision. Guidance that tries to override safety, policy, tool, output, acceptance, developer, or system instructions is rejected. `/subagents-refine <agent>` is the slash equivalent.
|
|
32
|
+
|
|
15
33
|
### Create an agent
|
|
16
34
|
|
|
17
35
|
```typescript
|
|
@@ -125,8 +143,7 @@ copying a full builtin file.
|
|
|
125
143
|
## Prompt Template Integration
|
|
126
144
|
|
|
127
145
|
The package includes prompt shortcuts for common workflows: `/parallel-review`,
|
|
128
|
-
`/review-loop`, `/parallel-research`, `/
|
|
129
|
-
`/parallel-handoff-plan`, `/gather-context-and-clarify`, and
|
|
146
|
+
`/review-loop`, `/parallel-research`, `/gather-context-and-clarify`, and
|
|
130
147
|
`/parallel-cleanup`. Use them when the user wants repeatable review,
|
|
131
148
|
review/fix loops, research, context handoff, implementation handoff,
|
|
132
149
|
clarification, or cleanup-review patterns. `/parallel-review autofix` and
|
|
@@ -141,4 +158,4 @@ Additional user prompt templates can delegate into `pi-subagents` through the na
|
|
|
141
158
|
|
|
142
159
|
Other Pi extensions can call `pi-subagents` through the in-process event bus. The RPC channels are `subagents:rpc:v1:ready`, `subagents:rpc:v1:request`, and per-request replies at `subagents:rpc:v1:reply:<requestId>`. Envelopes use `{ version: 1, requestId, method, params }`, and replies use `{ version: 1, requestId, success, data | error }`. `ping` advertises the exact process-local async completion event as `events.asyncComplete` for RPC-spawn consumers.
|
|
143
160
|
|
|
144
|
-
Methods: `ping`, `status`, `spawn`, `steer`, `interrupt`, `resume`, and `stop`. `ping` capability metadata advertises optional projections: `capabilities.fleetStatus: { version: 1 }` adds bounded current-session `data.fleet` records (opaque reconciliation `key`, resolved `agent`, optional `role`, `model`, `effort`, caller-facing `goal`, `startedAt`, split `{ input, output, total }` tokens, plus `totalActive`/`omitted` overflow counts) to successful `status` replies; `capabilities.launchResolvedExtensions` advertises parent-resolved opaque launch-extension identifiers in status details; `capabilities.runtimeAcknowledgedExtensions` advertises the best-effort child-runtime acknowledgement projection fed by cooperating extensions emitting `subagent:acknowledge-extension`. Foreground `details.results[]` rows carry a stable numeric `index`; correlate children by `(runId, index)` rather than row position. Consumers should read status/result artifacts and RPC projections instead of scraping terminal output and must ignore unknown fields. `spawn` is async-only and rejects management actions, `async: false`, or `clarify: true`; it reuses the normal executor, so discovery, validation, session attribution, configured spawn caps, child-safety depth, artifacts, and async status are shared with the `subagent` tool. `status`, acknowledged async `steer`, and `interrupt` map to the normal control actions. RPC steer disables pause-and-revive recovery and advertises `capabilities.nonRecoveringSteer`, preserving the caller's authority over the exact spawned child. `resume` requires a target plus non-empty message and delegates to the package-owned revival path; it may set a caller-owned `file-only` output path but cannot override the persisted child model, tools, budgets, session ownership, or exclusive session lease. `stop` targets running async runs through the existing timeout control channel. `pi.events` is process-local, so separate Pi processes and child subagents need lifecycle artifact files or `pi-intercom` instead.
|
|
161
|
+
Methods: `ping`, `status`, `spawn`, `steer`, `interrupt`, `resume`, and `stop`. `ping` capability metadata advertises optional projections: `capabilities.fleetStatus: { version: 1 }` adds bounded current-session `data.fleet` records (opaque reconciliation `key`, resolved `agent`, optional `role`, `model`, `effort`, caller-facing `goal`, `startedAt`, split `{ input, output, total }` tokens, plus `totalActive`/`omitted` overflow counts) to successful `status` replies; `capabilities.launchResolvedExtensions` advertises parent-resolved opaque launch-extension identifiers in status details; `capabilities.runtimeAcknowledgedExtensions` advertises the best-effort child-runtime acknowledgement projection fed by cooperating extensions emitting `subagent:acknowledge-extension`. Foreground `details.results[]` rows carry a stable numeric `index`; correlate children by `(runId, index)` rather than row position. Consumers should read status/result artifacts and RPC projections instead of scraping terminal output and must ignore unknown fields. `spawn` requires `workflowScript`, is async-only, and rejects management actions, `async: false`, or `clarify: true`; it reuses the normal executor, so discovery, validation, session attribution, configured spawn caps, child-safety depth, artifacts, and async status are shared with the `subagent` tool. `status`, acknowledged async `steer`, and `interrupt` map to the normal control actions. RPC steer disables pause-and-revive recovery and advertises `capabilities.nonRecoveringSteer`, preserving the caller's authority over the exact spawned child. `resume` requires a target plus non-empty message and delegates to the package-owned revival path; it may set a caller-owned `file-only` output path but cannot override the persisted child model, tools, budgets, session ownership, or exclusive session lease. `stop` targets running async runs through the existing timeout control channel. `pi.events` is process-local, so separate Pi processes and child subagents need lifecycle artifact files or `pi-intercom` instead.
|