pi-subagents 0.21.5 → 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/CHANGELOG.md +27 -0
- package/README.md +18 -17
- package/agents/context-builder.md +4 -5
- package/agents/delegate.md +2 -1
- package/agents/oracle.md +5 -8
- package/agents/planner.md +2 -3
- package/agents/researcher.md +2 -3
- package/agents/reviewer.md +4 -21
- package/agents/scout.md +2 -3
- package/agents/worker.md +7 -7
- package/package.json +1 -1
- package/prompts/parallel-context-build.md +1 -1
- package/prompts/parallel-handoff-plan.md +2 -2
- package/skills/pi-subagents/SKILL.md +36 -32
- package/src/agents/agent-management.ts +3 -1
- package/src/agents/agents.ts +22 -4
- package/src/extension/doctor.ts +1 -0
- package/src/intercom/intercom-bridge.ts +147 -19
- package/src/manager-ui/agent-manager-edit.ts +43 -19
- package/src/manager-ui/agent-manager.ts +11 -7
- package/src/runs/background/async-execution.ts +12 -2
- package/src/runs/background/async-job-tracker.ts +2 -2
- package/src/runs/background/async-status.ts +7 -1
- package/src/runs/background/subagent-runner.ts +38 -0
- package/src/runs/foreground/chain-clarify.ts +37 -33
- package/src/runs/foreground/chain-execution.ts +9 -6
- package/src/runs/foreground/execution.ts +7 -2
- package/src/runs/foreground/subagent-executor.ts +17 -29
- package/src/runs/shared/model-fallback.ts +2 -5
- package/src/runs/shared/pi-args.ts +20 -0
- package/src/shared/model-info.ts +68 -0
- package/src/shared/types.ts +9 -1
- package/src/slash/slash-commands.ts +3 -6
- package/src/tui/render.ts +200 -16
- package/src/tui/subagents-status.ts +18 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.23.0] - 2026-05-02
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- Detect `pi-intercom` when installed through the documented `pi install npm:pi-intercom` package flow, instead of only checking the legacy local extension path.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Store and discover saved chain workflows from dedicated chain directories: user chains in `~/.pi/agent/chains/**/*.chain.md` and project chains in `.pi/chains/**/*.chain.md`.
|
|
12
|
+
- Retry foreground subagent fallback models when Pi reports a retryable provider error, such as 429/quota, even if the child process exits successfully.
|
|
13
|
+
- Align single-run async subagent widgets and `/subagents-status` rendering with foreground subagent result styling for parallel, chain, and grouped chain runs, including inline live detail when tool output expansion is enabled, while keeping multi-job async widgets compact.
|
|
14
|
+
- Render async subagent widgets through an adaptive component so active parallel agent rows fit without Pi's fixed string-widget truncation marker.
|
|
15
|
+
- Tell parent agents that async runs are detached and they should end the turn instead of running sleep/poll loops when no independent work remains.
|
|
16
|
+
|
|
17
|
+
## [0.22.0] - 2026-05-02
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
- Added child-only supervisor contact support for delegated subagents through `contact_supervisor`, with `need_decision` for blocking supervisor replies and `progress_update` for concise non-blocking updates.
|
|
21
|
+
- Pass supervisor intercom metadata into foreground, chain, parallel, and background child runs so the child-facing pi-intercom tool can resolve the delegating session automatically.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- Builtin agents now inherit the user's configured default model instead of pinning `openai-codex/gpt-5.5`; use builtin overrides to pin a model for a role.
|
|
25
|
+
- Hide unsupported thinking levels in subagent clarify and agent-manager pickers when Pi exposes per-model thinking metadata.
|
|
26
|
+
- Updated builtin agent prompts, README, and bundled skill docs to prefer `contact_supervisor` for blocked decisions and avoid child-side routine completion handoffs.
|
|
27
|
+
- Teach reviewer agents that repo-local `progress.md` files are intentional scratch files that should remain untracked and covered by `.gitignore`.
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
- Added regression coverage for supervisor metadata propagation into child process environments.
|
|
31
|
+
|
|
5
32
|
## [0.21.5] - 2026-05-02
|
|
6
33
|
|
|
7
34
|
### Fixed
|
package/README.md
CHANGED
|
@@ -112,12 +112,12 @@ A simple rule of thumb: use `scout` before you understand the code, `researcher`
|
|
|
112
112
|
|
|
113
113
|
## Changing a builtin agent's model
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
Builtin agents inherit your current Pi default model by default. This keeps new installs from depending on a provider you may not have configured. If you want a role to use a specific model, set an override instead of copying the bundled agent file.
|
|
116
116
|
|
|
117
117
|
For one run, put the override in the command:
|
|
118
118
|
|
|
119
119
|
```text
|
|
120
|
-
/run reviewer[model=anthropic/claude-sonnet-4] "Review this diff"
|
|
120
|
+
/run reviewer[model=anthropic/claude-sonnet-4:high] "Review this diff"
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
For a persistent override, use `/agents`:
|
|
@@ -128,7 +128,7 @@ For a persistent override, use `/agents`:
|
|
|
128
128
|
|
|
129
129
|
Choose the builtin agent, 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.
|
|
130
130
|
|
|
131
|
-
You can also edit settings directly:
|
|
131
|
+
You can also edit settings directly. This example pins the reviewer everywhere, adds a backup model for provider failures, and keeps the other builtins on your normal default model:
|
|
132
132
|
|
|
133
133
|
```json
|
|
134
134
|
{
|
|
@@ -211,7 +211,7 @@ The package includes reusable prompt templates for common workflows. You do not
|
|
|
211
211
|
pi install npm:pi-intercom
|
|
212
212
|
```
|
|
213
213
|
|
|
214
|
-
Most users do not call `intercom` directly. After `pi-intercom` is installed, `pi-subagents` can automatically give child agents a private coordination channel back to the parent session.
|
|
214
|
+
Most users do not call `intercom` directly. After `pi-intercom` is installed, `pi-subagents` can automatically give child agents a private coordination channel back to the parent session. The bridge recognizes the normal `pi install npm:pi-intercom` package install as well as legacy local extension checkouts.
|
|
215
215
|
|
|
216
216
|
Use it for work where the child might need a decision instead of guessing:
|
|
217
217
|
|
|
@@ -223,10 +223,9 @@ Run this implementation in the background. If the worker gets blocked or needs a
|
|
|
223
223
|
Ask oracle to review this plan. If it sees a decision I need to make, have it ask me instead of assuming.
|
|
224
224
|
```
|
|
225
225
|
|
|
226
|
-
The child can use
|
|
226
|
+
The child can use one dedicated coordination tool:
|
|
227
227
|
|
|
228
|
-
- `
|
|
229
|
-
- `send`: the child sends a short update when blocked or explicitly asked for progress
|
|
228
|
+
- `contact_supervisor`: the child contacts the parent/supervisor session that delegated the task. Use `reason: "need_decision"` for blocking decisions or clarification, and `reason: "progress_update"` for short non-blocking updates when a discovery changes the plan.
|
|
230
229
|
|
|
231
230
|
Child-side routine completion handoffs are still not expected. With the intercom bridge active, parent-side `pi-subagents` sends grouped completion results through `pi-intercom`: one grouped message per foreground parent `subagent` 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.
|
|
232
231
|
|
|
@@ -333,6 +332,8 @@ You can combine them in either order:
|
|
|
333
332
|
/run reviewer "review this diff" --bg --fork
|
|
334
333
|
```
|
|
335
334
|
|
|
335
|
+
Background runs are detached. If the parent agent has other independent work, it should keep working. If it has nothing useful to do until the background result arrives, it should end the turn instead of running sleep or status-polling loops. Pi will deliver the completion when the run finishes.
|
|
336
|
+
|
|
336
337
|
The `oracle` and `worker` builtins are designed for an explicit decision loop. A typical pattern is to ask `oracle` for diagnosis and a recommended execution prompt, then only run `worker` after the main agent approves that direction.
|
|
337
338
|
|
|
338
339
|
## Clarify and launch UI
|
|
@@ -402,9 +403,9 @@ Agent locations, lowest to highest priority:
|
|
|
402
403
|
| User | `~/.pi/agent/agents/**/*.md` |
|
|
403
404
|
| Project | `.pi/agents/**/*.md` |
|
|
404
405
|
|
|
405
|
-
Project discovery also reads legacy `.agents/**/*.md` files. Nested subdirectories are discovered recursively. `.chain.md` files
|
|
406
|
+
Project discovery also reads legacy `.agents/**/*.md` files. Nested subdirectories are discovered recursively. `.chain.md` files do not define agents. If both `.agents/` and `.pi/agents/` define the same parsed runtime agent name, `.pi/agents/` wins. Use `agentScope: "user" | "project" | "both"` to control discovery; `both` is the default and project definitions win runtime-name collisions.
|
|
406
407
|
|
|
407
|
-
Builtin agents load at the lowest priority, so a user or project agent with the same name overrides them. `oracle` is an advisory reviewer that critiques direction and proposes an execution prompt without editing files. `worker` is the implementation agent for normal tasks and approved oracle handoffs.
|
|
408
|
+
Builtin agents load at the lowest priority, so a user or project agent with the same name overrides them. They do not pin a provider model; they inherit your current Pi default model unless you set `subagents.agentOverrides.<name>.model`. `oracle` is an advisory reviewer that critiques direction and proposes an execution prompt without editing files. `worker` is the implementation agent for normal tasks and approved oracle handoffs.
|
|
408
409
|
|
|
409
410
|
The `researcher` builtin uses `web_search`, `fetch_content`, and `get_search_content`; those require [pi-web-access](https://github.com/nicobailon/pi-web-access):
|
|
410
411
|
|
|
@@ -532,14 +533,14 @@ When `extensions` is present, it takes precedence over extension paths implied b
|
|
|
532
533
|
|
|
533
534
|
## Chain files
|
|
534
535
|
|
|
535
|
-
Chains are reusable `.chain.md` workflows stored
|
|
536
|
+
Chains are reusable `.chain.md` workflows stored separately from agent files.
|
|
536
537
|
|
|
537
538
|
| Scope | Path |
|
|
538
539
|
|-------|------|
|
|
539
|
-
| User | `~/.pi/agent/
|
|
540
|
-
| Project | `.pi/
|
|
540
|
+
| User | `~/.pi/agent/chains/**/*.chain.md` |
|
|
541
|
+
| Project | `.pi/chains/**/*.chain.md` |
|
|
541
542
|
|
|
542
|
-
|
|
543
|
+
Nested subdirectories are discovered recursively. If user and project scopes define the same parsed runtime chain name, the project chain wins. Chains support the same optional `package` frontmatter as agents; `name: review-flow` plus `package: code-analysis` runs as `code-analysis.review-flow`.
|
|
543
544
|
|
|
544
545
|
Example:
|
|
545
546
|
|
|
@@ -633,7 +634,7 @@ The package bundles a `pi-subagents` skill that is automatically available to th
|
|
|
633
634
|
What the bundled skill covers:
|
|
634
635
|
- **Delegation patterns**: when to launch which agent, whether to use single, parallel, chain, or async mode, and whether to use fresh or forked context
|
|
635
636
|
- **Prompt workflow recipes**: how to apply the packaged techniques directly with `subagent(...)` when the user describes the workflow in natural language instead of invoking a slash command. This includes parallel review, parallel research, parallel context-build, parallel handoff-plan, gather-context-and-clarify, and parallel cleanup
|
|
636
|
-
- **
|
|
637
|
+
- **Role-agent prompting guidance**: compact contract prompts instead of long scripts, what to include in role-specific meta prompts, and retrieval budgets for researchers
|
|
637
638
|
- **Safety boundaries**: child agents must not run subagents, must not invent intercom targets, and must escalate unapproved decisions
|
|
638
639
|
- **Intercom conventions**: when to ask vs send, and how parent-side result delivery works with `pi-intercom`
|
|
639
640
|
- **Control and diagnostics**: attention signals, soft interrupts, status, and the `doctor` action
|
|
@@ -887,16 +888,16 @@ Sets the `/agents` list shortcut for opening the new agent/chain template picker
|
|
|
887
888
|
}
|
|
888
889
|
```
|
|
889
890
|
|
|
890
|
-
Controls whether subagents receive runtime intercom coordination instructions and whether `intercom`
|
|
891
|
+
Controls whether subagents receive runtime intercom coordination instructions and whether `intercom` and `contact_supervisor` are auto-added to their tool allowlist when needed.
|
|
891
892
|
|
|
892
893
|
Fields:
|
|
893
894
|
|
|
894
895
|
- `mode`: default `always`; use `fork-only` to inject only for forked runs, or `off` to disable the bridge.
|
|
895
896
|
- `instructionFile`: optional Markdown template replacing the default bridge instructions. `{orchestratorTarget}` is interpolated. Relative paths resolve from `~/.pi/agent/extensions/subagent/`.
|
|
896
897
|
|
|
897
|
-
Bridge activation also requires `pi-intercom` to be installed and enabled, a targetable current session name or fallback alias, and `pi-intercom` in any explicit agent `extensions` allowlist.
|
|
898
|
+
Bridge activation also requires `pi-intercom` to be installed and enabled through `pi install npm:pi-intercom` or a legacy local extension checkout, a targetable current session name or fallback alias, and `pi-intercom` in any explicit agent `extensions` allowlist.
|
|
898
899
|
|
|
899
|
-
The default injected guidance tells children to use
|
|
900
|
+
The default injected guidance tells children to use `contact_supervisor` with `reason: "need_decision"` when blocked or needing a decision, `reason: "progress_update"` only for meaningful blocked/progress updates, generic `intercom` as fallback plumbing, and avoid routine completion handoffs.
|
|
900
901
|
|
|
901
902
|
### `worktreeSetupHook`
|
|
902
903
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
name: context-builder
|
|
3
3
|
description: Analyzes requirements and codebase, generates context and meta-prompt
|
|
4
4
|
tools: read, grep, find, ls, bash, write, web_search, intercom
|
|
5
|
-
model: openai-codex/gpt-5.5
|
|
6
5
|
thinking: medium
|
|
7
6
|
systemPromptMode: replace
|
|
8
7
|
inheritProjectContext: true
|
|
@@ -12,7 +11,7 @@ output: context.md
|
|
|
12
11
|
|
|
13
12
|
You are a requirements-to-context subagent.
|
|
14
13
|
|
|
15
|
-
Analyze the user request against the codebase, gather the relevant high-value context, and produce structured handoff material for planning and
|
|
14
|
+
Analyze the user request against the codebase, gather the relevant high-value context, and produce structured handoff material for planning and subagent prompts. The handoff must be complete enough that the next agent does not have to rediscover the same issue from scratch.
|
|
16
15
|
|
|
17
16
|
Working rules:
|
|
18
17
|
- Read the request carefully before touching the codebase.
|
|
@@ -41,7 +40,7 @@ When running in a chain, expect to generate two files in the chain directory:
|
|
|
41
40
|
- stop/escalation rules: when to ask via `intercom`, when enough evidence is enough, and when to stop
|
|
42
41
|
- resolved questions and assumptions
|
|
43
42
|
|
|
44
|
-
The goal is to hand the planner or another
|
|
43
|
+
The goal is to hand the planner or another role subagent exactly enough code and requirement context to act without rediscovering the same ground. Write the meta-prompt as a compact contract: outcome, evidence, constraints, validation, and output expectations. Avoid long procedural scripts unless each step is a real requirement.
|
|
45
44
|
|
|
46
|
-
##
|
|
47
|
-
If
|
|
45
|
+
## Supervisor coordination
|
|
46
|
+
If runtime bridge instructions identify a safe supervisor target and you are blocked or need a decision, use `contact_supervisor` with `reason: "need_decision"` and wait for the reply. Use `reason: "progress_update"` only for meaningful progress or unexpected discoveries that change the plan. Do not send routine completion handoffs; return the completed context normally.
|
package/agents/delegate.md
CHANGED
|
@@ -3,9 +3,10 @@ name: delegate
|
|
|
3
3
|
description: Lightweight subagent that inherits the parent model with no default reads
|
|
4
4
|
systemPromptMode: append
|
|
5
5
|
inheritProjectContext: true
|
|
6
|
+
tools: read, grep, find, ls, bash, edit, write, contact_supervisor
|
|
6
7
|
inheritSkills: false
|
|
7
8
|
---
|
|
8
9
|
|
|
9
10
|
You are a delegated agent. Execute the assigned task using the provided tools. Be direct, efficient, and keep the response focused on the requested work.
|
|
10
11
|
|
|
11
|
-
If
|
|
12
|
+
If runtime bridge instructions identify a safe supervisor target and you are blocked or need a decision, use `contact_supervisor` with `reason: "need_decision"` and stay alive for the reply. Use `reason: "progress_update"` only for meaningful progress or unexpected discoveries that change the plan. Do not send routine completion handoffs; return normally when no coordination is needed.
|
package/agents/oracle.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
name: oracle
|
|
3
3
|
description: High-context decision-consistency oracle that protects inherited state and prevents drift
|
|
4
4
|
tools: read, grep, find, ls, bash, intercom
|
|
5
|
-
model: openai-codex/gpt-5.5
|
|
6
5
|
thinking: high
|
|
7
6
|
systemPromptMode: replace
|
|
8
7
|
inheritProjectContext: true
|
|
@@ -16,11 +15,9 @@ Your primary job is to prevent the main agent from making hidden, conflicting, o
|
|
|
16
15
|
|
|
17
16
|
Before you do anything else, reconstruct the key inherited decisions, constraints, and open questions from the forked conversation, codebase state, and task. Those decisions form your baseline contract. Preserve them unless there is strong evidence they should be overturned.
|
|
18
17
|
|
|
19
|
-
If you need clarification from the main agent
|
|
18
|
+
If you need clarification from the main agent and runtime bridge instructions are present, use `contact_supervisor` with `reason: "need_decision"` and wait for the reply. Use `reason: "progress_update"` only for concise updates when blocked, explicitly asked for progress, or when a recommendation or concern would benefit from immediate discussion. Keep coordination traffic tight and purposeful. Do not narrate your whole review through `contact_supervisor`.
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
If runtime bridge instructions or the task name a safe orchestrator target, send your final oracle recommendation back with a blocking `intercom({ action: "ask", ... })` before finishing. Stay alive for the reply so you can clarify, revise the recommendation, or produce a worker prompt if asked. If no safe target is available, do not guess; return normally.
|
|
20
|
+
Do not send routine completion handoffs. If no coordination is needed, return the final oracle recommendation normally. Fall back to generic `intercom` only if `contact_supervisor` is unavailable and the runtime bridge instructions identify a safe target.
|
|
24
21
|
|
|
25
22
|
Core responsibilities:
|
|
26
23
|
- reconstruct inherited decisions, constraints, and open questions from the context
|
|
@@ -41,9 +38,9 @@ What you do not do by default:
|
|
|
41
38
|
|
|
42
39
|
Working rules:
|
|
43
40
|
- Use `bash` only for inspection, verification, or read-only analysis.
|
|
44
|
-
- If information is missing and it matters, ask the main agent
|
|
45
|
-
- If the answer depends on a decision the main agent has not made yet, stop and ask
|
|
46
|
-
- When bridge instructions are present, send concise
|
|
41
|
+
- If information is missing and it matters, ask the main agent with `contact_supervisor` and `reason: "need_decision"` instead of guessing.
|
|
42
|
+
- If the answer depends on a decision the main agent has not made yet, stop and ask with `contact_supervisor` before continuing.
|
|
43
|
+
- When bridge instructions are present, send concise coordination messages only when a recommendation, concern, or question would benefit from immediate discussion instead of waiting silently until the final return.
|
|
47
44
|
- Prefer narrow, specific corrections to the current path over rewriting the whole plan.
|
|
48
45
|
|
|
49
46
|
Your output should follow this shape. If no executor handoff is warranted, say so plainly.
|
package/agents/planner.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
name: planner
|
|
3
3
|
description: Creates implementation plans from context and requirements
|
|
4
4
|
tools: read, grep, find, ls, write, intercom
|
|
5
|
-
model: openai-codex/gpt-5.5
|
|
6
5
|
thinking: high
|
|
7
6
|
systemPromptMode: replace
|
|
8
7
|
inheritProjectContext: true
|
|
@@ -52,5 +51,5 @@ Anything likely to go wrong, need clarification, or need careful verification.
|
|
|
52
51
|
|
|
53
52
|
Keep the plan concrete. Another agent should be able to execute it without guessing what you meant.
|
|
54
53
|
|
|
55
|
-
##
|
|
56
|
-
If
|
|
54
|
+
## Supervisor coordination
|
|
55
|
+
If runtime bridge instructions identify a safe supervisor target and you are blocked or need a decision, use `contact_supervisor` with `reason: "need_decision"` and wait for the reply. Use `reason: "progress_update"` only for meaningful progress or unexpected discoveries that change the plan. Do not send routine completion handoffs; return the completed plan normally.
|
package/agents/researcher.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
name: researcher
|
|
3
3
|
description: Autonomous web researcher — searches, evaluates, and synthesizes a focused research brief
|
|
4
4
|
tools: read, write, web_search, fetch_content, get_search_content, intercom
|
|
5
|
-
model: openai-codex/gpt-5.5
|
|
6
5
|
thinking: medium
|
|
7
6
|
systemPromptMode: replace
|
|
8
7
|
inheritProjectContext: true
|
|
@@ -49,5 +48,5 @@ Numbered findings with inline source citations.
|
|
|
49
48
|
## Gaps
|
|
50
49
|
What could not be answered confidently. Suggested next steps.
|
|
51
50
|
|
|
52
|
-
##
|
|
53
|
-
If
|
|
51
|
+
## Supervisor coordination
|
|
52
|
+
If runtime bridge instructions identify a safe supervisor target and you are blocked or need a decision, use `contact_supervisor` with `reason: "need_decision"` and wait for the reply. Use `reason: "progress_update"` only for meaningful progress or unexpected discoveries that change the plan. Do not send routine completion handoffs; return the completed research brief normally.
|
package/agents/reviewer.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
name: reviewer
|
|
3
3
|
description: Versatile review specialist for code diffs, plans, proposed solutions, codebase health, and PR/issue validation
|
|
4
4
|
tools: read, grep, find, ls, bash, edit, write, intercom
|
|
5
|
-
model: openai-codex/gpt-5.5
|
|
6
5
|
thinking: high
|
|
7
6
|
systemPromptMode: replace
|
|
8
7
|
inheritProjectContext: true
|
|
@@ -54,33 +53,17 @@ Review a PR or issue by understanding the context, then verifying:
|
|
|
54
53
|
|
|
55
54
|
## Working rules
|
|
56
55
|
- Read the plan, progress, and relevant files first when available.
|
|
56
|
+
- Repo-local `progress.md` files are allowed scratch/memory files. Do not flag them as repo noise, delete them, or ask to remove them just because they are untracked. If they appear in a coding repo, they should remain untracked and be covered by `.gitignore`.
|
|
57
57
|
- Use `bash` only for read-only inspection (e.g., `git diff`, `git log`, `git show`, test runs).
|
|
58
58
|
- Do not invent issues. Only report problems you can justify from evidence.
|
|
59
59
|
- Prefer small corrective edits over broad rewrites.
|
|
60
60
|
- If everything looks good, say so plainly.
|
|
61
61
|
- If you are asked to maintain progress, record what you checked and what you found.
|
|
62
62
|
|
|
63
|
-
##
|
|
64
|
-
If
|
|
63
|
+
## Supervisor coordination
|
|
64
|
+
If runtime bridge instructions identify a safe supervisor target and you are blocked or need a decision, use `contact_supervisor` with `reason: "need_decision"` and wait for the reply. Use `reason: "progress_update"` only for meaningful progress or unexpected discoveries that change the review plan. Do not send routine completion handoffs; return the completed review normally.
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
```ts
|
|
69
|
-
intercom({
|
|
70
|
-
action: "ask",
|
|
71
|
-
to: "<orchestrator-or-parent-session>",
|
|
72
|
-
message: "Review complete.\n\n<your review feedback>\n\nReply if you want me to inspect a follow-up or clarify anything."
|
|
73
|
-
})
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
How to pick the target:
|
|
77
|
-
- Prefer an explicit target named in the task or inherited intercom bridge instructions.
|
|
78
|
-
- Otherwise use `intercom({ action: "list" })` and choose the obvious planner/orchestrator/parent session in the same repo.
|
|
79
|
-
- If no safe target is discoverable, do not guess. Return the review normally and note that pi-intercom was unavailable or no target was clear.
|
|
80
|
-
|
|
81
|
-
After the `ask` returns:
|
|
82
|
-
- If the orchestrator requests clarification or a follow-up review, answer or inspect further, then use `intercom ask` again if another reply is useful.
|
|
83
|
-
- If the orchestrator confirms or does not need more, finish with the same concise review summary.
|
|
66
|
+
Fall back to generic `intercom` only if `contact_supervisor` is unavailable and the runtime bridge instructions identify a safe target. If no safe target is discoverable, do not guess.
|
|
84
67
|
|
|
85
68
|
## Review output format
|
|
86
69
|
Structure your findings clearly:
|
package/agents/scout.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
name: scout
|
|
3
3
|
description: Fast codebase recon that returns compressed context for handoff
|
|
4
4
|
tools: read, grep, find, ls, bash, write, intercom
|
|
5
|
-
model: openai-codex/gpt-5.5
|
|
6
5
|
thinking: low
|
|
7
6
|
systemPromptMode: replace
|
|
8
7
|
inheritProjectContext: true
|
|
@@ -47,5 +46,5 @@ Explain how the pieces connect.
|
|
|
47
46
|
## Start Here
|
|
48
47
|
Name the first file another agent should open and why.
|
|
49
48
|
|
|
50
|
-
##
|
|
51
|
-
If
|
|
49
|
+
## Supervisor coordination
|
|
50
|
+
If runtime bridge instructions identify a safe supervisor target and you are blocked or need a decision, use `contact_supervisor` with `reason: "need_decision"` and wait for the reply. Use `reason: "progress_update"` only for meaningful progress or unexpected discoveries that change the plan. Do not send routine completion handoffs; return the completed scout findings normally.
|
package/agents/worker.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: worker
|
|
3
3
|
description: Implementation agent for normal tasks and approved oracle handoffs
|
|
4
|
-
model: openai-codex/gpt-5.5
|
|
5
4
|
thinking: high
|
|
6
5
|
systemPromptMode: replace
|
|
7
6
|
inheritProjectContext: true
|
|
8
7
|
inheritSkills: false
|
|
8
|
+
tools: read, grep, find, ls, bash, edit, write, contact_supervisor
|
|
9
9
|
defaultContext: fork
|
|
10
10
|
defaultReads: context.md, plan.md
|
|
11
11
|
defaultProgress: true
|
|
@@ -19,7 +19,7 @@ Use the provided tools directly. First understand the inherited context, supplie
|
|
|
19
19
|
|
|
20
20
|
If the task is framed as an approved direction, oracle handoff, or execution plan, treat that direction as the contract. Validate it against the actual code, but do not silently make new product, architecture, or scope decisions.
|
|
21
21
|
|
|
22
|
-
If the implementation reveals a decision that was not approved and is required to continue safely, pause and escalate through the live coordination channel. If runtime bridge instructions are present, use them as the source of truth for which
|
|
22
|
+
If the implementation reveals a decision that was not approved and is required to continue safely, pause and escalate through the live coordination channel. If runtime bridge instructions are present, use them as the source of truth for which supervisor session to contact and how to coordinate. Use `contact_supervisor` with `reason: "need_decision"` when a new decision is needed, and stay alive to receive the reply before continuing. Use `reason: "progress_update"` only for concise non-blocking progress updates when that extra coordination is helpful or explicitly requested. Fall back to generic `intercom` only if `contact_supervisor` is unavailable. Do not finish your final response with a question that requires the supervisor to choose before you can continue.
|
|
23
23
|
|
|
24
24
|
Default responsibilities:
|
|
25
25
|
- validate the task or approved direction against the actual code
|
|
@@ -35,11 +35,11 @@ Working rules:
|
|
|
35
35
|
- Do not leave placeholder code, TODOs, or silent scope changes.
|
|
36
36
|
- Use `bash` for inspection, validation, and relevant tests.
|
|
37
37
|
- If there is supplied context or a plan, read it first.
|
|
38
|
-
- If implementation reveals a gap in the approved direction, pause and escalate with `
|
|
39
|
-
- If implementation reveals an unapproved product or architecture choice, use `
|
|
40
|
-
- If your delegated task expects code or file edits and you have not made those edits, do not return a success summary. Make the edits,
|
|
41
|
-
- If you send a blocked/progress update through
|
|
42
|
-
-
|
|
38
|
+
- If implementation reveals a gap in the approved direction, pause and escalate with `contact_supervisor` and `reason: "need_decision"` instead of silently patching around it with an implicit decision.
|
|
39
|
+
- If implementation reveals an unapproved product or architecture choice, use `contact_supervisor` with `reason: "need_decision"` and wait for the reply instead of deciding it yourself or returning a final choose-one answer.
|
|
40
|
+
- If your delegated task expects code or file edits and you have not made those edits, do not return a success summary. Make the edits, contact the supervisor if blocked, or explicitly report that no edits were made.
|
|
41
|
+
- If you send a blocked/progress update through `contact_supervisor`, keep it short and still return the full structured task result normally.
|
|
42
|
+
- Do not send routine completion handoffs. Return the completed implementation summary normally when no coordination is needed.
|
|
43
43
|
|
|
44
44
|
When running in a chain, expect instructions about:
|
|
45
45
|
- which files to read first
|
package/package.json
CHANGED
|
@@ -42,7 +42,7 @@ Ask each builder to produce a compact handoff file with:
|
|
|
42
42
|
- constraints and invariants;
|
|
43
43
|
- risks and unknowns;
|
|
44
44
|
- validation commands or next-best checks;
|
|
45
|
-
- a `meta-prompt` section for the next planner or
|
|
45
|
+
- a `meta-prompt` section for the next planner or role subagent.
|
|
46
46
|
|
|
47
47
|
After the builders return, synthesize their outputs into:
|
|
48
48
|
- the most important context the next agent needs;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
description: Parallel research/context builders into an implementation handoff plan
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
Use parallel subagents to understand the request, compare any external references, inspect the local codebase, and produce a grounded implementation handoff plan with a final
|
|
5
|
+
Use parallel subagents to understand the request, compare any external references, inspect the local codebase, and produce a grounded implementation handoff plan with a final implementation-ready meta-prompt.
|
|
6
6
|
|
|
7
7
|
Primary request, target, or focus:
|
|
8
8
|
|
|
@@ -48,7 +48,7 @@ Implementation-strategy context-builder, when used:
|
|
|
48
48
|
Final synthesis context-builder:
|
|
49
49
|
- Read the parallel outputs and produce one concise handoff plan.
|
|
50
50
|
- Include what the feature/change should do, what the external reference teaches, what the local codebase implies, the recommended approach, likely files to change, constraints, non-goals, validation, risks, and unresolved questions.
|
|
51
|
-
- End with a compact
|
|
51
|
+
- End with a compact implementation-ready meta-prompt for the next worker/planner.
|
|
52
52
|
|
|
53
53
|
After the chain returns, synthesize the result for me with:
|
|
54
54
|
- the recommended approach;
|
|
@@ -44,7 +44,7 @@ Packaged prompt shortcuts are also available for repeatable workflows. Treat the
|
|
|
44
44
|
- `/parallel-review` — fresh-context reviewers with distinct review angles, then synthesis
|
|
45
45
|
- `/parallel-research` — combine `researcher` and `scout` for external evidence plus local code context
|
|
46
46
|
- `/parallel-context-build` — parallel `context-builder` passes that produce planning handoff context and meta-prompts
|
|
47
|
-
- `/parallel-handoff-plan` — external-reference research plus local `context-builder` passes, followed by a synthesis handoff plan and
|
|
47
|
+
- `/parallel-handoff-plan` — external-reference research plus local `context-builder` passes, followed by a synthesis handoff plan and implementation-ready meta-prompt
|
|
48
48
|
- `/gather-context-and-clarify` — scout/research first, then ask the user clarifying questions with `interview`
|
|
49
49
|
- `/parallel-cleanup` — two fresh-context reviewers (deslop + verbosity passes) for an adversarial cleanup review of the current diff
|
|
50
50
|
|
|
@@ -81,7 +81,7 @@ subagent({
|
|
|
81
81
|
|
|
82
82
|
### Parallel handoff-plan technique
|
|
83
83
|
|
|
84
|
-
Use this when the user needs a solution brief or implementation-ready handoff from an external reference plus local code context, such as “study this library behavior, inspect our codebase, then produce a
|
|
84
|
+
Use this when the user needs a solution brief or implementation-ready handoff from an external reference plus local code context, such as “study this library behavior, inspect our codebase, then produce a worker prompt.” Run a chain with a first parallel group and a second synthesis `context-builder` step. The first group usually includes `researcher` for external projects/docs/prompt guidance and `context-builder` for local code context; add a second `context-builder` for implementation strategy only when the scope is large enough to benefit. Use distinct output paths under `handoff/`, then have the synthesis `context-builder` read those outputs and write `handoff/final-handoff-plan.md` with the recommended approach, likely files, constraints, non-goals, validation, risks, unresolved questions, and final compact implementation-ready meta-prompt.
|
|
85
85
|
|
|
86
86
|
Example shape:
|
|
87
87
|
|
|
@@ -93,7 +93,7 @@ subagent({
|
|
|
93
93
|
{ agent: "context-builder", task: "Build local codebase context for: ...", output: "handoff/local-context.md" },
|
|
94
94
|
{ agent: "context-builder", task: "Compare evidence and propose implementation strategy for: ...", output: "handoff/implementation-strategy.md" }
|
|
95
95
|
] },
|
|
96
|
-
{ agent: "context-builder", task: "Read {previous} and synthesize the final handoff plan and
|
|
96
|
+
{ agent: "context-builder", task: "Read {previous} and synthesize the final handoff plan and implementation-ready meta-prompt.", output: "handoff/final-handoff-plan.md" }
|
|
97
97
|
],
|
|
98
98
|
context: "fresh"
|
|
99
99
|
})
|
|
@@ -114,16 +114,16 @@ and user/project agents override builtins with the same name.
|
|
|
114
114
|
|
|
115
115
|
| Agent | Purpose | Model | Typical output / role |
|
|
116
116
|
|-------|---------|-------|------------------------|
|
|
117
|
-
| `scout` | Fast codebase recon |
|
|
118
|
-
| `planner` | Creates implementation plans |
|
|
119
|
-
| `worker` | Implementation and approved oracle handoffs |
|
|
120
|
-
| `reviewer` | Review-and-fix specialist |
|
|
121
|
-
| `context-builder` | Requirements/codebase handoff builder |
|
|
122
|
-
| `researcher` | Web research brief generator |
|
|
123
|
-
| `delegate` | Lightweight generic delegate | inherits
|
|
124
|
-
| `oracle` | Decision-consistency advisory review |
|
|
117
|
+
| `scout` | Fast codebase recon | inherits default | Writes `context.md` handoff material |
|
|
118
|
+
| `planner` | Creates implementation plans | inherits default | Writes `plan.md` |
|
|
119
|
+
| `worker` | Implementation and approved oracle handoffs | inherits default | Single-writer implementation with decision escalation |
|
|
120
|
+
| `reviewer` | Review-and-fix specialist | inherits default | Can edit/fix reviewed code |
|
|
121
|
+
| `context-builder` | Requirements/codebase handoff builder | inherits default | Writes structured context files |
|
|
122
|
+
| `researcher` | Web research brief generator | inherits default | Writes `research.md` |
|
|
123
|
+
| `delegate` | Lightweight generic delegate | inherits default | No fixed output; generic delegated work |
|
|
124
|
+
| `oracle` | Decision-consistency advisory review | inherits default | Advisory review, intercom coordination |
|
|
125
125
|
|
|
126
|
-
Override builtin defaults before copying full agent files when a small tweak is enough.
|
|
126
|
+
Builtin agents inherit the current Pi default model unless a run, user setting, or project setting overrides `model`. Override builtin defaults before copying full agent files when a small tweak is enough.
|
|
127
127
|
|
|
128
128
|
For one run, use inline config:
|
|
129
129
|
|
|
@@ -133,11 +133,11 @@ For one run, use inline config:
|
|
|
133
133
|
|
|
134
134
|
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.
|
|
135
135
|
|
|
136
|
-
## Prompting
|
|
136
|
+
## Prompting role subagents
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
Builtin role agents inherit the current Pi default model unless you override them. When launching them, write the task prompt as a compact contract, not a long procedural script. Define the destination and let the role choose the efficient path.
|
|
139
139
|
|
|
140
|
-
A strong
|
|
140
|
+
A strong subagent prompt usually includes:
|
|
141
141
|
- **Goal**: the concrete outcome the child should produce.
|
|
142
142
|
- **Context/evidence**: relevant plan paths, files, diffs, decisions, or user constraints already approved.
|
|
143
143
|
- **Success criteria**: what must be true before the child can finish.
|
|
@@ -183,11 +183,10 @@ Agent files can live in:
|
|
|
183
183
|
- legacy `.agents/**/*.md` — still read for compatibility, but `.pi/agents/` wins on conflicts
|
|
184
184
|
|
|
185
185
|
Chains live in:
|
|
186
|
-
- `~/.pi/agent/
|
|
187
|
-
- `.pi/
|
|
188
|
-
- legacy `.agents/**/*.chain.md`
|
|
186
|
+
- `~/.pi/agent/chains/**/*.chain.md` — user scope
|
|
187
|
+
- `.pi/chains/**/*.chain.md` — project scope
|
|
189
188
|
|
|
190
|
-
Discovery is recursive. `.chain.md` files
|
|
189
|
+
Discovery is recursive. `.chain.md` files do not define agents. Agents and chains can set optional frontmatter `package: code-analysis`; `name: scout` plus `package: code-analysis` registers as runtime name `code-analysis.scout` while serialization keeps `name` and `package` separate.
|
|
191
190
|
|
|
192
191
|
Precedence is by parsed runtime name:
|
|
193
192
|
1. project scope
|
|
@@ -263,7 +262,9 @@ without forcing each step to rediscover everything.
|
|
|
263
262
|
|
|
264
263
|
### Async/background
|
|
265
264
|
|
|
266
|
-
Use async mode whenever the parent agent should keep working while a child runs. A normal foreground `subagent(...)` call blocks the parent until the child completes; it is appropriate when the next parent step depends on the child result. If you say you will "ask a reviewer while I continue auditing" or otherwise run local work in parallel with a child, launch with `async: true`.
|
|
265
|
+
Use async mode whenever the parent agent should keep working while a child runs. A normal foreground `subagent(...)` call blocks the parent until the child completes; it is appropriate when the next parent step depends on the child result. If you say you will "ask a reviewer while I continue auditing" or otherwise run local work in parallel with a child, launch with `async: true`.
|
|
266
|
+
|
|
267
|
+
Do not end your turn immediately after launching an async child if you promised to keep working. Continue the local inspection or other independent work, then check the async run when its result is needed. If there is no independent work left and you would only be running `sleep` or status polling commands to wait, end your turn instead. Pi will deliver the async completion when it arrives.
|
|
267
268
|
|
|
268
269
|
```typescript
|
|
269
270
|
subagent({
|
|
@@ -375,7 +376,7 @@ prefer a single-writer pattern instead.
|
|
|
375
376
|
The intended oracle loop is:
|
|
376
377
|
1. the main agent forks to `oracle`
|
|
377
378
|
2. `oracle` reviews direction, drift, assumptions, and risks
|
|
378
|
-
3. `oracle` can coordinate back
|
|
379
|
+
3. `oracle` can coordinate back through `contact_supervisor` when the bridge injects it
|
|
379
380
|
4. the main agent decides what direction to approve
|
|
380
381
|
5. only then should `worker` implement
|
|
381
382
|
|
|
@@ -401,25 +402,28 @@ history as a baseline contract.
|
|
|
401
402
|
|
|
402
403
|
`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.
|
|
403
404
|
|
|
404
|
-
Most agents should not call `intercom` directly unless bridge instructions provide a target. Do not invent a target.
|
|
405
|
+
Most agents should not call generic `intercom` directly unless bridge instructions provide a target and `contact_supervisor` is unavailable. Do not invent a target. Prefer the tool from the injected bridge instructions.
|
|
405
406
|
|
|
406
|
-
Use `
|
|
407
|
+
Use `contact_supervisor` with `reason: "need_decision"` when:
|
|
407
408
|
- a subagent is blocked on a decision
|
|
408
409
|
- a child needs clarification instead of guessing
|
|
409
|
-
-
|
|
410
|
-
|
|
410
|
+
- an approval, product, API, or scope choice is required before continuing safely
|
|
411
|
+
|
|
412
|
+
Use `contact_supervisor` with `reason: "progress_update"` when:
|
|
413
|
+
- a child is explicitly asked for progress
|
|
414
|
+
- a meaningful discovery changes the plan
|
|
415
|
+
- a long-running child needs to report a blocked/progress checkpoint without waiting for normal tool return flow
|
|
411
416
|
|
|
412
417
|
Message conventions:
|
|
413
|
-
- `
|
|
414
|
-
- `
|
|
418
|
+
- `reason: "need_decision"` waits for the parent reply and returns it to the child.
|
|
419
|
+
- `reason: "progress_update"` is non-blocking and should stay concise.
|
|
415
420
|
- 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.
|
|
416
421
|
|
|
417
|
-
If
|
|
422
|
+
If bridge instructions provide the child-facing tool, a child can ask:
|
|
418
423
|
|
|
419
424
|
```typescript
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
to: "<bridge-provided-target>",
|
|
425
|
+
contact_supervisor({
|
|
426
|
+
reason: "need_decision",
|
|
423
427
|
message: "Should I optimize for readability or performance here?"
|
|
424
428
|
})
|
|
425
429
|
```
|
|
@@ -607,7 +611,7 @@ When the user approves launching a subagent to carry out a plan or workflow, tre
|
|
|
607
611
|
- `/parallel-review` maps to: launch fresh-context `reviewer` agents with distinct review angles; synthesize the feedback before applying anything.
|
|
608
612
|
- `/parallel-research` maps to: combine local `scout` context with external `researcher` evidence when current docs, ecosystem behavior, or API details matter.
|
|
609
613
|
- `/parallel-context-build` maps to: run a chain-mode parallel group of `context-builder` agents with distinct temp output paths, then synthesize their context and meta-prompt sections.
|
|
610
|
-
- `/parallel-handoff-plan` maps to: run external `researcher` plus local/strategy `context-builder` passes, then a synthesis `context-builder` that writes an implementation handoff plan and
|
|
614
|
+
- `/parallel-handoff-plan` maps to: run external `researcher` plus local/strategy `context-builder` passes, then a synthesis `context-builder` that writes an implementation handoff plan and implementation-ready meta-prompt.
|
|
611
615
|
- `/parallel-cleanup` maps to: use review-only cleanup passes after implementation, especially for simplicity, verbosity, and redundant tests.
|
|
612
616
|
|
|
613
617
|
For feature work, use this sequence as scaffolding for parent-agent behavior:
|
|
@@ -459,7 +459,9 @@ export function handleCreate(params: ManagementParams, ctx: ManagementContext):
|
|
|
459
459
|
const scope = scopeRaw as ManagementScope;
|
|
460
460
|
const isChain = hasKey(cfg, "steps");
|
|
461
461
|
const d = discoverAgentsAll(ctx.cwd);
|
|
462
|
-
const targetDir =
|
|
462
|
+
const targetDir = isChain
|
|
463
|
+
? scope === "user" ? d.userChainDir : d.projectChainDir ?? path.join(ctx.cwd, ".pi", "chains")
|
|
464
|
+
: scope === "user" ? d.userDir : d.projectDir ?? path.join(ctx.cwd, ".pi", "agents");
|
|
463
465
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
464
466
|
if (nameExistsInScope(ctx.cwd, scope, runtimeName)) return result(`Name '${runtimeName}' already exists in ${scope} scope. Use update instead.`, true);
|
|
465
467
|
const targetPath = path.join(targetDir, isChain ? `${runtimeName}.chain.md` : `${runtimeName}.md`);
|