@leing2021/super-pi 0.22.0 → 0.23.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 +38 -209
- package/extensions/ce-core/index.ts +190 -7
- package/extensions/ce-core/tools/parallel-subagent.ts +3 -3
- package/extensions/ce-core/tools/subagent.ts +2 -2
- package/package.json +4 -18
- package/rules/common/naming.md +154 -0
- package/skills/02-plan/SKILL.md +3 -2
- package/skills/03-work/SKILL.md +9 -6
- package/skills/04-review/SKILL.md +3 -2
- package/skills/06-next/SKILL.md +38 -10
- package/skills/06-next/references/recommendation-logic.md +2 -2
- package/skills/07-worktree/SKILL.md +9 -8
- package/skills/{09-help → 08-help}/SKILL.md +3 -3
- package/skills/{09-help → 08-help}/references/workflow-sequence.md +2 -1
- package/skills/references/language-detection.md +44 -0
- package/extensions/subagent/agent-management.ts +0 -595
- package/extensions/subagent/agent-manager-chain-detail.ts +0 -162
- package/extensions/subagent/agent-manager-detail.ts +0 -231
- package/extensions/subagent/agent-manager-edit.ts +0 -390
- package/extensions/subagent/agent-manager-list.ts +0 -278
- package/extensions/subagent/agent-manager-parallel.ts +0 -304
- package/extensions/subagent/agent-manager.ts +0 -705
- package/extensions/subagent/agent-scope.ts +0 -8
- package/extensions/subagent/agent-selection.ts +0 -25
- package/extensions/subagent/agent-serializer.ts +0 -123
- package/extensions/subagent/agent-templates.ts +0 -62
- package/extensions/subagent/agents/context-builder.md +0 -37
- package/extensions/subagent/agents/delegate.md +0 -9
- package/extensions/subagent/agents/oracle.md +0 -73
- package/extensions/subagent/agents/planner.md +0 -52
- package/extensions/subagent/agents/researcher.md +0 -50
- package/extensions/subagent/agents/reviewer.md +0 -38
- package/extensions/subagent/agents/scout.md +0 -48
- package/extensions/subagent/agents/worker.md +0 -52
- package/extensions/subagent/agents.ts +0 -761
- package/extensions/subagent/artifacts.ts +0 -100
- package/extensions/subagent/async-execution.ts +0 -520
- package/extensions/subagent/async-job-tracker.ts +0 -216
- package/extensions/subagent/async-status.ts +0 -241
- package/extensions/subagent/chain-clarify.ts +0 -1364
- package/extensions/subagent/chain-execution.ts +0 -853
- package/extensions/subagent/chain-serializer.ts +0 -126
- package/extensions/subagent/completion-dedupe.ts +0 -65
- package/extensions/subagent/doctor.ts +0 -200
- package/extensions/subagent/execution.ts +0 -738
- package/extensions/subagent/file-coalescer.ts +0 -42
- package/extensions/subagent/fork-context.ts +0 -63
- package/extensions/subagent/formatters.ts +0 -122
- package/extensions/subagent/frontmatter.ts +0 -31
- package/extensions/subagent/index.ts +0 -585
- package/extensions/subagent/intercom-bridge.ts +0 -240
- package/extensions/subagent/jsonl-writer.ts +0 -83
- package/extensions/subagent/model-fallback.ts +0 -108
- package/extensions/subagent/notify.ts +0 -110
- package/extensions/subagent/parallel-utils.ts +0 -108
- package/extensions/subagent/pi-args.ts +0 -138
- package/extensions/subagent/pi-spawn.ts +0 -100
- package/extensions/subagent/post-exit-stdio-guard.ts +0 -87
- package/extensions/subagent/prompt-template-bridge.ts +0 -399
- package/extensions/subagent/prompts/gather-context-and-clarify.md +0 -13
- package/extensions/subagent/prompts/parallel-cleanup.md +0 -42
- package/extensions/subagent/prompts/parallel-research.md +0 -50
- package/extensions/subagent/prompts/parallel-review.md +0 -40
- package/extensions/subagent/render-helpers.ts +0 -82
- package/extensions/subagent/render.ts +0 -836
- package/extensions/subagent/result-intercom.ts +0 -237
- package/extensions/subagent/result-watcher.ts +0 -171
- package/extensions/subagent/run-history.ts +0 -57
- package/extensions/subagent/run-status.ts +0 -136
- package/extensions/subagent/schemas.ts +0 -164
- package/extensions/subagent/session-tokens.ts +0 -50
- package/extensions/subagent/settings.ts +0 -367
- package/extensions/subagent/single-output.ts +0 -97
- package/extensions/subagent/skills.ts +0 -626
- package/extensions/subagent/slash-bridge.ts +0 -176
- package/extensions/subagent/slash-commands.ts +0 -303
- package/extensions/subagent/slash-live-state.ts +0 -294
- package/extensions/subagent/subagent-control.ts +0 -150
- package/extensions/subagent/subagent-executor.ts +0 -1899
- package/extensions/subagent/subagent-prompt-runtime.ts +0 -75
- package/extensions/subagent/subagent-runner.ts +0 -1470
- package/extensions/subagent/subagents-status.ts +0 -472
- package/extensions/subagent/text-editor.ts +0 -272
- package/extensions/subagent/top-level-async.ts +0 -15
- package/extensions/subagent/types.ts +0 -623
- package/extensions/subagent/utils.ts +0 -456
- package/extensions/subagent/worktree.ts +0 -579
- package/extensions/super-pi-extension/agents/ce-oracle.md +0 -109
- package/extensions/super-pi-extension/agents/ce-planner.md +0 -116
- package/extensions/super-pi-extension/agents/ce-reviewer.md +0 -99
- package/extensions/super-pi-extension/agents/ce-scout.md +0 -80
- package/extensions/super-pi-extension/agents/ce-worker.md +0 -78
- package/extensions/super-pi-extension/chains/ce-parallel-review.chain.md +0 -34
- package/extensions/super-pi-extension/chains/ce-review-only.chain.md +0 -12
- package/extensions/super-pi-extension/chains/ce-standard.chain.md +0 -28
- package/extensions/super-pi-extension/index.ts +0 -129
- package/extensions/super-pi-extension/model-sync.ts +0 -204
- package/skills/08-status/SKILL.md +0 -41
- package/skills/08-status/references/artifact-locations.md +0 -10
- package/skills/10-rules/SKILL.md +0 -76
- package/skills/pi-subagents/SKILL.md +0 -566
|
@@ -1,566 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pi-subagents
|
|
3
|
-
description: |
|
|
4
|
-
Delegate work to builtin or custom subagents with single-agent, chain,
|
|
5
|
-
parallel, async, forked-context, and intercom-coordinated workflows. Use
|
|
6
|
-
for advisory review, implementation handoffs, and multi-step tasks where a
|
|
7
|
-
single agent should stay in control while other agents contribute context,
|
|
8
|
-
planning, or execution.
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# Pi Subagents
|
|
12
|
-
|
|
13
|
-
Use this skill when you need to launch a specialized subagent, compose multiple
|
|
14
|
-
agents into a workflow, or create/edit agents and chains on demand.
|
|
15
|
-
|
|
16
|
-
## When to Use
|
|
17
|
-
|
|
18
|
-
- **Advisory review**: use fresh-context `reviewer` agents for adversarial code review, or fork to `oracle` when inherited decisions and drift matter
|
|
19
|
-
- **Implementation handoff**: have `oracle` advise, then `worker` implement only after an approved direction
|
|
20
|
-
- **Recon and planning**: use `scout` or `context-builder`, then `planner`
|
|
21
|
-
- **Parallel exploration**: run multiple non-conflicting tasks concurrently
|
|
22
|
-
- **Long-running work**: launch async/background runs and inspect them later
|
|
23
|
-
- **Subagent control**: watch needs-attention signals and soft-interrupt only when a delegated run is genuinely blocked
|
|
24
|
-
- **Agent authoring**: create, update, or override agents and chains for a project
|
|
25
|
-
|
|
26
|
-
## Tool vs Slash Commands
|
|
27
|
-
|
|
28
|
-
Agents can use the `subagent(...)` tool directly for execution, management, status, and control.
|
|
29
|
-
Humans often use the slash-command layer instead:
|
|
30
|
-
|
|
31
|
-
- `/run` — launch a single agent
|
|
32
|
-
- `/chain` — launch a chain of steps
|
|
33
|
-
- `/parallel` — launch top-level parallel tasks
|
|
34
|
-
- `/agents` — open the agents manager TUI
|
|
35
|
-
- `/run-chain` — launch a saved `.chain.md` workflow
|
|
36
|
-
- `/subagents-status` — inspect active/recent async runs
|
|
37
|
-
- `/subagents-doctor` — diagnose setup, discovery, async paths, and intercom bridge state
|
|
38
|
-
|
|
39
|
-
Prefer the tool when you are writing agent logic. Prefer the slash commands when
|
|
40
|
-
you are guiding a human through an interactive flow.
|
|
41
|
-
|
|
42
|
-
Packaged prompt shortcuts are also available for repeatable workflows:
|
|
43
|
-
- `/parallel-review` — fresh-context reviewers with distinct review angles, then synthesis
|
|
44
|
-
- `/parallel-research` — combine `researcher` and `scout` for external evidence plus local code context
|
|
45
|
-
- `/gather-context-and-clarify` — scout/research first, then ask the user clarifying questions with `interview`
|
|
46
|
-
|
|
47
|
-
## Builtin Agents
|
|
48
|
-
|
|
49
|
-
Builtin agents load at the lowest priority. Project agents override user agents,
|
|
50
|
-
and user/project agents override builtins with the same name.
|
|
51
|
-
|
|
52
|
-
| Agent | Purpose | Model | Typical output / role |
|
|
53
|
-
|-------|---------|-------|------------------------|
|
|
54
|
-
| `scout` | Fast codebase recon | `openai-codex/gpt-5.4-mini` | Writes `context.md` handoff material |
|
|
55
|
-
| `planner` | Creates implementation plans | `openai-codex/gpt-5.5` | Writes `plan.md` |
|
|
56
|
-
| `worker` | Implementation and approved oracle handoffs | `openai-codex/gpt-5.3-codex` | Single-writer implementation with decision escalation |
|
|
57
|
-
| `reviewer` | Review-and-fix specialist | `openai-codex/gpt-5.5` | Can edit/fix reviewed code |
|
|
58
|
-
| `context-builder` | Requirements/codebase handoff builder | `openai-codex/gpt-5.5` | Writes structured context files |
|
|
59
|
-
| `researcher` | Web research brief generator | `openai-codex/gpt-5.5` | Writes `research.md` |
|
|
60
|
-
| `delegate` | Lightweight generic delegate | inherits parent model | No fixed output; generic delegated work |
|
|
61
|
-
| `oracle` | Decision-consistency advisory review | `openai-codex/gpt-5.5` | Advisory review, intercom coordination |
|
|
62
|
-
|
|
63
|
-
Override builtin defaults before copying full agent files when a small tweak is enough.
|
|
64
|
-
|
|
65
|
-
For one run, use inline config:
|
|
66
|
-
|
|
67
|
-
```text
|
|
68
|
-
/run reviewer[model=anthropic/claude-sonnet-4] "Review this diff"
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
For persistent tweaks, prefer `/agents`: choose the builtin, press `e`, change the model or other fields, then save a user or project override. User overrides apply everywhere. Project overrides apply only in that repo and win over user overrides.
|
|
72
|
-
|
|
73
|
-
Settings locations:
|
|
74
|
-
- User scope: `~/.pi/agent/settings.json`
|
|
75
|
-
- Project scope: `.pi/settings.json`
|
|
76
|
-
|
|
77
|
-
Direct settings example:
|
|
78
|
-
|
|
79
|
-
```json
|
|
80
|
-
{
|
|
81
|
-
"subagents": {
|
|
82
|
-
"agentOverrides": {
|
|
83
|
-
"reviewer": {
|
|
84
|
-
"model": "anthropic/claude-sonnet-4",
|
|
85
|
-
"thinking": "high",
|
|
86
|
-
"fallbackModels": ["openai/gpt-5-mini"]
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Useful override fields: `model`, `fallbackModels`, `thinking`,
|
|
94
|
-
`systemPromptMode`, `inheritProjectContext`, `inheritSkills`, `disabled`,
|
|
95
|
-
`skills`, `tools`, and `systemPrompt`. Create a user or project agent with the
|
|
96
|
-
same name only when you want a substantially different agent.
|
|
97
|
-
|
|
98
|
-
## Discovery and Scope Rules
|
|
99
|
-
|
|
100
|
-
Agent files can live in:
|
|
101
|
-
- `~/.pi/agent/agents/*.md` — user scope
|
|
102
|
-
- `.pi/agents/*.md` — canonical project scope
|
|
103
|
-
- legacy `.agents/*.md` — still read for compatibility, but `.pi/agents/` wins on conflicts
|
|
104
|
-
|
|
105
|
-
Chains live in:
|
|
106
|
-
- `~/.pi/agent/agents/*.chain.md`
|
|
107
|
-
- `.pi/agents/*.chain.md`
|
|
108
|
-
- legacy `.agents/*.chain.md`
|
|
109
|
-
|
|
110
|
-
Precedence is:
|
|
111
|
-
1. project scope
|
|
112
|
-
2. user scope
|
|
113
|
-
3. builtin agents
|
|
114
|
-
|
|
115
|
-
## Running Subagents
|
|
116
|
-
|
|
117
|
-
### Single agent
|
|
118
|
-
|
|
119
|
-
```typescript
|
|
120
|
-
subagent({
|
|
121
|
-
agent: "oracle",
|
|
122
|
-
task: "Review my current direction and challenge assumptions."
|
|
123
|
-
})
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Forked context
|
|
127
|
-
|
|
128
|
-
```typescript
|
|
129
|
-
subagent({
|
|
130
|
-
agent: "oracle",
|
|
131
|
-
task: "Review my current direction and challenge assumptions.",
|
|
132
|
-
context: "fork"
|
|
133
|
-
})
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
`context: "fork"` creates a branched child session from the current persisted
|
|
137
|
-
parent session. It does **not** create a fresh minimal review context or filter
|
|
138
|
-
history down to only the relevant parts. Use it when you want a separate review
|
|
139
|
-
or execution thread that can still reference the parent session history.
|
|
140
|
-
|
|
141
|
-
### Parallel execution
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
subagent({
|
|
145
|
-
tasks: [
|
|
146
|
-
{ agent: "scout", task: "Explore the auth module" },
|
|
147
|
-
{ agent: "reviewer", task: "Review the API client" }
|
|
148
|
-
]
|
|
149
|
-
})
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
Top-level parallel tasks can override per-task behavior:
|
|
153
|
-
|
|
154
|
-
```typescript
|
|
155
|
-
subagent({
|
|
156
|
-
tasks: [
|
|
157
|
-
{ agent: "scout", task: "Map auth", output: "auth-context.md", progress: true },
|
|
158
|
-
{ agent: "researcher", task: "Research OAuth best practices", output: "oauth-research.md" },
|
|
159
|
-
{ agent: "reviewer", task: "Review auth tests", model: "anthropic/claude-sonnet-4" }
|
|
160
|
-
],
|
|
161
|
-
concurrency: 3
|
|
162
|
-
})
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
Avoid duplicate output paths in parallel tasks. Concurrent children should not write to the same file.
|
|
166
|
-
|
|
167
|
-
### Chain execution
|
|
168
|
-
|
|
169
|
-
```typescript
|
|
170
|
-
subagent({
|
|
171
|
-
chain: [
|
|
172
|
-
{ agent: "scout", task: "Map the auth flow and summarize key files" },
|
|
173
|
-
{ agent: "planner", task: "Create an implementation plan from {previous}" },
|
|
174
|
-
{ agent: "worker", task: "Implement the approved plan based on {previous}" }
|
|
175
|
-
]
|
|
176
|
-
})
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
Chain steps can use templated variables such as `{task}`, `{previous}`, and
|
|
180
|
-
`{chain_dir}`. This is the main way to pass structured summaries between steps
|
|
181
|
-
without forcing each step to rediscover everything.
|
|
182
|
-
|
|
183
|
-
### Async/background
|
|
184
|
-
|
|
185
|
-
```typescript
|
|
186
|
-
subagent({
|
|
187
|
-
agent: "worker",
|
|
188
|
-
task: "Run the full test suite",
|
|
189
|
-
async: true
|
|
190
|
-
})
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
Inspect async runs with `subagent({ action: "status", id: "..." })`, `subagent({ action: "status" })` for active runs, or the `/subagents-status` slash command.
|
|
194
|
-
|
|
195
|
-
Use diagnostics when setup or child startup looks wrong:
|
|
196
|
-
|
|
197
|
-
```typescript
|
|
198
|
-
subagent({ action: "doctor" })
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
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.
|
|
202
|
-
|
|
203
|
-
### Subagent control
|
|
204
|
-
|
|
205
|
-
Subagent control is the runtime visibility and intervention layer for delegated runs. It is separate from lifecycle status. Lifecycle status says whether a child is `queued`, `running`, `paused`, `complete`, or `failed`. Activity reporting is factual: it tracks the last observed activity time and the current tool when known. It does not pretend to know that a child is truly stuck.
|
|
206
|
-
|
|
207
|
-
Default behavior is intentionally conservative. When no activity has been observed past the configured threshold, the run emits a `needs_attention` control event. Foreground runs can push this as a `subagent:control-event` event, and async runs persist it to `events.jsonl` so the parent tracker can surface it without constant manual polling. Notification-worthy control events are also inserted into the visible transcript so both the user and the parent agent can see them, with a proactive hint plus concrete `nudge`, `status`, and `interrupt` options. Visible notifications fire once per child run and attention state.
|
|
208
|
-
|
|
209
|
-
Use soft interrupt when a child is clearly blocked or drifting and the parent needs to regain control:
|
|
210
|
-
|
|
211
|
-
```typescript
|
|
212
|
-
subagent({ action: "interrupt" })
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
Pass `id` when targeting a specific controllable run:
|
|
216
|
-
|
|
217
|
-
```typescript
|
|
218
|
-
subagent({ action: "interrupt", id: "abc123" })
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
A soft interrupt cancels the current child turn and leaves the run paused. It does not mean the delegated task succeeded or failed. After an interrupt, decide the next explicit action: resume with clearer instructions, replace the task, ask the user, or stop the workflow.
|
|
222
|
-
|
|
223
|
-
Per-run control thresholds can be overridden when a task legitimately runs without observable output for longer than usual:
|
|
224
|
-
|
|
225
|
-
```typescript
|
|
226
|
-
subagent({
|
|
227
|
-
agent: "worker",
|
|
228
|
-
task: "Run the slow migration test suite",
|
|
229
|
-
control: {
|
|
230
|
-
needsAttentionAfterMs: 300000,
|
|
231
|
-
notifyOn: ["needs_attention"]
|
|
232
|
-
}
|
|
233
|
-
})
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
If the run already has an active intercom bridge target, needs-attention notifications can also prepare a compact intercom ping for the orchestrator. When a child route is available, the ping tells the orchestrator which agent needs attention and includes the exact `intercom({ action: "send", to: "..." })` target for a nudge. Do not invent a target or ask the child to self-report when no bridge exists.
|
|
237
|
-
|
|
238
|
-
## Clarify TUI
|
|
239
|
-
|
|
240
|
-
Single and parallel runs support a clarification TUI when you want to preview or
|
|
241
|
-
edit parameters before launch:
|
|
242
|
-
|
|
243
|
-
```typescript
|
|
244
|
-
subagent({
|
|
245
|
-
agent: "worker",
|
|
246
|
-
task: "Implement feature X",
|
|
247
|
-
clarify: true
|
|
248
|
-
})
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
Chains default to clarify mode unless you explicitly set `clarify: false`.
|
|
252
|
-
For programmatic background launches, use `clarify: false, async: true`.
|
|
253
|
-
|
|
254
|
-
The `/agents` manager also has launch toggles for forked context, background execution, and worktree-isolated parallel runs. Use it when guiding a human who wants to inspect or edit the launch before starting.
|
|
255
|
-
|
|
256
|
-
## Worktree Isolation
|
|
257
|
-
|
|
258
|
-
When multiple agents might write concurrently, use worktrees instead of letting
|
|
259
|
-
them share one filesystem view.
|
|
260
|
-
|
|
261
|
-
```typescript
|
|
262
|
-
subagent({
|
|
263
|
-
tasks: [
|
|
264
|
-
{ agent: "worker", task: "Implement feature A" },
|
|
265
|
-
{ agent: "worker", task: "Implement feature B" }
|
|
266
|
-
],
|
|
267
|
-
worktree: true
|
|
268
|
-
})
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
`worktree: true` gives each parallel task its own git worktree branched from
|
|
272
|
-
HEAD. This requires a clean git state and is mainly for intentionally parallel
|
|
273
|
-
write workflows. If you want one writer thread and several advisory agents,
|
|
274
|
-
prefer a single-writer pattern instead.
|
|
275
|
-
|
|
276
|
-
## The Oracle Workflow
|
|
277
|
-
|
|
278
|
-
The intended oracle loop is:
|
|
279
|
-
1. the main agent forks to `oracle`
|
|
280
|
-
2. `oracle` reviews direction, drift, assumptions, and risks
|
|
281
|
-
3. `oracle` can coordinate back to the orchestrator via `intercom`
|
|
282
|
-
4. the main agent decides what direction to approve
|
|
283
|
-
5. only then should `worker` implement
|
|
284
|
-
|
|
285
|
-
```typescript
|
|
286
|
-
// Advisory review in a branched thread
|
|
287
|
-
subagent({
|
|
288
|
-
agent: "oracle",
|
|
289
|
-
task: "Review my current direction, challenge assumptions, and propose the best next move.",
|
|
290
|
-
context: "fork"
|
|
291
|
-
})
|
|
292
|
-
|
|
293
|
-
// Implementation only after explicit approval
|
|
294
|
-
subagent({
|
|
295
|
-
agent: "worker",
|
|
296
|
-
task: "Implement the approved approach: ...",
|
|
297
|
-
context: "fork"
|
|
298
|
-
})
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
`oracle` is not a fresh-context reviewer in the Cognition article sense. It is
|
|
302
|
-
a forked advisory thread that inherits the parent session history and uses that
|
|
303
|
-
history as a baseline contract.
|
|
304
|
-
|
|
305
|
-
## Subagent + Intercom Coordination
|
|
306
|
-
|
|
307
|
-
`pi-subagents` works without `pi-intercom`. When `pi-intercom` is installed and enabled, the intercom bridge can automatically give child agents a private coordination channel back to the parent session.
|
|
308
|
-
|
|
309
|
-
Most agents should not call `intercom` directly unless bridge instructions provide a target. Do not invent a target. Use the target from the injected bridge instructions or from a visible needs-attention notice.
|
|
310
|
-
|
|
311
|
-
Use `intercom` when:
|
|
312
|
-
- a subagent is blocked on a decision
|
|
313
|
-
- a child needs clarification instead of guessing
|
|
314
|
-
- a detached or async child needs to coordinate without waiting for normal tool return flow
|
|
315
|
-
- an advisory agent was explicitly asked to send a concise progress update
|
|
316
|
-
|
|
317
|
-
Message conventions:
|
|
318
|
-
- `ask` means the child needs a decision or clarification from the parent session.
|
|
319
|
-
- `send` means a short blocked/progress update, only when blocked or explicitly asked.
|
|
320
|
-
- Child-side routine completion handoffs are not expected. With the intercom bridge active, parent-side `pi-subagents` sends grouped completion results through `pi-intercom`: one grouped message per foreground parent run and one per completed async result file. Acknowledged foreground delivery returns a compact receipt with artifact/session paths; if unacknowledged, the normal full output is preserved. Grouped messages include child intercom targets and full child summaries.
|
|
321
|
-
|
|
322
|
-
If a bridge target is available, a child can ask:
|
|
323
|
-
|
|
324
|
-
```typescript
|
|
325
|
-
intercom({
|
|
326
|
-
action: "ask",
|
|
327
|
-
to: "<bridge-provided-target>",
|
|
328
|
-
message: "Should I optimize for readability or performance here?"
|
|
329
|
-
})
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
The parent replies with:
|
|
333
|
-
|
|
334
|
-
```typescript
|
|
335
|
-
intercom({ action: "reply", message: "Optimize for readability." })
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
Or inspects unresolved asks first:
|
|
339
|
-
|
|
340
|
-
```typescript
|
|
341
|
-
intercom({ action: "pending" })
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
If intercom messages do not show up, run `subagent({ action: "doctor" })` or `/subagents-doctor`.
|
|
345
|
-
|
|
346
|
-
## Management Mode
|
|
347
|
-
|
|
348
|
-
The `subagent(...)` tool also supports management actions.
|
|
349
|
-
|
|
350
|
-
### List available agents and chains
|
|
351
|
-
|
|
352
|
-
```typescript
|
|
353
|
-
subagent({ action: "list" })
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
### Create an agent
|
|
357
|
-
|
|
358
|
-
```typescript
|
|
359
|
-
subagent({
|
|
360
|
-
action: "create",
|
|
361
|
-
config: {
|
|
362
|
-
name: "my-agent",
|
|
363
|
-
description: "Project-specific implementation helper",
|
|
364
|
-
systemPrompt: "Your system prompt here.",
|
|
365
|
-
systemPromptMode: "replace",
|
|
366
|
-
model: "openai-codex/gpt-5.4",
|
|
367
|
-
tools: "read,grep,find,ls,bash"
|
|
368
|
-
}
|
|
369
|
-
})
|
|
370
|
-
```
|
|
371
|
-
|
|
372
|
-
### Update an agent
|
|
373
|
-
|
|
374
|
-
```typescript
|
|
375
|
-
subagent({
|
|
376
|
-
action: "update",
|
|
377
|
-
agent: "my-agent",
|
|
378
|
-
config: {
|
|
379
|
-
thinking: "high"
|
|
380
|
-
}
|
|
381
|
-
})
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
### Delete an agent
|
|
385
|
-
|
|
386
|
-
```typescript
|
|
387
|
-
subagent({ action: "delete", agent: "my-agent" })
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
Use management actions when the system needs to create or edit subagents on
|
|
391
|
-
demand without dropping into raw file editing.
|
|
392
|
-
|
|
393
|
-
Management actions create or update user/project agent files. For small builtin changes such as a model swap, prefer `/agents` builtin overrides or `subagents.agentOverrides` in settings.
|
|
394
|
-
|
|
395
|
-
## Creating and Editing Agents by File
|
|
396
|
-
|
|
397
|
-
A minimal agent file looks like this:
|
|
398
|
-
|
|
399
|
-
```markdown
|
|
400
|
-
---
|
|
401
|
-
name: my-agent
|
|
402
|
-
description: What this agent does
|
|
403
|
-
model: openai-codex/gpt-5.4
|
|
404
|
-
thinking: high
|
|
405
|
-
tools: read, grep, find, ls, bash
|
|
406
|
-
systemPromptMode: replace
|
|
407
|
-
inheritProjectContext: true
|
|
408
|
-
inheritSkills: false
|
|
409
|
-
---
|
|
410
|
-
|
|
411
|
-
Your system prompt here.
|
|
412
|
-
```
|
|
413
|
-
|
|
414
|
-
That is only a starting point. Common optional fields include:
|
|
415
|
-
- `defaultProgress`
|
|
416
|
-
- `defaultReads`
|
|
417
|
-
- `output`
|
|
418
|
-
- `fallbackModels`
|
|
419
|
-
- `maxSubagentDepth`
|
|
420
|
-
|
|
421
|
-
For many customizations, builtin overrides in settings are lower-friction than
|
|
422
|
-
copying a full builtin file.
|
|
423
|
-
|
|
424
|
-
## Prompt Template Integration
|
|
425
|
-
|
|
426
|
-
The package includes prompt shortcuts for common workflows: `/parallel-review`,
|
|
427
|
-
`/parallel-research`, and `/gather-context-and-clarify`. Use them when the user
|
|
428
|
-
wants repeatable review, research, or clarification patterns.
|
|
429
|
-
|
|
430
|
-
If `pi-prompt-template-model` is installed, additional user prompt templates can delegate into
|
|
431
|
-
`pi-subagents`. This is useful when a slash command should always run through a
|
|
432
|
-
particular agent or with forked context.
|
|
433
|
-
|
|
434
|
-
## Important Constraints
|
|
435
|
-
|
|
436
|
-
- **Forking requires a persisted parent session.** If the current session does not
|
|
437
|
-
have a persisted session file, forked runs fail.
|
|
438
|
-
- **Forked runs inherit parent history.** They are branched threads, not fresh
|
|
439
|
-
filtered contexts. Use fresh context for adversarial reviewers unless the user explicitly asks for forked context.
|
|
440
|
-
- **Default subagent nesting depth is 2.** Deeper recursive delegation is blocked
|
|
441
|
-
unless configured otherwise.
|
|
442
|
-
- **Attention signals are not lifecycle state.** `needs_attention` means no activity has been observed past the configured threshold. `paused` means the child turn was intentionally interrupted or is awaiting direction; it is not the same as `failed`.
|
|
443
|
-
- **Intercom asks are blocking.** A session can only maintain one pending outbound
|
|
444
|
-
ask wait state at a time.
|
|
445
|
-
- **Keep conversational authority clear.** Advisory subagents should not silently
|
|
446
|
-
become second decision-makers.
|
|
447
|
-
|
|
448
|
-
## Best Practices
|
|
449
|
-
|
|
450
|
-
### Keep writes single-threaded by default
|
|
451
|
-
|
|
452
|
-
A strong pattern is one main decision-maker plus advisory/research/review
|
|
453
|
-
subagents around it. Use `oracle` for advice and `worker` for the actual write path.
|
|
454
|
-
|
|
455
|
-
### Use fork for branched advisory or execution threads
|
|
456
|
-
|
|
457
|
-
Forked runs are useful when the child should reason in a separate thread while
|
|
458
|
-
still inheriting the parent’s accumulated context. They are especially useful for
|
|
459
|
-
`oracle`, which audits inherited decisions and drift. For adversarial code review,
|
|
460
|
-
prefer fresh-context reviewers that inspect the repo and diff directly unless the
|
|
461
|
-
user explicitly requests forked context.
|
|
462
|
-
|
|
463
|
-
### Prefer narrow tasks
|
|
464
|
-
|
|
465
|
-
Give subagents specific tasks rather than vague mandates.
|
|
466
|
-
`Review auth.ts for null-check gaps` works better than `Review everything`.
|
|
467
|
-
|
|
468
|
-
### Escalate decisions upward
|
|
469
|
-
|
|
470
|
-
If a subagent encounters an unapproved product, architecture, or scope choice,
|
|
471
|
-
it should coordinate back via `intercom` instead of deciding alone.
|
|
472
|
-
|
|
473
|
-
### Intervene only on clear control signals
|
|
474
|
-
|
|
475
|
-
Use subagent control proactively when a delegated run emits `needs_attention`, or when a human asks you to regain control. Do not interrupt just because a child has briefly produced no output. Silence can be normal during long tool calls, test runs, or model reasoning.
|
|
476
|
-
|
|
477
|
-
### Name sessions meaningfully
|
|
478
|
-
|
|
479
|
-
Use `/name` so intercom targeting stays stable.
|
|
480
|
-
|
|
481
|
-
## Common Workflows
|
|
482
|
-
|
|
483
|
-
### Recon → Plan → Implement
|
|
484
|
-
|
|
485
|
-
```typescript
|
|
486
|
-
subagent({
|
|
487
|
-
chain: [
|
|
488
|
-
{ agent: "scout", task: "Map the auth flow and summarize relevant files" },
|
|
489
|
-
{ agent: "planner", task: "Plan the migration from {previous}" },
|
|
490
|
-
{ agent: "worker", task: "Implement the approved plan from {previous}" }
|
|
491
|
-
]
|
|
492
|
-
})
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
### Review loop
|
|
496
|
-
|
|
497
|
-
```typescript
|
|
498
|
-
subagent({ agent: "worker", task: "Add retry logic to the API client." })
|
|
499
|
-
subagent({
|
|
500
|
-
agent: "reviewer",
|
|
501
|
-
task: "Review the retry logic implementation. Inspect the repo and current diff directly. Look for edge cases and race conditions."
|
|
502
|
-
})
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
### Parallel non-conflicting analysis
|
|
506
|
-
|
|
507
|
-
```typescript
|
|
508
|
-
subagent({
|
|
509
|
-
tasks: [
|
|
510
|
-
{ agent: "scout", task: "Audit frontend auth flow" },
|
|
511
|
-
{ agent: "researcher", task: "Research current retry/backoff best practices" }
|
|
512
|
-
]
|
|
513
|
-
})
|
|
514
|
-
```
|
|
515
|
-
|
|
516
|
-
### Saved chain
|
|
517
|
-
|
|
518
|
-
```text
|
|
519
|
-
/run-chain review-chain -- review this branch
|
|
520
|
-
```
|
|
521
|
-
|
|
522
|
-
Use saved `.chain.md` workflows when the user wants a repeatable multi-agent flow without rewriting the chain each time.
|
|
523
|
-
|
|
524
|
-
## Error Handling
|
|
525
|
-
|
|
526
|
-
**"Unknown agent"**
|
|
527
|
-
```typescript
|
|
528
|
-
subagent({ action: "list" })
|
|
529
|
-
// Check available agents and chains, then confirm scope/precedence.
|
|
530
|
-
```
|
|
531
|
-
|
|
532
|
-
**Setup, discovery, or intercom confusion**
|
|
533
|
-
```typescript
|
|
534
|
-
subagent({ action: "doctor" })
|
|
535
|
-
// Check runtime paths, async support, discovery counts, current session, and intercom bridge state.
|
|
536
|
-
```
|
|
537
|
-
|
|
538
|
-
**"Max subagent depth exceeded"**
|
|
539
|
-
```typescript
|
|
540
|
-
// Flatten the workflow or raise maxSubagentDepth in config.
|
|
541
|
-
```
|
|
542
|
-
|
|
543
|
-
**"Session manager did not return a session file"**
|
|
544
|
-
```typescript
|
|
545
|
-
// Persist the current session before using context: "fork".
|
|
546
|
-
```
|
|
547
|
-
|
|
548
|
-
**Intercom "Already waiting for a reply"**
|
|
549
|
-
```typescript
|
|
550
|
-
// Resolve the current outbound ask before starting another one.
|
|
551
|
-
```
|
|
552
|
-
|
|
553
|
-
**Parallel output-path conflict**
|
|
554
|
-
```typescript
|
|
555
|
-
// Give each parallel task a distinct output path, or disable output for tasks that do not need it.
|
|
556
|
-
```
|
|
557
|
-
|
|
558
|
-
**Worktree launch fails**
|
|
559
|
-
```typescript
|
|
560
|
-
// Ensure the git working tree is clean and task cwd overrides match the shared cwd.
|
|
561
|
-
```
|
|
562
|
-
|
|
563
|
-
**Child fails before starting**
|
|
564
|
-
```typescript
|
|
565
|
-
// Inspect /subagents-status detail, artifact metadata/output logs, and run doctor. Extension loader errors usually appear in child output logs.
|
|
566
|
-
```
|