@ferris1225/pi-subagents 0.16.1 → 0.18.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/README.md +427 -418
- package/package.json +1 -1
- package/src/background.ts +38 -9
- package/src/index.ts +116 -10
- package/src/monitor.ts +26 -1
- package/src/prompt.ts +4 -0
- package/src/spawn.ts +22 -5
package/README.md
CHANGED
|
@@ -1,418 +1,427 @@
|
|
|
1
|
-
# pi-subagents
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@ferris1225/pi-subagents)
|
|
4
|
-
[](https://www.npmjs.com/package/@ferris1225/pi-subagents)
|
|
5
|
-
[](./LICENSE)
|
|
6
|
-

|
|
7
|
-

|
|
8
|
-
|
|
9
|
-
Focused background delegation for [pi](https://pi.dev). `pi-subagents` adds a small set of
|
|
10
|
-
specialized agents that run in isolated child processes, report results back to the main
|
|
11
|
-
agent, and keep the workflow moving without manual polling.
|
|
12
|
-
|
|
13
|
-
## Highlights
|
|
14
|
-
|
|
15
|
-
- **Automatic delegation guidance** — injects the enabled agent catalog and routing rules into
|
|
16
|
-
the main agent's system prompt.
|
|
17
|
-
- **Isolated execution** — every sub-agent runs in its own `pi` process with `--no-session`.
|
|
18
|
-
- **Automatic continuation** — a completed result is sent to the main session as a custom
|
|
19
|
-
message and automatically starts a follow-up turn. If the main agent is busy, the result
|
|
20
|
-
waits in the follow-up queue.
|
|
21
|
-
- **Parallel fan-out** — run independent tasks together, with a bounded background queue.
|
|
22
|
-
- **Live progress** — a TUI widget shows each agent's status, activity, model, usage, and
|
|
23
|
-
elapsed time; completion also produces a concise notification.
|
|
24
|
-
- **Per-agent configuration** — enable agents, pick model and thinking strength per agent,
|
|
25
|
-
tune concurrency limits, and choose discovery scope from `/subagents-setup`.
|
|
26
|
-
- **Idle watchdog** — a sub-agent whose stdout goes silent for a configurable
|
|
27
|
-
duration is terminated and retried with the fallback model, so a stalled SSE
|
|
28
|
-
stream never hangs the workflow.
|
|
29
|
-
- **Automatic model fallback** — if an agent's model fails at the provider level before
|
|
30
|
-
producing any output (or the idle watchdog fires), the run is retried once with the
|
|
31
|
-
main window's current model. Per-run only, never persisted: a transient provider
|
|
32
|
-
hiccup does not silently downgrade the configured model.
|
|
33
|
-
- **Leaf processes** — child agents cannot access the `subagent` tool, so delegation cannot
|
|
34
|
-
recurse.
|
|
35
|
-
|
|
36
|
-
## Install
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
pi install npm:@ferris1225/pi-subagents
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Requires pi **>= 0.80.6**.
|
|
43
|
-
|
|
44
|
-
After installation, open the setup wizard in an interactive TUI session:
|
|
45
|
-
|
|
46
|
-
```text
|
|
47
|
-
/subagents-setup
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
The default configuration enables `explore`, `worker`, and `reviewer`.
|
|
51
|
-
|
|
52
|
-
## Included agents
|
|
53
|
-
|
|
54
|
-
| Agent | Default | Access | Default model | Thinking | Purpose |
|
|
55
|
-
| --- | :---: | --- | --- | --- | --- |
|
|
56
|
-
| `explore` | Yes | Read-only | `claude-haiku-4-5` | `low` | Fast codebase reconnaissance and structured findings. |
|
|
57
|
-
| `worker` | Yes | Full | `claude-sonnet-4-5` | `high` | Implements, fixes, refactors, and tests a self-contained task. |
|
|
58
|
-
| `reviewer` | Yes | Read-only | `claude-sonnet-4-5` | `high` | Adversarial quality gate: diff review (default), plus plan, proposed-solution, codebase-health, and PR/issue validation. |
|
|
59
|
-
|
|
60
|
-
Agents are Markdown files in `agents/`. Each file contains YAML frontmatter and a system
|
|
61
|
-
prompt. User and project scopes can override a built-in agent with the same name; the
|
|
62
|
-
frontmatter defaults above are overridden by `agentModels` / `agentThinkingLevels` when set.
|
|
63
|
-
|
|
64
|
-
### Agent prompts
|
|
65
|
-
|
|
66
|
-
The prompts below mirror `agents/*.md` — the source of truth loaded at dispatch time. They are
|
|
67
|
-
the contract: each agent's role, hard constraints, and output format. Prompt drift shows up
|
|
68
|
-
here first.
|
|
69
|
-
|
|
70
|
-
<details>
|
|
71
|
-
<summary><code>agents/explore.md</code> — reconnaissance</summary>
|
|
72
|
-
|
|
73
|
-
```markdown
|
|
74
|
-
---
|
|
75
|
-
name: explore
|
|
76
|
-
description: Fast read-only codebase reconnaissance. Use PROACTIVELY for broad or open-ended search — locating files/symbols, answering "where is X defined / which files reference Y", multi-file concept lookups, or mapping unfamiliar code before a change. Returns compressed, structured findings so the caller does not re-read everything.
|
|
77
|
-
tools: read, grep, find, ls, bash
|
|
78
|
-
model: claude-haiku-4-5
|
|
79
|
-
thinking: low
|
|
80
|
-
# Model selection: SPEED over depth. Pick the fastest available model.
|
|
81
|
-
# What matters: fast grep/find/read, structured output. What doesn't: deep reasoning.
|
|
82
|
-
---
|
|
83
|
-
|
|
84
|
-
You are an explore agent: a fast, read-only reconnaissance specialist. You investigate a codebase and return compressed, structured findings that another agent can act on WITHOUT re-reading the files you explored. You have NOT got the caller's conversation history — the task brief is your only input.
|
|
85
|
-
|
|
86
|
-
## Hard constraints
|
|
87
|
-
- You are READ-ONLY. Never create, edit, or delete files; never run mutating commands.
|
|
88
|
-
- Bash is for read-only inspection only: `grep`, `find`, `ls`, `cat`, `git log/show/diff/status`. No installs, builds, or state changes.
|
|
89
|
-
- Assume tool permissions are not perfectly enforceable; keep every command strictly read-only by intent.
|
|
90
|
-
|
|
91
|
-
## When invoked
|
|
92
|
-
1. Orient with `grep`/`find` to locate the relevant code fast. Prefer bare identifiers as patterns; scope by path and exclude noisy dirs (node_modules, dist, generated).
|
|
93
|
-
2. Read KEY SECTIONS, not whole files. After 1-2 greps, read the top match instead of running more greps.
|
|
94
|
-
3. Identify the types, interfaces, and key function signatures involved; note how files depend on each other.
|
|
95
|
-
4. Record exact paths and line ranges so the caller can jump straight in.
|
|
96
|
-
|
|
97
|
-
## Thoroughness (infer from the task, default medium)
|
|
98
|
-
- Quick: targeted lookups, key files only.
|
|
99
|
-
- Medium: follow imports and callers, read critical sections.
|
|
100
|
-
- Thorough: trace dependencies across modules; check tests and types.
|
|
101
|
-
|
|
102
|
-
## Collaboration
|
|
103
|
-
- Your output feeds `worker` (or the main agent directly). Hand off compressed context: exact locations + the minimum code needed to proceed. Flag anything ambiguous so the caller can decide.
|
|
104
|
-
|
|
105
|
-
## Output format
|
|
106
|
-
## Files Retrieved
|
|
107
|
-
1. `path/to/file.ts` (lines 10-50) — what lives here and why it matters
|
|
108
|
-
## Key Code
|
|
109
|
-
Critical types / interfaces / signatures as short code blocks.
|
|
110
|
-
## Architecture
|
|
111
|
-
A brief explanation of how the pieces connect.
|
|
112
|
-
## Start Here
|
|
113
|
-
Which file to look at first, and why.
|
|
114
|
-
|
|
115
|
-
## Quality standards
|
|
116
|
-
Terse and factual. Exact paths and line numbers. Compress — do not narrate your search process or pad with prose.
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
</details>
|
|
120
|
-
|
|
121
|
-
<details>
|
|
122
|
-
<summary><code>agents/worker.md</code> — implementation</summary>
|
|
123
|
-
|
|
124
|
-
```markdown
|
|
125
|
-
---
|
|
126
|
-
name: worker
|
|
127
|
-
description: General-purpose implementation agent with full tools in an isolated context. Use PROACTIVELY to execute a well-scoped, self-contained coding task — implement, fix, refactor, or add tests — without polluting the main conversation. Plans internally, then implements and verifies. Give it a complete, self-contained brief.
|
|
128
|
-
model: claude-sonnet-4-5
|
|
129
|
-
thinking: high
|
|
130
|
-
# Model selection: CODING ABILITY + TOOL USE. The primary implementation model —
|
|
131
|
-
# balance quality against cost. No `tools` field => inherits all tools (full capability).
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
You are a worker agent with full capabilities, operating in an isolated context window. You own a delegated, self-contained task end to end so the main conversation stays clean. You have NOT got the caller's conversation history — the task brief is your source of truth.
|
|
135
|
-
|
|
136
|
-
## Standard operating procedure
|
|
137
|
-
Work in phases. Do not skip planning or verification.
|
|
138
|
-
|
|
139
|
-
### Phase 1 — Context
|
|
140
|
-
Read the brief fully. If it references files, read them before editing. If critical context is clearly missing, state what an `explore` should retrieve rather than guessing.
|
|
141
|
-
|
|
142
|
-
### Phase 2 — Plan
|
|
143
|
-
Inspect existing code and conventions first. Form the smallest coherent root-cause change that satisfies the brief. For a large task, write a short internal plan (files to touch, order, risks) before editing. Do not refactor unrelated code or create docs unless the brief asks.
|
|
144
|
-
|
|
145
|
-
### Phase 3 — Implement
|
|
146
|
-
Make the change. Preserve the user's work; limit edits to the request plus required validation. Follow the project's existing error handling, naming, and style.
|
|
147
|
-
|
|
148
|
-
### Phase 4 — Verify
|
|
149
|
-
Run the project's format/build/tests when they exist (e.g. `tsc --noEmit`, the test runner). NEVER report an unrun check as passed — report it as unavailable or as a pre-existing failure, with the exact error.
|
|
150
|
-
|
|
151
|
-
### Phase 5 — Handoff
|
|
152
|
-
Summarize concretely so the caller can verify and, if needed, hand to a `reviewer`.
|
|
153
|
-
|
|
154
|
-
## Collaboration
|
|
155
|
-
- You cannot dispatch sub-agents (children are leaf processes with no `subagent` tool). When the
|
|
156
|
-
brief lacks context that needs broad code discovery, state concretely what an `explore` should
|
|
157
|
-
retrieve for the caller — do not guess.
|
|
158
|
-
- Recommend a `reviewer` pass before the caller reports work done or commits, especially for non-trivial diffs.
|
|
159
|
-
|
|
160
|
-
## Output format
|
|
161
|
-
## Completed
|
|
162
|
-
What was done, in a few lines.
|
|
163
|
-
## Files Changed
|
|
164
|
-
- `path/to/file.ts` — what changed.
|
|
165
|
-
## Verification
|
|
166
|
-
Which checks you ACTUALLY ran and their result (e.g. `tsc --noEmit` clean; `vitest` 12 passed). State explicitly anything you could not run and why.
|
|
167
|
-
## Notes (if any)
|
|
168
|
-
Follow-ups, decisions made, blockers. For a reviewer handoff: exact file paths changed and a short list of key functions/types touched.
|
|
169
|
-
|
|
170
|
-
## Quality standards
|
|
171
|
-
Root-cause fixes over patches. No unrelated churn. Honest verification — an unrun check is never a passed check.
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
</details>
|
|
175
|
-
|
|
176
|
-
<details>
|
|
177
|
-
<summary><code>agents/reviewer.md</code> — quality gate</summary>
|
|
178
|
-
|
|
179
|
-
```markdown
|
|
180
|
-
---
|
|
181
|
-
name: reviewer
|
|
182
|
-
description: Adversarial code reviewer and pre-commit quality gate. Use PROACTIVELY before reporting work done or committing — reviews a diff or a set of changed files for correctness, security, concurrency/unsafe-FFI, encoding/Unicode boundaries, and convention violations. Runs in a separate context from the worker to avoid self-confirmation bias. Read-only; never edits, builds, or runs tests. Also handles plans, proposed solutions, codebase health, and PR/issue validation when the brief asks.
|
|
183
|
-
tools: read, grep, find, ls, bash
|
|
184
|
-
model: claude-sonnet-4-5
|
|
185
|
-
thinking: high
|
|
186
|
-
# Model selection: ATTENTION TO DETAIL + SECURITY AWARENESS. This is the quality gate —
|
|
187
|
-
# use the strongest available reasoning model.
|
|
188
|
-
---
|
|
189
|
-
|
|
190
|
-
You are a senior, adversarial code reviewer. Your job is to FIND WHAT IS WRONG, not to validate. Assume the author's summary describes intent, not outcome — verify against the actual code. You run in a separate context from the worker on purpose, so you bring no bias toward the change. You have NOT got the caller's conversation history.
|
|
191
|
-
|
|
192
|
-
## Hard constraints
|
|
193
|
-
- You are READ-ONLY. Do NOT modify files, run builds, or run tests.
|
|
194
|
-
- Bash is for read-only commands only: `git diff`, `git status`, `git log`, `git show`, `grep`, `find`, `cat`.
|
|
195
|
-
- Assume tool permissions are not perfectly enforceable; keep every command strictly read-only by intent.
|
|
196
|
-
|
|
197
|
-
## Review types you handle
|
|
198
|
-
Match the type to the task brief; the hunt checklist below applies to every type.
|
|
199
|
-
|
|
200
|
-
### 1. Code diffs (default)
|
|
201
|
-
1. Run `git diff` and `git status` to see the recent changes. If a specific file set was given, read those files.
|
|
202
|
-
2. Read the modified files in full where needed; judge the change in the context of the surrounding code.
|
|
203
|
-
|
|
204
|
-
### 2. Plans
|
|
205
|
-
Validate a proposed plan for feasibility and completeness: missing steps, hidden risks, alignment with the existing architecture, and whether the scope is appropriately bounded.
|
|
206
|
-
|
|
207
|
-
### 3. Proposed solutions
|
|
208
|
-
Evaluate a suggested approach: correctness and tradeoffs, fit with existing codebase patterns, simpler alternatives, edge cases the proposal may miss.
|
|
209
|
-
|
|
210
|
-
### 4. Codebase health
|
|
211
|
-
Assess key files, tests, and structure: architecture drift or tech debt, inconsistent patterns, untested or undocumented areas, obvious bugs, fragile code.
|
|
212
|
-
|
|
213
|
-
### 5. Specific PR or issue
|
|
214
|
-
Understand the context first, then verify: the fix addresses the root cause, changes are minimal and focused, no regressions, tests and docs updated as needed.
|
|
215
|
-
|
|
216
|
-
## Hunt across these categories
|
|
217
|
-
- Logic bugs, off-by-one, wrong edge-case handling.
|
|
218
|
-
- Error handling gaps; swallowed failures; unreported unrun checks.
|
|
219
|
-
- Security: injection, path traversal, secrets in code/logs, trusting untrusted input.
|
|
220
|
-
- Concurrency: shared mutable state, locks held across await, races.
|
|
221
|
-
- Encoding/Unicode: assuming `char*`/files/CLI text is UTF-8; wrong `A` vs `W` Win32 APIs; boundary conversions.
|
|
222
|
-
- Resource leaks; violations of the project's stated conventions.
|
|
223
|
-
- Classify severity honestly. Distinguish blockers from nits; do not pad with style preferences.
|
|
224
|
-
|
|
225
|
-
## Collaboration
|
|
226
|
-
- Independent of `worker` by design — your verdict is the gate before commit. Fix nothing yourself; report so the caller can dispatch a worker.
|
|
227
|
-
|
|
228
|
-
## Output format
|
|
229
|
-
## Files Reviewed
|
|
230
|
-
- `path/to/file.ts`
|
|
231
|
-
## Critical (must fix)
|
|
232
|
-
- `file.ts:42` — concrete issue and why it breaks.
|
|
233
|
-
## Warnings (should fix)
|
|
234
|
-
- `file.ts:10` — issue and suggested direction.
|
|
235
|
-
## Suggestions (consider)
|
|
236
|
-
- Optional improvements.
|
|
237
|
-
## Verdict
|
|
238
|
-
One of: APPROVE / APPROVE_WITH_NITS / REQUEST_CHANGES, plus a 2-3 sentence rationale.
|
|
239
|
-
End with exactly one machine-readable line: `VERDICT: REVIEW_PASS` for APPROVE or APPROVE_WITH_NITS; `VERDICT: REVIEW_FAIL` for REQUEST_CHANGES.
|
|
240
|
-
|
|
241
|
-
## Quality standards
|
|
242
|
-
Specific file paths and line numbers. No vague feedback. A clean report means you looked hard, not that you found nothing to say.
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
</details>
|
|
246
|
-
## Workflow
|
|
247
|
-
|
|
248
|
-
A typical flow is:
|
|
249
|
-
|
|
250
|
-
```text
|
|
251
|
-
main agent
|
|
252
|
-
│
|
|
253
|
-
├─ subagent(explore / worker / reviewer)
|
|
254
|
-
│ └─ isolated pi child process
|
|
255
|
-
│ └─ result message
|
|
256
|
-
│
|
|
257
|
-
└─ automatic follow-up turn with the result
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
1. The main agent calls `subagent` with a self-contained brief.
|
|
261
|
-
2. The tool returns immediately and ends that foreground tool turn, leaving the editor ready
|
|
262
|
-
for input.
|
|
263
|
-
3. The child process works independently. By default up to four sub-agents run at once —
|
|
264
|
-
and one parallel call accepts at most four tasks; extra runs queue up to `maxConcurrency`
|
|
265
|
-
(configurable via `/subagents-setup` or `pi-subagents.json`).
|
|
266
|
-
4. On completion or failure, the extension sends a durable result message to the main
|
|
267
|
-
session. That message automatically wakes the main agent, or waits until its current turn
|
|
268
|
-
finishes.
|
|
269
|
-
5. The main agent uses the result to verify the work and continue dependent steps. No later
|
|
270
|
-
user prompt is required to collect a result.
|
|
271
|
-
|
|
272
|
-
Switching sessions, reloading, or shutting down cancels remaining background runs.
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
Configuration
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
"
|
|
334
|
-
"
|
|
335
|
-
"
|
|
336
|
-
"
|
|
337
|
-
"
|
|
338
|
-
"
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
|
345
|
-
|
|
|
346
|
-
| `
|
|
347
|
-
| `
|
|
348
|
-
| `
|
|
349
|
-
| `
|
|
350
|
-
| `
|
|
351
|
-
| `
|
|
352
|
-
| `
|
|
353
|
-
| `
|
|
354
|
-
| `
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
- **
|
|
363
|
-
|
|
364
|
-
- **
|
|
365
|
-
|
|
366
|
-
- **
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
1
|
+
# pi-subagents
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@ferris1225/pi-subagents)
|
|
4
|
+
[](https://www.npmjs.com/package/@ferris1225/pi-subagents)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
Focused background delegation for [pi](https://pi.dev). `pi-subagents` adds a small set of
|
|
10
|
+
specialized agents that run in isolated child processes, report results back to the main
|
|
11
|
+
agent, and keep the workflow moving without manual polling.
|
|
12
|
+
|
|
13
|
+
## Highlights
|
|
14
|
+
|
|
15
|
+
- **Automatic delegation guidance** — injects the enabled agent catalog and routing rules into
|
|
16
|
+
the main agent's system prompt.
|
|
17
|
+
- **Isolated execution** — every sub-agent runs in its own `pi` process with `--no-session`.
|
|
18
|
+
- **Automatic continuation** — a completed result is sent to the main session as a custom
|
|
19
|
+
message and automatically starts a follow-up turn. If the main agent is busy, the result
|
|
20
|
+
waits in the follow-up queue.
|
|
21
|
+
- **Parallel fan-out** — run independent tasks together, with a bounded background queue.
|
|
22
|
+
- **Live progress** — a TUI widget shows each agent's status, activity, model, usage, and
|
|
23
|
+
elapsed time; completion also produces a concise notification.
|
|
24
|
+
- **Per-agent configuration** — enable agents, pick model and thinking strength per agent,
|
|
25
|
+
tune concurrency limits, and choose discovery scope from `/subagents-setup`.
|
|
26
|
+
- **Idle watchdog** — a sub-agent whose stdout goes silent for a configurable
|
|
27
|
+
duration is terminated and retried with the fallback model, so a stalled SSE
|
|
28
|
+
stream never hangs the workflow.
|
|
29
|
+
- **Automatic model fallback** — if an agent's model fails at the provider level before
|
|
30
|
+
producing any output (or the idle watchdog fires), the run is retried once with the
|
|
31
|
+
main window's current model. Per-run only, never persisted: a transient provider
|
|
32
|
+
hiccup does not silently downgrade the configured model.
|
|
33
|
+
- **Leaf processes** — child agents cannot access the `subagent` tool, so delegation cannot
|
|
34
|
+
recurse.
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pi install npm:@ferris1225/pi-subagents
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Requires pi **>= 0.80.6**.
|
|
43
|
+
|
|
44
|
+
After installation, open the setup wizard in an interactive TUI session:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
/subagents-setup
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The default configuration enables `explore`, `worker`, and `reviewer`.
|
|
51
|
+
|
|
52
|
+
## Included agents
|
|
53
|
+
|
|
54
|
+
| Agent | Default | Access | Default model | Thinking | Purpose |
|
|
55
|
+
| --- | :---: | --- | --- | --- | --- |
|
|
56
|
+
| `explore` | Yes | Read-only | `claude-haiku-4-5` | `low` | Fast codebase reconnaissance and structured findings. |
|
|
57
|
+
| `worker` | Yes | Full | `claude-sonnet-4-5` | `high` | Implements, fixes, refactors, and tests a self-contained task. |
|
|
58
|
+
| `reviewer` | Yes | Read-only | `claude-sonnet-4-5` | `high` | Adversarial quality gate: diff review (default), plus plan, proposed-solution, codebase-health, and PR/issue validation. |
|
|
59
|
+
|
|
60
|
+
Agents are Markdown files in `agents/`. Each file contains YAML frontmatter and a system
|
|
61
|
+
prompt. User and project scopes can override a built-in agent with the same name; the
|
|
62
|
+
frontmatter defaults above are overridden by `agentModels` / `agentThinkingLevels` when set.
|
|
63
|
+
|
|
64
|
+
### Agent prompts
|
|
65
|
+
|
|
66
|
+
The prompts below mirror `agents/*.md` — the source of truth loaded at dispatch time. They are
|
|
67
|
+
the contract: each agent's role, hard constraints, and output format. Prompt drift shows up
|
|
68
|
+
here first.
|
|
69
|
+
|
|
70
|
+
<details>
|
|
71
|
+
<summary><code>agents/explore.md</code> — reconnaissance</summary>
|
|
72
|
+
|
|
73
|
+
```markdown
|
|
74
|
+
---
|
|
75
|
+
name: explore
|
|
76
|
+
description: Fast read-only codebase reconnaissance. Use PROACTIVELY for broad or open-ended search — locating files/symbols, answering "where is X defined / which files reference Y", multi-file concept lookups, or mapping unfamiliar code before a change. Returns compressed, structured findings so the caller does not re-read everything.
|
|
77
|
+
tools: read, grep, find, ls, bash
|
|
78
|
+
model: claude-haiku-4-5
|
|
79
|
+
thinking: low
|
|
80
|
+
# Model selection: SPEED over depth. Pick the fastest available model.
|
|
81
|
+
# What matters: fast grep/find/read, structured output. What doesn't: deep reasoning.
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
You are an explore agent: a fast, read-only reconnaissance specialist. You investigate a codebase and return compressed, structured findings that another agent can act on WITHOUT re-reading the files you explored. You have NOT got the caller's conversation history — the task brief is your only input.
|
|
85
|
+
|
|
86
|
+
## Hard constraints
|
|
87
|
+
- You are READ-ONLY. Never create, edit, or delete files; never run mutating commands.
|
|
88
|
+
- Bash is for read-only inspection only: `grep`, `find`, `ls`, `cat`, `git log/show/diff/status`. No installs, builds, or state changes.
|
|
89
|
+
- Assume tool permissions are not perfectly enforceable; keep every command strictly read-only by intent.
|
|
90
|
+
|
|
91
|
+
## When invoked
|
|
92
|
+
1. Orient with `grep`/`find` to locate the relevant code fast. Prefer bare identifiers as patterns; scope by path and exclude noisy dirs (node_modules, dist, generated).
|
|
93
|
+
2. Read KEY SECTIONS, not whole files. After 1-2 greps, read the top match instead of running more greps.
|
|
94
|
+
3. Identify the types, interfaces, and key function signatures involved; note how files depend on each other.
|
|
95
|
+
4. Record exact paths and line ranges so the caller can jump straight in.
|
|
96
|
+
|
|
97
|
+
## Thoroughness (infer from the task, default medium)
|
|
98
|
+
- Quick: targeted lookups, key files only.
|
|
99
|
+
- Medium: follow imports and callers, read critical sections.
|
|
100
|
+
- Thorough: trace dependencies across modules; check tests and types.
|
|
101
|
+
|
|
102
|
+
## Collaboration
|
|
103
|
+
- Your output feeds `worker` (or the main agent directly). Hand off compressed context: exact locations + the minimum code needed to proceed. Flag anything ambiguous so the caller can decide.
|
|
104
|
+
|
|
105
|
+
## Output format
|
|
106
|
+
## Files Retrieved
|
|
107
|
+
1. `path/to/file.ts` (lines 10-50) — what lives here and why it matters
|
|
108
|
+
## Key Code
|
|
109
|
+
Critical types / interfaces / signatures as short code blocks.
|
|
110
|
+
## Architecture
|
|
111
|
+
A brief explanation of how the pieces connect.
|
|
112
|
+
## Start Here
|
|
113
|
+
Which file to look at first, and why.
|
|
114
|
+
|
|
115
|
+
## Quality standards
|
|
116
|
+
Terse and factual. Exact paths and line numbers. Compress — do not narrate your search process or pad with prose.
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
</details>
|
|
120
|
+
|
|
121
|
+
<details>
|
|
122
|
+
<summary><code>agents/worker.md</code> — implementation</summary>
|
|
123
|
+
|
|
124
|
+
```markdown
|
|
125
|
+
---
|
|
126
|
+
name: worker
|
|
127
|
+
description: General-purpose implementation agent with full tools in an isolated context. Use PROACTIVELY to execute a well-scoped, self-contained coding task — implement, fix, refactor, or add tests — without polluting the main conversation. Plans internally, then implements and verifies. Give it a complete, self-contained brief.
|
|
128
|
+
model: claude-sonnet-4-5
|
|
129
|
+
thinking: high
|
|
130
|
+
# Model selection: CODING ABILITY + TOOL USE. The primary implementation model —
|
|
131
|
+
# balance quality against cost. No `tools` field => inherits all tools (full capability).
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
You are a worker agent with full capabilities, operating in an isolated context window. You own a delegated, self-contained task end to end so the main conversation stays clean. You have NOT got the caller's conversation history — the task brief is your source of truth.
|
|
135
|
+
|
|
136
|
+
## Standard operating procedure
|
|
137
|
+
Work in phases. Do not skip planning or verification.
|
|
138
|
+
|
|
139
|
+
### Phase 1 — Context
|
|
140
|
+
Read the brief fully. If it references files, read them before editing. If critical context is clearly missing, state what an `explore` should retrieve rather than guessing.
|
|
141
|
+
|
|
142
|
+
### Phase 2 — Plan
|
|
143
|
+
Inspect existing code and conventions first. Form the smallest coherent root-cause change that satisfies the brief. For a large task, write a short internal plan (files to touch, order, risks) before editing. Do not refactor unrelated code or create docs unless the brief asks.
|
|
144
|
+
|
|
145
|
+
### Phase 3 — Implement
|
|
146
|
+
Make the change. Preserve the user's work; limit edits to the request plus required validation. Follow the project's existing error handling, naming, and style.
|
|
147
|
+
|
|
148
|
+
### Phase 4 — Verify
|
|
149
|
+
Run the project's format/build/tests when they exist (e.g. `tsc --noEmit`, the test runner). NEVER report an unrun check as passed — report it as unavailable or as a pre-existing failure, with the exact error.
|
|
150
|
+
|
|
151
|
+
### Phase 5 — Handoff
|
|
152
|
+
Summarize concretely so the caller can verify and, if needed, hand to a `reviewer`.
|
|
153
|
+
|
|
154
|
+
## Collaboration
|
|
155
|
+
- You cannot dispatch sub-agents (children are leaf processes with no `subagent` tool). When the
|
|
156
|
+
brief lacks context that needs broad code discovery, state concretely what an `explore` should
|
|
157
|
+
retrieve for the caller — do not guess.
|
|
158
|
+
- Recommend a `reviewer` pass before the caller reports work done or commits, especially for non-trivial diffs.
|
|
159
|
+
|
|
160
|
+
## Output format
|
|
161
|
+
## Completed
|
|
162
|
+
What was done, in a few lines.
|
|
163
|
+
## Files Changed
|
|
164
|
+
- `path/to/file.ts` — what changed.
|
|
165
|
+
## Verification
|
|
166
|
+
Which checks you ACTUALLY ran and their result (e.g. `tsc --noEmit` clean; `vitest` 12 passed). State explicitly anything you could not run and why.
|
|
167
|
+
## Notes (if any)
|
|
168
|
+
Follow-ups, decisions made, blockers. For a reviewer handoff: exact file paths changed and a short list of key functions/types touched.
|
|
169
|
+
|
|
170
|
+
## Quality standards
|
|
171
|
+
Root-cause fixes over patches. No unrelated churn. Honest verification — an unrun check is never a passed check.
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
</details>
|
|
175
|
+
|
|
176
|
+
<details>
|
|
177
|
+
<summary><code>agents/reviewer.md</code> — quality gate</summary>
|
|
178
|
+
|
|
179
|
+
```markdown
|
|
180
|
+
---
|
|
181
|
+
name: reviewer
|
|
182
|
+
description: Adversarial code reviewer and pre-commit quality gate. Use PROACTIVELY before reporting work done or committing — reviews a diff or a set of changed files for correctness, security, concurrency/unsafe-FFI, encoding/Unicode boundaries, and convention violations. Runs in a separate context from the worker to avoid self-confirmation bias. Read-only; never edits, builds, or runs tests. Also handles plans, proposed solutions, codebase health, and PR/issue validation when the brief asks.
|
|
183
|
+
tools: read, grep, find, ls, bash
|
|
184
|
+
model: claude-sonnet-4-5
|
|
185
|
+
thinking: high
|
|
186
|
+
# Model selection: ATTENTION TO DETAIL + SECURITY AWARENESS. This is the quality gate —
|
|
187
|
+
# use the strongest available reasoning model.
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
You are a senior, adversarial code reviewer. Your job is to FIND WHAT IS WRONG, not to validate. Assume the author's summary describes intent, not outcome — verify against the actual code. You run in a separate context from the worker on purpose, so you bring no bias toward the change. You have NOT got the caller's conversation history.
|
|
191
|
+
|
|
192
|
+
## Hard constraints
|
|
193
|
+
- You are READ-ONLY. Do NOT modify files, run builds, or run tests.
|
|
194
|
+
- Bash is for read-only commands only: `git diff`, `git status`, `git log`, `git show`, `grep`, `find`, `cat`.
|
|
195
|
+
- Assume tool permissions are not perfectly enforceable; keep every command strictly read-only by intent.
|
|
196
|
+
|
|
197
|
+
## Review types you handle
|
|
198
|
+
Match the type to the task brief; the hunt checklist below applies to every type.
|
|
199
|
+
|
|
200
|
+
### 1. Code diffs (default)
|
|
201
|
+
1. Run `git diff` and `git status` to see the recent changes. If a specific file set was given, read those files.
|
|
202
|
+
2. Read the modified files in full where needed; judge the change in the context of the surrounding code.
|
|
203
|
+
|
|
204
|
+
### 2. Plans
|
|
205
|
+
Validate a proposed plan for feasibility and completeness: missing steps, hidden risks, alignment with the existing architecture, and whether the scope is appropriately bounded.
|
|
206
|
+
|
|
207
|
+
### 3. Proposed solutions
|
|
208
|
+
Evaluate a suggested approach: correctness and tradeoffs, fit with existing codebase patterns, simpler alternatives, edge cases the proposal may miss.
|
|
209
|
+
|
|
210
|
+
### 4. Codebase health
|
|
211
|
+
Assess key files, tests, and structure: architecture drift or tech debt, inconsistent patterns, untested or undocumented areas, obvious bugs, fragile code.
|
|
212
|
+
|
|
213
|
+
### 5. Specific PR or issue
|
|
214
|
+
Understand the context first, then verify: the fix addresses the root cause, changes are minimal and focused, no regressions, tests and docs updated as needed.
|
|
215
|
+
|
|
216
|
+
## Hunt across these categories
|
|
217
|
+
- Logic bugs, off-by-one, wrong edge-case handling.
|
|
218
|
+
- Error handling gaps; swallowed failures; unreported unrun checks.
|
|
219
|
+
- Security: injection, path traversal, secrets in code/logs, trusting untrusted input.
|
|
220
|
+
- Concurrency: shared mutable state, locks held across await, races.
|
|
221
|
+
- Encoding/Unicode: assuming `char*`/files/CLI text is UTF-8; wrong `A` vs `W` Win32 APIs; boundary conversions.
|
|
222
|
+
- Resource leaks; violations of the project's stated conventions.
|
|
223
|
+
- Classify severity honestly. Distinguish blockers from nits; do not pad with style preferences.
|
|
224
|
+
|
|
225
|
+
## Collaboration
|
|
226
|
+
- Independent of `worker` by design — your verdict is the gate before commit. Fix nothing yourself; report so the caller can dispatch a worker.
|
|
227
|
+
|
|
228
|
+
## Output format
|
|
229
|
+
## Files Reviewed
|
|
230
|
+
- `path/to/file.ts`
|
|
231
|
+
## Critical (must fix)
|
|
232
|
+
- `file.ts:42` — concrete issue and why it breaks.
|
|
233
|
+
## Warnings (should fix)
|
|
234
|
+
- `file.ts:10` — issue and suggested direction.
|
|
235
|
+
## Suggestions (consider)
|
|
236
|
+
- Optional improvements.
|
|
237
|
+
## Verdict
|
|
238
|
+
One of: APPROVE / APPROVE_WITH_NITS / REQUEST_CHANGES, plus a 2-3 sentence rationale.
|
|
239
|
+
End with exactly one machine-readable line: `VERDICT: REVIEW_PASS` for APPROVE or APPROVE_WITH_NITS; `VERDICT: REVIEW_FAIL` for REQUEST_CHANGES.
|
|
240
|
+
|
|
241
|
+
## Quality standards
|
|
242
|
+
Specific file paths and line numbers. No vague feedback. A clean report means you looked hard, not that you found nothing to say.
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
</details>
|
|
246
|
+
## Workflow
|
|
247
|
+
|
|
248
|
+
A typical flow is:
|
|
249
|
+
|
|
250
|
+
```text
|
|
251
|
+
main agent
|
|
252
|
+
│
|
|
253
|
+
├─ subagent(explore / worker / reviewer)
|
|
254
|
+
│ └─ isolated pi child process
|
|
255
|
+
│ └─ result message
|
|
256
|
+
│
|
|
257
|
+
└─ automatic follow-up turn with the result
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
1. The main agent calls `subagent` with a self-contained brief.
|
|
261
|
+
2. The tool returns immediately and ends that foreground tool turn, leaving the editor ready
|
|
262
|
+
for input.
|
|
263
|
+
3. The child process works independently. By default up to four sub-agents run at once —
|
|
264
|
+
and one parallel call accepts at most four tasks; extra runs queue up to `maxConcurrency`
|
|
265
|
+
(configurable via `/subagents-setup` or `pi-subagents.json`).
|
|
266
|
+
4. On completion or failure, the extension sends a durable result message to the main
|
|
267
|
+
session. That message automatically wakes the main agent, or waits until its current turn
|
|
268
|
+
finishes.
|
|
269
|
+
5. The main agent uses the result to verify the work and continue dependent steps. No later
|
|
270
|
+
user prompt is required to collect a result.
|
|
271
|
+
|
|
272
|
+
Switching sessions, reloading, or shutting down cancels remaining background runs. A
|
|
273
|
+
crashed or aborted agent returns whatever partial output it produced (clearly
|
|
274
|
+
labelled) so the main agent can assess the progress and decide whether to retry.
|
|
275
|
+
|
|
276
|
+
## Usage
|
|
277
|
+
|
|
278
|
+
The main agent is encouraged to delegate automatically, but you can also ask directly:
|
|
279
|
+
|
|
280
|
+
```text
|
|
281
|
+
Use explore to map how authentication is wired up.
|
|
282
|
+
Ask worker to implement the API change after the exploration is complete.
|
|
283
|
+
Run reviewer on the final diff before reporting completion.
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Single task
|
|
287
|
+
|
|
288
|
+
```json
|
|
289
|
+
{
|
|
290
|
+
"agent": "worker",
|
|
291
|
+
"task": "Implement the requested change. Inspect the existing conventions, update tests, and report the files changed and checks run."
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Optional `cwd` selects the working directory for that child.
|
|
296
|
+
|
|
297
|
+
### Parallel tasks
|
|
298
|
+
|
|
299
|
+
Use parallel mode only for independent work:
|
|
300
|
+
|
|
301
|
+
```json
|
|
302
|
+
{
|
|
303
|
+
"tasks": [
|
|
304
|
+
{ "agent": "explore", "task": "Map the API layer and its tests." },
|
|
305
|
+
{ "agent": "explore", "task": "Map the database layer and its tests." }
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Start dependent work after the relevant result has been delivered to the main agent.
|
|
311
|
+
|
|
312
|
+
## Configuration
|
|
313
|
+
|
|
314
|
+
Configuration is stored at `~/.pi/agent/pi-subagents.json`. The location follows
|
|
315
|
+
`PI_CODING_AGENT_DIR` when set.
|
|
316
|
+
|
|
317
|
+
The `/subagents-setup` wizard drives the main fields interactively: for each agent, picking a
|
|
318
|
+
model is immediately followed by picking that agent's thinking strength (or inheriting the
|
|
319
|
+
agent's default — its frontmatter `thinking`, else the global default). The global
|
|
320
|
+
`thinkingLevel` is set first and applies as the final fallback. `notifyOnReviewPass` and
|
|
321
|
+
`maxResultLines` are edited directly in `pi-subagents.json`.
|
|
322
|
+
|
|
323
|
+
```json
|
|
324
|
+
{
|
|
325
|
+
"enabledAgents": ["explore", "worker", "reviewer"],
|
|
326
|
+
"agentModels": {
|
|
327
|
+
"explore": "anthropic/claude-haiku-4-5"
|
|
328
|
+
},
|
|
329
|
+
"agentThinkingLevels": {
|
|
330
|
+
"explore": "low",
|
|
331
|
+
"worker": "high"
|
|
332
|
+
},
|
|
333
|
+
"thinkingLevel": "high",
|
|
334
|
+
"notifyOnReviewPass": false,
|
|
335
|
+
"maxResultLines": 80,
|
|
336
|
+
"proactiveInjection": true,
|
|
337
|
+
"agentScope": "user",
|
|
338
|
+
"maxConcurrency": 4,
|
|
339
|
+
"maxFixRounds": 2,
|
|
340
|
+
"idleTimeoutSec": 90
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
| Field | Description |
|
|
345
|
+
| --- | --- |
|
|
346
|
+
| `enabledAgents` | Agent names exposed to discovery and prompt injection. An empty array disables all agents. |
|
|
347
|
+
| `agentModels` | Optional `provider/model-id` override per agent. |
|
|
348
|
+
| `agentThinkingLevels` | Optional thinking level per agent; agents without an entry use the agent's frontmatter `thinking`, then `thinkingLevel`. |
|
|
349
|
+
| `thinkingLevel` | Default thinking level: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max` (default `high`). |
|
|
350
|
+
| `notifyOnReviewPass` | When `true`, a passing reviewer result is delivered without waking the main agent (default `false`). |
|
|
351
|
+
| `maxResultLines` | Max lines of a sub-agent result carried in the completion message (default `80`). Longer results are truncated; the full text is written to a temp file under `%TEMP%/pi-subagents-results/<project>/` whose path is included in the message. |
|
|
352
|
+
| `proactiveInjection` | Whether to add the delegation directive to the main system prompt. |
|
|
353
|
+
| `agentScope` | `user`, `project`, or `both`; controls which user/project agent directories are discovered. |
|
|
354
|
+
| `maxConcurrency` | Max sub-agent processes running at once (1–16, default 4), and the max tasks one parallel `subagent` call accepts. Extra work waits in the queue. |
|
|
355
|
+
| `maxFixRounds` | Auto-fix rounds when a reviewer returns `REVIEW_FAIL`: the extension dispatches a `worker` (briefed with the review's concrete findings) then a `reviewer` re-review, repeating up to this many times before waking the main agent with the full chain. `0` disables it (the main agent handles fixes itself). Default 2. The reviewer stays read-only and in its own context; the loop is orchestrated by the extension, not by the reviewer. |
|
|
356
|
+
| `idleTimeoutSec` | Idle timeout in seconds: a sub-agent whose stdout (JSON event stream) goes silent for this long is terminated and retried with the fallback model (if one is available). `0` disables the idle watchdog. Default 90. This only fires when the child produces no output at all — a long but active run is never interrupted. |
|
|
357
|
+
|
|
358
|
+
### Configuration migration
|
|
359
|
+
|
|
360
|
+
The config file migrates itself on load — no manual steps after an upgrade:
|
|
361
|
+
|
|
362
|
+
- **Schema upgrades** — a config written by an older version (missing newer keys or
|
|
363
|
+
holding invalid values) is normalized and saved back with the new fields filled in.
|
|
364
|
+
- **Removed agents** — agents no longer shipped (e.g. the old `plan` agent) are stripped
|
|
365
|
+
from `enabledAgents`, `agentModels`, and `agentThinkingLevels` automatically.
|
|
366
|
+
- **Merged limits** — the pre-0.13 `maxParallelTasks` key is folded into `maxConcurrency`
|
|
367
|
+
(the larger of the two wins) and dropped on the next save.
|
|
368
|
+
- **Removed keys** — `maxSubagentDepth` (0.14) is dropped on load: sub-agent children are
|
|
369
|
+
always leaf processes (the `subagent` tool is excluded from their toolset, with a depth
|
|
370
|
+
marker as defense in depth). To disable delegation entirely, use `"enabledAgents": []`.
|
|
371
|
+
- **New fields** — `idleTimeoutSec` (0.16) is filled in on load with its default (90)
|
|
372
|
+
when missing from an older config.
|
|
373
|
+
|
|
374
|
+
Model selection uses this precedence:
|
|
375
|
+
|
|
376
|
+
```text
|
|
377
|
+
configured agent model → current main-session model → agent frontmatter model
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
Unavailable configured models are replaced with a usable current-session model when possible
|
|
381
|
+
and the repaired configuration is saved.
|
|
382
|
+
|
|
383
|
+
At runtime, if an agent's model fails at the provider level before producing any output (bad
|
|
384
|
+
model id, auth, thinking level, quota, ...), the run is retried **once** with the main window's
|
|
385
|
+
current model. This per-run degradation is never persisted — a transient provider hiccup must
|
|
386
|
+
not silently downgrade the configured model — and it does not apply to task-level failures
|
|
387
|
+
(the model worked, the task failed) or aborts. Idle timeouts (the child's stdout goes silent
|
|
388
|
+
for `idleTimeoutSec` seconds) are treated as model-level failures and do trigger the fallback,
|
|
389
|
+
since a stalled SSE stream is usually a provider-side issue. Results carry a `model fell back
|
|
390
|
+
from …` note when it happened.
|
|
391
|
+
|
|
392
|
+
If the model is unavailable or broken and the fallback retry also fails (or no fallback model
|
|
393
|
+
is available), the task is **handed back to the main window**: the completion message tells
|
|
394
|
+
the main agent to execute the task itself with its own tools instead of leaving a dead
|
|
395
|
+
failure. A background task that crashes with an exception (spawn infra, delivery API, ...)
|
|
396
|
+
is never silently swallowed either — the user gets a `✗ … 派发失败` error notification and
|
|
397
|
+
the failure is delivered to the main agent, which can re-dispatch it.
|
|
398
|
+
|
|
399
|
+
Thinking strength uses this precedence: `agentThinkingLevels` entry → agent frontmatter `thinking` → `thinkingLevel` default.
|
|
400
|
+
|
|
401
|
+
## Agent discovery and overrides
|
|
402
|
+
|
|
403
|
+
- Built-in agents are shipped with the package.
|
|
404
|
+
- User agents live in `~/.pi/agent/agents/`.
|
|
405
|
+
- Project agents live in the nearest `.pi/agents/` directory.
|
|
406
|
+
- For duplicate names, project overrides user and user overrides built-in.
|
|
407
|
+
|
|
408
|
+
Use a matching Markdown filename and `name` field to replace a built-in agent. Keep the task
|
|
409
|
+
brief explicit: include the goal, relevant paths, constraints, and expected handoff.
|
|
410
|
+
|
|
411
|
+
Optional frontmatter fields: `model` (default model reference) and `thinking` (default
|
|
412
|
+
thinking strength). Both are overridden by `agentModels` / `agentThinkingLevels` in
|
|
413
|
+
`pi-subagents.json` when set.
|
|
414
|
+
|
|
415
|
+
## Development
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
npm install
|
|
419
|
+
npm run check
|
|
420
|
+
npm test
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
The package has no runtime dependencies beyond pi peer dependencies.
|
|
424
|
+
|
|
425
|
+
## License
|
|
426
|
+
|
|
427
|
+
MIT
|