@ferris1225/pi-subagents 4.3.31 → 4.3.33
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 +80 -0
- package/LICENSE +1 -1
- package/README.md +215 -273
- package/index.ts +15 -14
- package/package.json +10 -10
- package/skills/workflow/SKILL.md +226 -0
- package/src/configuration/config.ts +17 -121
- package/src/configuration/models.ts +1 -1
- package/src/configuration/setup.ts +80 -176
- package/src/configuration/ui.ts +28 -66
- package/src/delegation/agents.ts +79 -209
- package/src/delegation/builtin-agents.ts +60 -0
- package/src/delegation/dispatch.ts +32 -149
- package/src/delegation/prompt.ts +7 -5
- package/src/execution/rpc-control.ts +6 -2
- package/src/execution/rpc-run.ts +60 -20
- package/src/execution/spawn.ts +17 -28
- package/src/isolation/git-command.ts +1 -2
- package/src/isolation/recovery.ts +1 -1
- package/src/isolation/temp-hygiene.ts +2 -2
- package/src/isolation/worktree.ts +31 -17
- package/src/lifecycle/completion.ts +1 -1
- package/src/lifecycle/dispatch-core.ts +142 -0
- package/src/lifecycle/durable.ts +3 -3
- package/src/lifecycle/runtime.ts +34 -1
- package/src/lifecycle/thread-lifecycle.ts +36 -25
- package/src/lifecycle/thread-shared.ts +11 -4
- package/src/lifecycle/tools.ts +84 -11
- package/src/presentation/monitor.ts +39 -17
- package/src/presentation/widget.ts +2 -2
- package/src/workflow/durable.ts +195 -0
- package/src/workflow/engine.ts +625 -0
- package/src/workflow/files.ts +217 -0
- package/src/workflow/plan.ts +340 -0
- package/src/workflow/state.ts +48 -0
- package/src/workflow/tool.ts +269 -0
- package/workflows/code-review.md +57 -0
- package/workflows/migration.md +52 -0
- package/workflows/research.md +47 -0
- package/agents/artisan.md +0 -18
- package/agents/scout.md +0 -19
package/README.md
CHANGED
|
@@ -8,92 +8,29 @@
|
|
|
8
8
|
|
|
9
9
|
On-demand delegation for [pi](https://github.com/earendil-works/pi): a lightweight
|
|
10
10
|
reader and an implementer, durable threads, and Git worktree isolation. Main
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
delegates whenever the work has independent parts or a bounded job can be briefed
|
|
12
|
+
self-contained — parallel phases usually beat a serialized main.
|
|
13
13
|
|
|
14
14
|
## What's new
|
|
15
15
|
|
|
16
|
-
**4.3.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
and
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
**4.3.26** — scout is search-only, completions stop double-delivering, and
|
|
35
|
-
progress no longer routes through files. Scout's role is now exactly code and
|
|
36
|
-
documentation search plus web lookup; it has no shell, and work that needs
|
|
37
|
-
execution stays in main. A result that exceeds the inline limit is no longer
|
|
38
|
-
dumped truncated into the completion: none of it is inlined, and the notice
|
|
39
|
-
points at the full Markdown artifact, so the content enters the main context
|
|
40
|
-
exactly once. `subagent_status` answers progress with an activity trail
|
|
41
|
-
(what each run has been doing) instead of child session paths, and the
|
|
42
|
-
advisory `subagent_risk` tool is gone. Development dependencies track Pi 1.3.0.
|
|
43
|
-
|
|
44
|
-
**4.3.24** — the per-model cost footer drops the live `tok/s` throughput
|
|
45
|
-
figure: measured rates could not be trusted across providers, so the footer
|
|
46
|
-
sticks to what pi reports exactly — per-model token flow, cost, context share,
|
|
47
|
-
and thinking level.
|
|
48
|
-
|
|
49
|
-
**4.3.23** — Pi 1.0.3. Development dependencies track that release. A stored
|
|
50
|
-
agent model that still names `azure-openai-responses/<id>` keeps working: it
|
|
51
|
-
follows the live catalog, and is saved as `azure/<id>` once that is the id Pi
|
|
52
|
-
reports.
|
|
53
|
-
|
|
54
|
-
**4.3.22** — use a subagent when the work can run independently in parallel, its
|
|
55
|
-
boundary is clear, and delegation will actually reduce cost or improve
|
|
56
|
-
completion quality. Role choice stays with scout and artisan.
|
|
57
|
-
|
|
58
|
-
**4.3.21** — two built-in roles. `scout` is the lightweight read-only researcher
|
|
59
|
-
and `artisan` implements one substantial change. Steward and sentinel are no
|
|
60
|
-
longer shipped. Role prompts follow the GPT-6 Astra guidance: the brief wins,
|
|
61
|
-
authorized work runs through, and checks stay proportional. Main prefers scout
|
|
62
|
-
and artisan when a fresh context or a parallel phase helps, and does not open
|
|
63
|
-
extra phases to fill free slots.
|
|
64
|
-
|
|
65
|
-
**4.3.20** — Pi 1.0 prompt sections and tool exposure. The delegation contract
|
|
66
|
-
is a `<subagents>` section, and live leases are a separate `<subagent_leases>`
|
|
67
|
-
section, so an unchanged turn keeps the cached system prefix. Orchestration
|
|
68
|
-
tools stay declared to the model and cannot be called from codemode scripts.
|
|
69
|
-
Dispatch and stop run sequentially so one assistant message cannot race
|
|
70
|
-
admission. Child processes still force provider `maxRetries: 0`, using the
|
|
71
|
-
1.0 registration that requires an `api`.
|
|
72
|
-
|
|
73
|
-
**4.3.19** — session-start restore and recovery notices stay inside the current
|
|
74
|
-
project. A second pi window no longer surfaces another checkout's retained
|
|
75
|
-
worktree or restores (and would otherwise stop) that project's interrupted runs.
|
|
76
|
-
|
|
77
|
-
**4.3.18** — main-first delegation: keep known-context local changes in main,
|
|
78
|
-
use cleanup and review roles only where they add value, and configure process
|
|
79
|
-
capacity with `maxConcurrentAgents`. See [Evaluate delegation](#evaluate-delegation)
|
|
80
|
-
to compare quality, elapsed time, and complete task cost on your own workload.
|
|
81
|
-
|
|
82
|
-
**4.3.15** — fix the cost footer crash after `/reload`, `/new`, `/resume`, or
|
|
83
|
-
`/fork`: each footer now reads only its own session's live context, never an
|
|
84
|
-
event context retained from the previous session.
|
|
85
|
-
|
|
86
|
-
**4.3.13** — the footer is reserved for the per-model cost tally: the
|
|
87
|
-
`subagents N running` activity-count line is gone, leaving the widget,
|
|
88
|
-
completion notifications, and `subagent_status` for live progress.
|
|
89
|
-
|
|
90
|
-
**4.3.12** — per-model accounting: the main window's consumption line becomes a
|
|
91
|
-
per-model cost footer (token flow, cost, context share, and live `tok/s` per
|
|
92
|
-
`provider/model`), awaited children's usage is no longer folded into the parent
|
|
93
|
-
session total, and parallel completion totals are grouped per model instead of
|
|
94
|
-
summed across them.
|
|
95
|
-
|
|
96
|
-
See [CHANGELOG.md](./CHANGELOG.md).
|
|
16
|
+
**4.3.33** — dependency graphs for multi-phase work. `subagent_workflow` declares
|
|
17
|
+
nodes with `dependsOn`, validates the graph before any child starts, dispatches
|
|
18
|
+
each node as its prerequisites settle, and reports the whole graph once. Saved
|
|
19
|
+
definitions live in `.pi/workflows/` or `~/.pi/agent/workflows/`, three templates
|
|
20
|
+
ship with the package, and a `workflow` skill carries the authoring guidance.
|
|
21
|
+
`subagent_status` and `subagent_stop` accept a graph id.
|
|
22
|
+
|
|
23
|
+
**4.3.32** — codemode-aware, tool-agnostic role policy and a minimal config.
|
|
24
|
+
`scout` keeps every active tool the host proves read-only and can never keep a
|
|
25
|
+
tool that reaches other tools, such as `codemode`, while `artisan` inherits the
|
|
26
|
+
session's live surface, codemode included, so a code-mode host works unchanged.
|
|
27
|
+
The two roles ship as code, are always enabled, and custom `agent.md` discovery
|
|
28
|
+
is gone; `/subagents-setup` now only picks a model and thinking level per role,
|
|
29
|
+
and the config file keeps just `agentModels` and `agentThinkingLevels`. The
|
|
30
|
+
delegation contract defaults to delegating independent or self-contained work.
|
|
31
|
+
|
|
32
|
+
See [CHANGELOG.md](./CHANGELOG.md) for earlier releases; every published version
|
|
33
|
+
is preserved as a GitHub Release.
|
|
97
34
|
|
|
98
35
|
## Contents
|
|
99
36
|
|
|
@@ -101,16 +38,15 @@ See [CHANGELOG.md](./CHANGELOG.md).
|
|
|
101
38
|
- [Install](#install)
|
|
102
39
|
- [The team](#the-team)
|
|
103
40
|
- [Dispatching work](#dispatching-work)
|
|
41
|
+
- [Workflows](#workflows)
|
|
104
42
|
- [Parallel edits](#parallel-edits)
|
|
105
43
|
- [Runs: status and stop](#runs-status-and-stop)
|
|
106
44
|
- [Live status and results](#live-status-and-results)
|
|
107
45
|
- [Models, thinking, and tools](#models-thinking-and-tools)
|
|
108
46
|
- [Configuration](#configuration)
|
|
109
47
|
- [Evaluate delegation](#evaluate-delegation)
|
|
110
|
-
- [Custom agents](#custom-agents)
|
|
111
48
|
- [Storage and cleanup](#storage-and-cleanup)
|
|
112
49
|
- [Development](#development)
|
|
113
|
-
- [Changelog](#changelog)
|
|
114
50
|
- [Release](#release)
|
|
115
51
|
|
|
116
52
|
## Why
|
|
@@ -120,9 +56,11 @@ at "spawn a child with a prompt" and leave the hard parts — when to delegate,
|
|
|
120
56
|
wide to fan out, what happens when a model dies, how results come
|
|
121
57
|
back — with you. This extension owns them:
|
|
122
58
|
|
|
123
|
-
- Main
|
|
124
|
-
|
|
125
|
-
|
|
59
|
+
- Main delegates whenever the work has independent parts or a bounded job can be
|
|
60
|
+
briefed self-contained — parallel phases usually beat a serialized main, and
|
|
61
|
+
broad or unfamiliar lookups go to a child instead of the same searches run
|
|
62
|
+
serially.
|
|
63
|
+
`scout` covers read-only code, documentation, and web
|
|
126
64
|
lookup only — it has no shell, so work that needs execution stays in main;
|
|
127
65
|
`artisan` covers one substantial change. A small edit already understood in
|
|
128
66
|
the current context stays in main, and a free process slot is not a reason
|
|
@@ -154,14 +92,11 @@ pi install npm:@ferris1225/pi-subagents
|
|
|
154
92
|
|
|
155
93
|
Pi's extension list shows `@ferris1225/pi-subagents` without an internal source-path suffix.
|
|
156
94
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
full setup asks each enabled role's model, then its thinking level. A newly shipped
|
|
163
|
-
built-in is surfaced once without being re-enabled after you deliberately turn it
|
|
164
|
-
off. Then ask for work:
|
|
95
|
+
A fresh install writes a default config at session start — both roles enabled,
|
|
96
|
+
both following the main model — and announces `/subagents-setup` once; the file
|
|
97
|
+
itself is the marker, so later sessions stay silent. Run `/subagents-setup` to
|
|
98
|
+
pick a model and thinking level per role — that is the entire configuration
|
|
99
|
+
surface. Then ask for work:
|
|
165
100
|
|
|
166
101
|
```text
|
|
167
102
|
Map how authentication works, fix the refresh race, and run the tests.
|
|
@@ -183,9 +118,8 @@ tests, docs, and local cleanup, and reports a disproved premise or a scope/appro
|
|
|
183
118
|
blocker with evidence. Handoffs lead with the outcome and report checks as
|
|
184
119
|
`command → result`.
|
|
185
120
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
children on every task.
|
|
121
|
+
The catalog is fixed: `scout` and `artisan` are always enabled, and there are no
|
|
122
|
+
custom role files. Two roles do not require two children on every task.
|
|
189
123
|
|
|
190
124
|
Every child is a leaf pi process with its own context window and no memory of your
|
|
191
125
|
conversation. It still loads normal Pi context, including applicable project
|
|
@@ -197,9 +131,7 @@ material assumptions or blockers.
|
|
|
197
131
|
|
|
198
132
|
Children run the official `pi --mode rpc` server, using Pi's exported command/response
|
|
199
133
|
types and its own session persistence. There is no separate subagent protocol. The
|
|
200
|
-
host transport remains local.
|
|
201
|
-
process, signals only that process, and does not provide process-tree shutdown,
|
|
202
|
-
bounded abort coordination, or cancellation of child extension dialogs.
|
|
134
|
+
host transport remains local.
|
|
203
135
|
|
|
204
136
|
## Dispatching work
|
|
205
137
|
|
|
@@ -234,24 +166,18 @@ subagent({
|
|
|
234
166
|
});
|
|
235
167
|
```
|
|
236
168
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
reason to invent another phase. The runtime paces
|
|
242
|
-
execution: `maxConcurrentAgents: 0` (the default) keeps automatic capacity at half
|
|
243
|
-
the machine's cores, bounded to 4–6 child processes. Set `maxConcurrentAgents` to
|
|
244
|
-
1–6 for an explicit capacity. Wider batches queue and start as slots free.
|
|
245
|
-
This setting limits simultaneous processes, not total tasks or total token cost.
|
|
169
|
+
Independent phases go in one `tasks` array. The runtime paces execution at half
|
|
170
|
+
the machine's cores, bounded to 4–6 simultaneous child processes; wider batches
|
|
171
|
+
queue and start as slots free. The limit paces processes, not total tasks or
|
|
172
|
+
total token cost.
|
|
246
173
|
|
|
247
174
|
A run leases its stable, single-line `phaseId` in the resolved working directory.
|
|
248
175
|
Rewording the task with the same `phaseId` is rejected and names the existing run.
|
|
249
176
|
Completed and failed phases stay owned for the current session, even without a retained
|
|
250
177
|
session file. Calls that omit `phaseId` keep exact normalized task+cwd matching; equal
|
|
251
|
-
task text with different phase ids is
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
the runtime chooses which owner to report.
|
|
178
|
+
task text with different phase ids is still rejected by that fallback. Matching is
|
|
179
|
+
deterministic, never fuzzy, embedding-based, or inferred from natural language. Active
|
|
180
|
+
leases win over matching settled threads when the runtime chooses which owner to report.
|
|
255
181
|
|
|
256
182
|
Because queueing is pacing rather than refusal, it is always reported as such.
|
|
257
183
|
Dispatch confirmations name each waiting run's real reason — waiting for a free
|
|
@@ -269,16 +195,89 @@ only when the phases are independent. Never overlap writers or duplicate an owne
|
|
|
269
195
|
phase, and do not split one tightly coupled change across children.
|
|
270
196
|
|
|
271
197
|
Verification follows the change and required project gates. Tests should catch
|
|
272
|
-
meaningful failures, not mirror reversible, low-impact edits
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
the final gate, and release; children never bump versions, commit, push, or publish.
|
|
198
|
+
meaningful failures, not mirror reversible, low-impact edits. Fix failures caused
|
|
199
|
+
by the change, then repeat or broaden checks only for new edits, failures, or
|
|
200
|
+
unresolved concerns. Main owns architecture, the integrated diff, the final gate,
|
|
201
|
+
and release; children never bump versions, commit, push, or publish.
|
|
277
202
|
|
|
278
203
|
These defaults follow [OpenAI's GPT-6 Astra model guidance](https://developers.openai.com/api/docs/guides/latest-model?model=gpt-6-astra)
|
|
279
204
|
and [Eric Provencher's skills and prompts guidance](https://x.com/pvncher/status/2095991462416490862).
|
|
280
205
|
They simplify instructions without changing the configured models or thinking levels.
|
|
281
206
|
|
|
207
|
+
## Workflows
|
|
208
|
+
|
|
209
|
+
A request sometimes has phases whose order is known before the work starts:
|
|
210
|
+
establish the facts, change independent slices at the same time, then run one
|
|
211
|
+
gate. `subagent_workflow` declares that graph once. The runtime starts each node
|
|
212
|
+
the moment its prerequisites settle and a process slot frees, so no parent model
|
|
213
|
+
turn sits between waves, and it wakes the main agent once with a summary of the
|
|
214
|
+
whole graph.
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
subagent_workflow({
|
|
218
|
+
name: "auth-fix",
|
|
219
|
+
description: "Map the refresh race, fix it, gate it.",
|
|
220
|
+
nodes: [
|
|
221
|
+
{ id: "map", agent: "scout", task: "Map the refresh race in src/auth. Cite path:line." },
|
|
222
|
+
{ id: "fix", agent: "artisan", task: "Fix it. Evidence:\n{{map}}", dependsOn: ["map"],
|
|
223
|
+
scope: { paths: ["src/auth"] } },
|
|
224
|
+
{ id: "tests", agent: "artisan", task: "Add regression tests. Evidence:\n{{map}}",
|
|
225
|
+
dependsOn: ["map"], scope: { paths: ["test/auth.test.ts"] } },
|
|
226
|
+
{ id: "gate", agent: "artisan", task: "Run the checks.\nFix:\n{{fix}}\nTests:\n{{tests}}",
|
|
227
|
+
dependsOn: ["fix", "tests"] },
|
|
228
|
+
],
|
|
229
|
+
});
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
- `{{id}}` interpolates that node's final answer into a dependent's brief;
|
|
233
|
+
`{{id.status}}`, `{{id.runId}}`, and `{{id.error}}` interpolate facts. A
|
|
234
|
+
placeholder may only name a node the current one waits for, directly or through
|
|
235
|
+
its chain; anything else is rejected at compile time.
|
|
236
|
+
- The graph is validated before the first child starts: unique ids, existing
|
|
237
|
+
dependencies, no cycles, resolvable placeholders, and no declared writer-scope
|
|
238
|
+
overlap between nodes that no dependency orders.
|
|
239
|
+
- Nodes are ordinary one-shot runs: same admission, isolation, durable
|
|
240
|
+
checkpoints, and usage accounting as a `subagent` call. A node's result is
|
|
241
|
+
registered only after its worktree is integrated, so a dependent reads what its
|
|
242
|
+
prerequisite actually left behind.
|
|
243
|
+
- Failure is contained by the graph. A failed node blocks only its dependents,
|
|
244
|
+
independent branches keep running, and the summary names completed, failed, and
|
|
245
|
+
never-ran nodes with the reason. Nodes never retry: main finishes incomplete work
|
|
246
|
+
from the retained evidence.
|
|
247
|
+
- A workflow reports once. Node completions are quiet, and the single summary
|
|
248
|
+
carries each node's answer (clipped, with a full-report file when anything was
|
|
249
|
+
cut) plus a per-model tally.
|
|
250
|
+
- Write-capable nodes in a graph default to a detached worktree, which needs a
|
|
251
|
+
committed `HEAD`; pass `"isolation": "shared"` on a node to keep it in your
|
|
252
|
+
checkout and serialize it on the repository write lane.
|
|
253
|
+
|
|
254
|
+
Saved definitions run by name and can be reviewed before they run:
|
|
255
|
+
|
|
256
|
+
- Project: `.pi/workflows/<name>.json` or `.pi/workflows/<name>.md` (trusted projects only)
|
|
257
|
+
- User: `~/.pi/agent/workflows/`
|
|
258
|
+
- Shipped: the `code-review`, `research`, and `migration` templates in this package
|
|
259
|
+
- Precedence: project > user > built-in, where the same `name` wins
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
subagent_workflow({ workflow: "code-review" });
|
|
263
|
+
subagent_workflow({ file: ".pi/workflows/code-review.md" });
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
A Markdown definition carries prose plus one `json` fenced block holding the plan
|
|
267
|
+
object or a bare node array. The package also ships a `workflow` skill
|
|
268
|
+
(`skills/workflow/SKILL.md`) with the authoring guidance: when a graph is worth
|
|
269
|
+
its cost, how to slice phases, how to write briefs, and the anti-patterns.
|
|
270
|
+
|
|
271
|
+
Derived phase ids are `<workflow-slug>.<node-id>`, and a settled phase stays owned
|
|
272
|
+
for the parent session, so the same graph with identical briefs is rejected as a
|
|
273
|
+
duplicate. Re-run it in a new session, or change what the phases target.
|
|
274
|
+
|
|
275
|
+
`subagent_status({ workflow: id })` reports nodes and their wait reasons;
|
|
276
|
+
`subagent_stop({ workflow: id })` stops a graph without starting its idle
|
|
277
|
+
dependents. An unfinished graph keeps its shape on disk, so the next session's
|
|
278
|
+
start notice and `subagent_status` report which nodes completed and which were
|
|
279
|
+
still running.
|
|
280
|
+
|
|
282
281
|
## Parallel edits
|
|
283
282
|
|
|
284
283
|
`scope` is declarative admission metadata for expected writes, not access control. `paths`
|
|
@@ -303,8 +302,8 @@ launch receipt say `independence not verified`; that means the contract lacked e
|
|
|
303
302
|
metadata, not that overlap was proved safe. Single calls never make a batch-independence
|
|
304
303
|
claim. The existing shared-checkout writer lane remains the final serialization boundary.
|
|
305
304
|
|
|
306
|
-
- Single tasks use your checkout. Parallel write-capable agents (`artisan`
|
|
307
|
-
|
|
305
|
+
- Single tasks use your checkout. Parallel write-capable agents (`artisan`)
|
|
306
|
+
default to a detached Git worktree, so parallel writers run at
|
|
308
307
|
the same time. Worktree mode needs a committed `HEAD`. Read-only roles such as
|
|
309
308
|
scout stay on the shared checkout, and an explicit `isolation: worktree` for a
|
|
310
309
|
read-only role is rejected.
|
|
@@ -313,9 +312,6 @@ claim. The existing shared-checkout writer lane remains the final serialization
|
|
|
313
312
|
Child tools, network access, and environment access retain the Pi process's privileges.
|
|
314
313
|
Third-party Pi packages execute as trusted code and must be reviewed accordingly.
|
|
315
314
|
|
|
316
|
-
- A role file can pin its own default with `isolation: worktree` or
|
|
317
|
-
`isolation: shared` in the frontmatter. Precedence is an explicit per-dispatch
|
|
318
|
-
`isolation`, then the role's declaration, then the parallel write default.
|
|
319
315
|
- An isolated run's tracked, deleted, untracked, and binary changes integrate
|
|
320
316
|
back exactly once, after the child settles. Nothing is staged and your index is
|
|
321
317
|
untouched.
|
|
@@ -342,8 +338,9 @@ deliverable needs a new phase and brief, not a recycled thread.
|
|
|
342
338
|
|
|
343
339
|
| Tool | What it does |
|
|
344
340
|
| ---- | ------------ |
|
|
345
|
-
| `
|
|
346
|
-
| `
|
|
341
|
+
| `subagent_workflow` | Run a dependency graph: declare `nodes` with `dependsOn` (or name a saved definition), get a launch receipt, and receive one summary when the graph settles. |
|
|
342
|
+
| `subagent_status` | Read-only progress check. Omit `id` to list this parent session's runs, or pass an exact numeric `id` to inspect one. Omit `workflow` to include graphs, or pass a graph id. |
|
|
343
|
+
| `subagent_stop` | Destructively cancel/retire a run by id/prefix, a whole graph with `workflow: id`, or all active runs with `all: true`. Delivers partial output and finalizes isolated changes. |
|
|
347
344
|
|
|
348
345
|
```ts
|
|
349
346
|
subagent_status({});
|
|
@@ -356,20 +353,19 @@ child to finish. The model-facing answer is the progress view: state, elapsed ti
|
|
|
356
353
|
and an activity trail of what the run has been doing (for example
|
|
357
354
|
`activity: read src/config.ts · grep "cacheKey" · thinking`), plus failure
|
|
358
355
|
diagnostics and any actionable paths (a truncated run's full-result file, retained
|
|
359
|
-
worktree/patch artifacts).
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
to generate strict JSON. Agent-written reports remain evidence to verify.
|
|
356
|
+
worktree/patch artifacts). States distinguish `queued`, `running`, `interrupting`,
|
|
357
|
+
`settling` (Git finalization), `completed`, `failed`, `stopped`, and `interrupted`
|
|
358
|
+
(recovered unfinished work). Queued runs report their actual wait reason. Settled
|
|
359
|
+
runs remain queryable in the current parent session even after their transient
|
|
360
|
+
widget rows disappear.
|
|
361
|
+
|
|
362
|
+
The tool returns these facts in Pi's structured `details.runs` field. An individual
|
|
363
|
+
run's failure does not make a successful status lookup a tool error; an unknown `id`
|
|
364
|
+
does. This is runtime-authored data, not a requirement for children to generate
|
|
365
|
+
strict JSON. Agent-written reports remain evidence to verify.
|
|
370
366
|
|
|
371
367
|
A background dispatch returns a launch receipt, then its completion arrives at
|
|
372
|
-
the next safe parent boundary—after current tool calls and before the next model
|
|
368
|
+
the next safe parent boundary — after current tool calls and before the next model
|
|
373
369
|
call. `wait: true` instead holds the dispatch until its new runs settle, which is
|
|
374
370
|
useful for one-shot `pi -p` sessions or an immediate dependency. Each run has one
|
|
375
371
|
delivery route; aborting the waiting parent turn transfers delivery to the
|
|
@@ -384,26 +380,23 @@ manual recovery after reload or crash. Missing session files no longer discard
|
|
|
384
380
|
isolated edits. Restore for this checkout runs at session start; lookup tools,
|
|
385
381
|
prompt injection, and fresh dispatch wait for that pass so an existing id cannot
|
|
386
382
|
be reported missing or reused. A sibling window in another project leaves those
|
|
387
|
-
records untouched. Missing recorded worktrees surface as failures without
|
|
388
|
-
remaining recovery evidence.
|
|
383
|
+
records untouched. Missing recorded worktrees surface as failures without
|
|
384
|
+
discarding the remaining recovery evidence.
|
|
389
385
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
386
|
+
Invalid durable records are dropped without following or deleting their targets.
|
|
387
|
+
Recovery-owned worktrees and patches stay protected from startup sweeps and
|
|
388
|
+
project-root retention. Completed/failed runs drop their durable thread record;
|
|
389
|
+
after reload, inspect their delivered result instead of expecting them in the
|
|
390
|
+
current-session status list.
|
|
395
391
|
|
|
396
392
|
## Live status and results
|
|
397
393
|
|
|
398
394
|
The TUI widget renders one line per active run in fixed identity columns —
|
|
399
|
-
status icon, right-aligned `#id`, padded agent name, then the task label —
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
`think:<level>`, and seconds-precision elapsed. A live run renders
|
|
405
|
-
two lines: what it is — agent, task, usage, model, thinking, elapsed —
|
|
406
|
-
and, dim under the label column, what it is doing right now:
|
|
395
|
+
status icon, right-aligned `#id`, padded agent name, then the task label — with
|
|
396
|
+
the live activity dimmed after `↳` on its own line and the rest of the telemetry
|
|
397
|
+
inline after ` · `: the worktree badge, wait state, token flow in pi's footer
|
|
398
|
+
vocabulary (`↑` input, `↓` output, `R`/`W` cache read/write), cost, full
|
|
399
|
+
`provider/model`, current effective `think:<level>`, and seconds-precision elapsed:
|
|
407
400
|
|
|
408
401
|
```text
|
|
409
402
|
● #12 artisan src/cache.ts · worktree:a91f3c · ↑5.2k ↓41.0k R210.0k W6.1k $1.9400 · think:high · 12m06s
|
|
@@ -418,18 +411,16 @@ Telemetry drops leftmost-first when a row runs out of width (badge, wait state,
|
|
|
418
411
|
usage, model, thinking) while elapsed survives every width. Queued rows state
|
|
419
412
|
what they actually wait for — `queued` for a free process slot, `repo lane`
|
|
420
413
|
for shared-checkout write serialization, or `starting`. The widget is
|
|
421
|
-
capped at ten lines:
|
|
422
|
-
`… +N more` marker so the editor keeps its space.
|
|
414
|
+
capped at ten lines: extra runs collapse into a `… +N more` marker.
|
|
423
415
|
|
|
424
416
|
Completions resume the main agent on their own, with a compact block of at most 40
|
|
425
417
|
lines by default. Longer output (or lines wider than 200 characters) is not inlined
|
|
426
|
-
at all: the notice states the true size
|
|
427
|
-
a short result has a long line — and points at the unchanged Markdown artifact
|
|
418
|
+
at all: the notice states the true size and points at the unchanged Markdown artifact
|
|
428
419
|
holding the full output, and main is told to read that file. The content therefore
|
|
429
420
|
enters the main context exactly once, never first as a truncated copy the model
|
|
430
|
-
cannot trust and then again as the file read. Roles write result-only handoffs —
|
|
431
|
-
verification, unresolved blockers — and the main agent is told to
|
|
432
|
-
conclusion rather than restate what you already read. A failed run adds its
|
|
421
|
+
cannot trust and then again as the file read. Roles write result-only handoffs —
|
|
422
|
+
outcome, paths, verification, unresolved blockers — and the main agent is told to
|
|
423
|
+
add its conclusion rather than restate what you already read. A failed run adds its
|
|
433
424
|
failed-tool diagnostics.
|
|
434
425
|
|
|
435
426
|
Delivery is held while a context compaction is in flight and released once it
|
|
@@ -437,11 +428,9 @@ settles — on failure and abort too — so a result a child spent minutes produ
|
|
|
437
428
|
is never swallowed by the summary that replaces the history.
|
|
438
429
|
|
|
439
430
|
A `wait: true` dispatch streams its progress onto the tool card while it waits.
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
`provider/model` ref — when it settles, and a parallel group's totals
|
|
444
|
-
are grouped per model, never summed across them:
|
|
431
|
+
Each child reports its usage per run — with its full `provider/model` ref — when it
|
|
432
|
+
settles, and a parallel group's totals are grouped per model, never summed across
|
|
433
|
+
them:
|
|
445
434
|
|
|
446
435
|
```text
|
|
447
436
|
Totals: 3 runs · zhipu/glm-4.7: ↓300 $0.0500 · anthropic/claude-sonnet-4: ↓4.0k $1.5000
|
|
@@ -459,29 +448,34 @@ session** continues on the main model, so finished searches, reads, and edits
|
|
|
459
448
|
survive. Ordinary task failures do not trigger a handoff.
|
|
460
449
|
|
|
461
450
|
Thinking is a **role default** — scout `low`, artisan `high` — clamped to what
|
|
462
|
-
the effective model supports.
|
|
463
|
-
|
|
451
|
+
the effective model supports. The `/subagents-setup` thinking picker lists only
|
|
452
|
+
the levels that model supports and marks the role
|
|
464
453
|
default; selecting it clears the stored override. There is no
|
|
465
|
-
Auto choice
|
|
466
|
-
no `thinking` field in agent Markdown. Precedence: your setup override > the
|
|
454
|
+
Auto choice and no per-dispatch `thinking` flag. Precedence: your setup override > the
|
|
467
455
|
role default, then the model clamp. There is no separate vision mode — assign
|
|
468
456
|
a multimodal model and name the image paths in the task.
|
|
469
457
|
|
|
470
|
-
Every dispatch, startup retry, and model fallback snapshots the parent's
|
|
471
|
-
and all `subagent*` tools are removed so children remain leaves. A
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
`
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
458
|
+
Every dispatch, startup retry, and model fallback snapshots the parent's live
|
|
459
|
+
tools, and all `subagent*` tools are removed so children remain leaves. A broad
|
|
460
|
+
role inherits that snapshot — including `codemode` when the session runs it — so
|
|
461
|
+
a code-mode parent produces code-mode children under the same `codemode.mode`.
|
|
462
|
+
An explicit resolved list that names no MCP tool also excludes MCP tools it does
|
|
463
|
+
not name.
|
|
464
|
+
|
|
465
|
+
Neither role names extension, MCP, or vendor tools. `scout` is a hard
|
|
466
|
+
read-only boundary that is derived from the live catalog: it keeps every active
|
|
467
|
+
tool the host proves read-only — `annotations.readOnlyHint` for extension and
|
|
468
|
+
MCP tools, plus pi's own `read`, `grep`, `find`, and `ls` — and never a shell, a
|
|
469
|
+
mutation tool, or a tool that reaches other tools, so `codemode` and
|
|
470
|
+
`tool_search` cannot reach a writer through it. A retrieval extension or an MCP
|
|
471
|
+
search server therefore works for scout without being named anywhere, and without
|
|
472
|
+
reconfiguring the server: a read-only tool the session reaches only through
|
|
473
|
+
`codemode` or `tool_search` — pi's default for MCP servers — is handed to scout
|
|
474
|
+
directly, which is the same capability without giving scout a way to reach a
|
|
475
|
+
writer. Every other MCP tool stays excluded from that child. Tools with no
|
|
476
|
+
read-only annotation, whether they are declared by another role or by an active
|
|
477
|
+
extension, are conservatively treated as write-capable when isolation is chosen.
|
|
478
|
+
An empty resolved snapshot starts the child with `--no-tools`.
|
|
485
479
|
|
|
486
480
|
For external research scout prefers official documentation, specifications, release
|
|
487
481
|
notes, and first-party repositories; it fetches decisive pages rather than citing
|
|
@@ -489,62 +483,37 @@ search snippets, records material dates/versions, and marks uncertainty.
|
|
|
489
483
|
|
|
490
484
|
## Configuration
|
|
491
485
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
that
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
model/thinking settings; no retired-name aliases or configuration migration are applied.
|
|
501
|
-
The file is created on first start, and its presence is what keeps later sessions
|
|
502
|
-
silent. To start over, delete it and run `/subagents-setup`; the next session writes
|
|
503
|
-
the defaults again. Settings live in `~/.pi/agent/pi-subagents.json` (following
|
|
504
|
-
`PI_CODING_AGENT_DIR`):
|
|
486
|
+
`scout` and `artisan` are always enabled; the only settings are a model and a
|
|
487
|
+
thinking level per role. `/subagents-setup` opens a menu with one row per role —
|
|
488
|
+
its summary, current model, and current thinking level — plus a "Both roles"
|
|
489
|
+
walk that asks each role's model and then its thinking level. `Esc` moves back,
|
|
490
|
+
and the model picker supports fuzzy search. To start over, delete
|
|
491
|
+
`~/.pi/agent/pi-subagents.json` and run `/subagents-setup`; the next session
|
|
492
|
+
writes the defaults again. Settings live in `~/.pi/agent/pi-subagents.json`
|
|
493
|
+
(following `PI_CODING_AGENT_DIR`):
|
|
505
494
|
|
|
506
495
|
```json
|
|
507
496
|
{
|
|
508
|
-
"enabledAgents": ["scout", "artisan"],
|
|
509
|
-
"knownAgents": ["scout", "artisan"],
|
|
510
497
|
"agentModels": { "scout": "anthropic/claude-haiku-4-5" },
|
|
511
|
-
"agentThinkingLevels": { "artisan": "high" }
|
|
512
|
-
"maxResultLines": 40,
|
|
513
|
-
"maxConcurrentAgents": 0,
|
|
514
|
-
"agentScope": "user",
|
|
515
|
-
"idleTimeoutSec": 1800
|
|
498
|
+
"agentThinkingLevels": { "artisan": "high" }
|
|
516
499
|
}
|
|
517
500
|
```
|
|
518
501
|
|
|
519
502
|
| Field | Meaning |
|
|
520
503
|
| --------------------- | ------- |
|
|
521
|
-
| `
|
|
522
|
-
| `
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
roles or models; edit it in the JSON configuration file.
|
|
535
|
-
|
|
536
|
-
When at least one role is enabled, the delegation directive is installed as a
|
|
537
|
-
`<subagents>` prompt section. Active leases go in `<subagent_leases>`. Pi 1.0
|
|
538
|
-
appends a section delta only when that text changes, so idle turns keep the
|
|
539
|
-
cached system prefix. Hosts without a section map still receive the same
|
|
540
|
-
contract appended to the system prompt. `enabledAgents` is authoritative after
|
|
541
|
-
catalog adoption: a newly shipped built-in is appended once, then `knownAgents`
|
|
542
|
-
records that it was surfaced
|
|
543
|
-
so a deliberate later disable remains disabled. Role names left in an older
|
|
544
|
-
config do nothing unless a file still defines them; saving setup drops names
|
|
545
|
-
that have no file. Available custom roles remain
|
|
546
|
-
selectable even when disabled. Invalid known fields fall back safely, and unknown fields
|
|
547
|
-
are dropped when canonical config is persisted.
|
|
504
|
+
| `agentModels` | Optional model per role as `provider/model-id`; missing means the current main model. |
|
|
505
|
+
| `agentThinkingLevels` | Optional thinking override per role; missing means the role default (`scout` low, `artisan` high). |
|
|
506
|
+
|
|
507
|
+
Everything else is a fixed constant: result deliveries keep 40 lines before the
|
|
508
|
+
on-disk artifact takes over, process capacity is automatic, and a child silent
|
|
509
|
+
for 30 minutes is terminated. Obsolete keys left by older config files are
|
|
510
|
+
dropped when the canonical shape is persisted, and invalid values fall back to
|
|
511
|
+
defaults.
|
|
512
|
+
|
|
513
|
+
The delegation directive is installed as a `<subagents>` prompt section. Active
|
|
514
|
+
leases go in `<subagent_leases>`. Pi 1.0 appends a section delta only when that
|
|
515
|
+
text changes, so idle turns keep the cached system prefix. Hosts without a
|
|
516
|
+
section map still receive the same contract appended to the system prompt.
|
|
548
517
|
|
|
549
518
|
At session start, model overrides that pi no longer reports are removed with a
|
|
550
519
|
one-time notice. If pi's own session compaction fails mid-thread, a notice surfaces
|
|
@@ -562,19 +531,17 @@ facts, but its tests do not establish a quality or cost advantage over solo Pi.
|
|
|
562
531
|
Keep task prompts, models, thinking levels, tools, and project instructions
|
|
563
532
|
fixed. Keep results from earlier attempts out of later prompts; alternate
|
|
564
533
|
execution order and repeat each comparison several times.
|
|
565
|
-
3. Compare main
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
a pool of one can still launch several children sequentially. Record actual
|
|
569
|
-
child counts and roles as well, and do not require filling the pool.
|
|
534
|
+
3. Compare a session where main delegates freely against one where you instruct
|
|
535
|
+
it to work solo (or uninstall the extension). Record actual child counts and
|
|
536
|
+
roles as well — a delegation-prone main may still finish some tasks alone.
|
|
570
537
|
4. Measure final acceptance and regressions, elapsed time through integration,
|
|
571
538
|
and rework. Record main plus every child's token usage and cost, retaining
|
|
572
539
|
model identities and including failed attempts, review, integration, and
|
|
573
540
|
retries. A child's successful exit or quick first patch is not final success.
|
|
574
541
|
5. Compare quality under matched total-cost budgets and matched wall-clock
|
|
575
|
-
limits as separate experiments. Include failed or unfinished runs. The
|
|
576
|
-
|
|
577
|
-
|
|
542
|
+
limits as separate experiments. Include failed or unfinished runs. The idle
|
|
543
|
+
timeout only detects a silent child; enforce experiment-wide budgets in your
|
|
544
|
+
evaluation process.
|
|
578
545
|
|
|
579
546
|
The [BOAD coding study](https://arxiv.org/html/2512.23631v2) found a useful small
|
|
580
547
|
expert set but declining results when adding more roles; its role-count result
|
|
@@ -583,31 +550,6 @@ does not prescribe a concurrency limit. A broader
|
|
|
583
550
|
also found that coordination outcomes depend on the task and single-agent
|
|
584
551
|
baseline. These motivate measuring your own workflow, not a universal team size.
|
|
585
552
|
|
|
586
|
-
## Custom agents
|
|
587
|
-
|
|
588
|
-
Built-ins ship with the package. Add or replace them with Markdown files:
|
|
589
|
-
|
|
590
|
-
- User agents: `~/.pi/agent/agents/`
|
|
591
|
-
- Project agents: the nearest `.pi/agents/` in a trusted project
|
|
592
|
-
- Precedence: project > user > built-in, where the same `name` wins
|
|
593
|
-
|
|
594
|
-
```yaml
|
|
595
|
-
---
|
|
596
|
-
name: scout
|
|
597
|
-
description: Fast read-only codebase reconnaissance
|
|
598
|
-
isolation: shared
|
|
599
|
-
tools: read, grep, find, ls
|
|
600
|
-
---
|
|
601
|
-
…additional system prompt…
|
|
602
|
-
```
|
|
603
|
-
|
|
604
|
-
`description` is the routing line the main model reads. `isolation` pins the
|
|
605
|
-
role's default boundary as described under [Parallel edits](#parallel-edits).
|
|
606
|
-
Models come only from `/subagents-setup`; an agent file cannot pin one. An
|
|
607
|
-
explicit `tools` list is intersected with the parent's active set; omitting it
|
|
608
|
-
inherits the active set. A role named `scout` is always reduced to the fixed
|
|
609
|
-
read-only tool set described above.
|
|
610
|
-
|
|
611
553
|
## Storage and cleanup
|
|
612
554
|
|
|
613
555
|
Everything lives under your pi agent directory, grouped per project. Nothing
|
|
@@ -622,6 +564,7 @@ that removes it, so this directory does not grow without bound:
|
|
|
622
564
|
| `ferris-pi-subagents/<project>/sessions/` | Child sessions for in-run fallback and manual recovery | When the owning session ends and no recovery record claims them |
|
|
623
565
|
| `ferris-pi-subagents/<project>/worktrees/` | Isolated checkouts for parallel writers | On integration, or when no thread/recovery record claims them |
|
|
624
566
|
| `ferris-pi-subagents/<project>/results/` | Full text of truncated results | After 7 days, or beyond 50 per project |
|
|
567
|
+
| `ferris-pi-subagents/<project>/pi-subagents-workflows.json` | Shape and node state of unfinished workflow graphs | When the graph settles, or after 30 days |
|
|
625
568
|
| `ferris-pi-subagents/<project>/tmp/` | Child prompt copies and the no-retry policy shim | When its owning process exits |
|
|
626
569
|
| `ferris-pi-subagents/<project>/` | All of the above for one checkout | After 3 idle days unless a thread/recovery record claims it |
|
|
627
570
|
|
|
@@ -642,14 +585,13 @@ npm run check
|
|
|
642
585
|
`npm run check` is `tsc --noEmit` plus the unit tests (`npm test`). There are
|
|
643
586
|
no bundled runtime dependencies; pi and TypeBox are peers. The source is
|
|
644
587
|
grouped by responsibility under `src/`: configuration, delegation, execution, isolation,
|
|
645
|
-
lifecycle, and presentation.
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
replacement RPC server is introduced.
|
|
588
|
+
lifecycle, and presentation.
|
|
589
|
+
|
|
590
|
+
`npm test` runs the TypeScript sources on Node's built-in type stripping from
|
|
591
|
+
Node 22.19 up, including Node 26, which removed `--experimental-transform-types`;
|
|
592
|
+
the source therefore avoids parameter properties and other transform-only
|
|
593
|
+
syntax. Pi and TypeBox are peers, and the extension imports only pi's public SDK
|
|
594
|
+
surface, so nothing is bundled.
|
|
653
595
|
|
|
654
596
|
## Changelog
|
|
655
597
|
|