pi-subagents 0.21.4 → 0.22.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 +23 -0
- package/README.md +12 -11
- 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 +3 -2
- package/prompts/parallel-context-build.md +1 -1
- package/prompts/parallel-handoff-plan.md +2 -2
- package/skills/pi-subagents/SKILL.md +30 -27
- package/src/extension/index.ts +4 -1
- package/src/intercom/intercom-bridge.ts +10 -8
- package/src/intercom/result-intercom.ts +4 -3
- package/src/manager-ui/agent-manager-edit.ts +43 -19
- package/src/manager-ui/agent-manager.ts +5 -2
- package/src/runs/background/async-execution.ts +16 -10
- package/src/runs/background/async-job-tracker.ts +12 -19
- package/src/runs/background/async-resume.ts +1 -0
- package/src/runs/background/async-status.ts +35 -49
- package/src/runs/background/parallel-groups.ts +45 -0
- package/src/runs/background/result-watcher.ts +2 -2
- package/src/runs/background/run-status.ts +26 -7
- package/src/runs/background/stale-run-reconciler.ts +15 -2
- package/src/runs/background/subagent-runner.ts +12 -3
- package/src/runs/foreground/chain-clarify.ts +35 -30
- package/src/runs/foreground/chain-execution.ts +9 -6
- package/src/runs/foreground/execution.ts +4 -0
- package/src/runs/foreground/subagent-executor.ts +18 -30
- 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/session-identity.ts +10 -0
- package/src/shared/types.ts +14 -5
- package/src/slash/slash-commands.ts +8 -7
- package/src/tui/render.ts +67 -2
- package/src/tui/subagents-status.ts +129 -15
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.22.0] - 2026-05-02
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- 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.
|
|
9
|
+
- 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.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- 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.
|
|
13
|
+
- Hide unsupported thinking levels in subagent clarify and agent-manager pickers when Pi exposes per-model thinking metadata.
|
|
14
|
+
- Updated builtin agent prompts, README, and bundled skill docs to prefer `contact_supervisor` for blocked decisions and avoid child-side routine completion handoffs.
|
|
15
|
+
- Teach reviewer agents that repo-local `progress.md` files are intentional scratch files that should remain untracked and covered by `.gitignore`.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- Added regression coverage for supervisor metadata propagation into child process environments.
|
|
19
|
+
|
|
20
|
+
## [0.21.5] - 2026-05-02
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- Show top-level async parallel runs as `parallel` instead of `chain`, with foreground-style running/done wording in widgets and status output, and group running async chain detail by chain step.
|
|
24
|
+
- Scoped `/subagents-status` to async runs launched from the current pi session instead of showing prior or unrelated sessions.
|
|
25
|
+
- Declared the Pi TUI package as a direct dev dependency and added a manifest guard so CI installs do not rely on transitive optional peer dependencies for tests.
|
|
26
|
+
- Made prompt-runtime extension path assertions portable on Windows.
|
|
27
|
+
|
|
5
28
|
## [0.21.4] - 2026-05-01
|
|
6
29
|
|
|
7
30
|
### Added
|
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
|
{
|
|
@@ -150,12 +150,14 @@ Use `~/.pi/agent/settings.json` for a user override or `.pi/settings.json` for a
|
|
|
150
150
|
|
|
151
151
|
Foreground runs stream progress in the conversation while they run.
|
|
152
152
|
|
|
153
|
-
Background runs keep working after control returns to you. They show completion notifications and can be inspected with:
|
|
153
|
+
Background runs keep working after control returns to you. They show a compact async widget, send completion notifications, and can be inspected with:
|
|
154
154
|
|
|
155
155
|
```text
|
|
156
156
|
/subagents-status
|
|
157
157
|
```
|
|
158
158
|
|
|
159
|
+
The status view shows active and recent runs for the current Pi session. Parallel background runs are shown as parallel work, with per-agent progress instead of fake chain steps. Chains with parallel groups keep their grouped shape in both progress and results views, so failed or paused agents stay visible next to completed ones.
|
|
160
|
+
|
|
159
161
|
You can also ask naturally:
|
|
160
162
|
|
|
161
163
|
```text
|
|
@@ -221,10 +223,9 @@ Run this implementation in the background. If the worker gets blocked or needs a
|
|
|
221
223
|
Ask oracle to review this plan. If it sees a decision I need to make, have it ask me instead of assuming.
|
|
222
224
|
```
|
|
223
225
|
|
|
224
|
-
The child can use
|
|
226
|
+
The child can use one dedicated coordination tool:
|
|
225
227
|
|
|
226
|
-
- `
|
|
227
|
-
- `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.
|
|
228
229
|
|
|
229
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.
|
|
230
231
|
|
|
@@ -402,7 +403,7 @@ Agent locations, lowest to highest priority:
|
|
|
402
403
|
|
|
403
404
|
Project discovery also reads legacy `.agents/**/*.md` files. Nested subdirectories are discovered recursively. `.chain.md` files are treated as chains, not 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.
|
|
404
405
|
|
|
405
|
-
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.
|
|
406
|
+
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.
|
|
406
407
|
|
|
407
408
|
The `researcher` builtin uses `web_search`, `fetch_content`, and `get_search_content`; those require [pi-web-access](https://github.com/nicobailon/pi-web-access):
|
|
408
409
|
|
|
@@ -631,7 +632,7 @@ The package bundles a `pi-subagents` skill that is automatically available to th
|
|
|
631
632
|
What the bundled skill covers:
|
|
632
633
|
- **Delegation patterns**: when to launch which agent, whether to use single, parallel, chain, or async mode, and whether to use fresh or forked context
|
|
633
634
|
- **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
|
|
634
|
-
- **
|
|
635
|
+
- **Role-agent prompting guidance**: compact contract prompts instead of long scripts, what to include in role-specific meta prompts, and retrieval budgets for researchers
|
|
635
636
|
- **Safety boundaries**: child agents must not run subagents, must not invent intercom targets, and must escalate unapproved decisions
|
|
636
637
|
- **Intercom conventions**: when to ask vs send, and how parent-side result delivery works with `pi-intercom`
|
|
637
638
|
- **Control and diagnostics**: attention signals, soft interrupts, status, and the `doctor` action
|
|
@@ -885,7 +886,7 @@ Sets the `/agents` list shortcut for opening the new agent/chain template picker
|
|
|
885
886
|
}
|
|
886
887
|
```
|
|
887
888
|
|
|
888
|
-
Controls whether subagents receive runtime intercom coordination instructions and whether `intercom`
|
|
889
|
+
Controls whether subagents receive runtime intercom coordination instructions and whether `intercom` and `contact_supervisor` are auto-added to their tool allowlist when needed.
|
|
889
890
|
|
|
890
891
|
Fields:
|
|
891
892
|
|
|
@@ -894,7 +895,7 @@ Fields:
|
|
|
894
895
|
|
|
895
896
|
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.
|
|
896
897
|
|
|
897
|
-
The default injected guidance tells children to use
|
|
898
|
+
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.
|
|
898
899
|
|
|
899
900
|
### `worktreeSetupHook`
|
|
900
901
|
|
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-subagents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Pi extension for delegating tasks to subagents with chains, parallel execution, and TUI clarification",
|
|
5
5
|
"author": "Nico Bailon",
|
|
6
6
|
"license": "MIT",
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@mariozechner/pi-agent-core": "^0.65.0",
|
|
79
79
|
"@mariozechner/pi-ai": "^0.65.0",
|
|
80
|
-
"@mariozechner/pi-coding-agent": "^0.65.0"
|
|
80
|
+
"@mariozechner/pi-coding-agent": "^0.65.0",
|
|
81
|
+
"@mariozechner/pi-tui": "^0.65.2"
|
|
81
82
|
}
|
|
82
83
|
}
|
|
@@ -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.
|
|
@@ -375,7 +375,7 @@ prefer a single-writer pattern instead.
|
|
|
375
375
|
The intended oracle loop is:
|
|
376
376
|
1. the main agent forks to `oracle`
|
|
377
377
|
2. `oracle` reviews direction, drift, assumptions, and risks
|
|
378
|
-
3. `oracle` can coordinate back
|
|
378
|
+
3. `oracle` can coordinate back through `contact_supervisor` when the bridge injects it
|
|
379
379
|
4. the main agent decides what direction to approve
|
|
380
380
|
5. only then should `worker` implement
|
|
381
381
|
|
|
@@ -401,25 +401,28 @@ history as a baseline contract.
|
|
|
401
401
|
|
|
402
402
|
`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
403
|
|
|
404
|
-
Most agents should not call `intercom` directly unless bridge instructions provide a target. Do not invent a target.
|
|
404
|
+
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
405
|
|
|
406
|
-
Use `
|
|
406
|
+
Use `contact_supervisor` with `reason: "need_decision"` when:
|
|
407
407
|
- a subagent is blocked on a decision
|
|
408
408
|
- a child needs clarification instead of guessing
|
|
409
|
-
-
|
|
410
|
-
|
|
409
|
+
- an approval, product, API, or scope choice is required before continuing safely
|
|
410
|
+
|
|
411
|
+
Use `contact_supervisor` with `reason: "progress_update"` when:
|
|
412
|
+
- a child is explicitly asked for progress
|
|
413
|
+
- a meaningful discovery changes the plan
|
|
414
|
+
- a long-running child needs to report a blocked/progress checkpoint without waiting for normal tool return flow
|
|
411
415
|
|
|
412
416
|
Message conventions:
|
|
413
|
-
- `
|
|
414
|
-
- `
|
|
417
|
+
- `reason: "need_decision"` waits for the parent reply and returns it to the child.
|
|
418
|
+
- `reason: "progress_update"` is non-blocking and should stay concise.
|
|
415
419
|
- 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
420
|
|
|
417
|
-
If
|
|
421
|
+
If bridge instructions provide the child-facing tool, a child can ask:
|
|
418
422
|
|
|
419
423
|
```typescript
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
to: "<bridge-provided-target>",
|
|
424
|
+
contact_supervisor({
|
|
425
|
+
reason: "need_decision",
|
|
423
426
|
message: "Should I optimize for readability or performance here?"
|
|
424
427
|
})
|
|
425
428
|
```
|
|
@@ -607,7 +610,7 @@ When the user approves launching a subagent to carry out a plan or workflow, tre
|
|
|
607
610
|
- `/parallel-review` maps to: launch fresh-context `reviewer` agents with distinct review angles; synthesize the feedback before applying anything.
|
|
608
611
|
- `/parallel-research` maps to: combine local `scout` context with external `researcher` evidence when current docs, ecosystem behavior, or API details matter.
|
|
609
612
|
- `/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
|
|
613
|
+
- `/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
614
|
- `/parallel-cleanup` maps to: use review-only cleanup passes after implementation, especially for simplicity, verbosity, and redundant tests.
|
|
612
615
|
|
|
613
616
|
For feature work, use this sequence as scaffolding for parent-agent behavior:
|
package/src/extension/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { type ExtensionAPI, type ExtensionContext, type ToolDefinition } from "@
|
|
|
20
20
|
import { Box, Container, Spacer, Text, truncateToWidth, visibleWidth, wrapTextWithAnsi, type Component } from "@mariozechner/pi-tui";
|
|
21
21
|
import { discoverAgents } from "../agents/agents.ts";
|
|
22
22
|
import { cleanupAllArtifactDirs, cleanupOldArtifacts, getArtifactsDir } from "../shared/artifacts.ts";
|
|
23
|
+
import { resolveCurrentSessionId } from "../shared/session-identity.ts";
|
|
23
24
|
import { cleanupOldChainDirs } from "../shared/settings.ts";
|
|
24
25
|
import { renderWidget, renderSubagentResult, stopResultAnimations, stopWidgetAnimation, syncResultAnimation } from "../tui/render.ts";
|
|
25
26
|
import { SubagentParams } from "./schemas.ts";
|
|
@@ -271,6 +272,7 @@ export default function registerSubagentExtension(pi: ExtensionAPI): void {
|
|
|
271
272
|
const runtimeCleanup = () => {
|
|
272
273
|
stopWidgetAnimation();
|
|
273
274
|
stopResultAnimations();
|
|
275
|
+
stopResultWatcher();
|
|
274
276
|
clearPendingForegroundControlNotices(state);
|
|
275
277
|
if (state.poller) {
|
|
276
278
|
clearInterval(state.poller);
|
|
@@ -523,12 +525,13 @@ DIAGNOSTICS:
|
|
|
523
525
|
|
|
524
526
|
const resetSessionState = (ctx: ExtensionContext) => {
|
|
525
527
|
state.baseCwd = ctx.cwd;
|
|
526
|
-
state.currentSessionId = ctx.sessionManager
|
|
528
|
+
state.currentSessionId = resolveCurrentSessionId(ctx.sessionManager);
|
|
527
529
|
state.lastUiContext = ctx;
|
|
528
530
|
cleanupSessionArtifacts(ctx);
|
|
529
531
|
clearPendingForegroundControlNotices(state);
|
|
530
532
|
resetJobs(ctx);
|
|
531
533
|
restoreSlashFinalSnapshots(ctx.sessionManager.getEntries());
|
|
534
|
+
primeExistingResults();
|
|
532
535
|
};
|
|
533
536
|
|
|
534
537
|
pi.on("session_start", (_event, ctx) => {
|
|
@@ -18,14 +18,15 @@ function defaultSubagentConfigDir(): string {
|
|
|
18
18
|
|
|
19
19
|
const DEFAULT_INTERCOM_TARGET_PREFIX = "subagent-chat";
|
|
20
20
|
export const INTERCOM_BRIDGE_MARKER = "Intercom orchestration channel:";
|
|
21
|
-
const DEFAULT_INTERCOM_BRIDGE_TEMPLATE = `The inherited thread is reference-only. Do not continue that conversation or send questions, status updates, or completion handoffs to the
|
|
21
|
+
const DEFAULT_INTERCOM_BRIDGE_TEMPLATE = `The inherited thread is reference-only. Do not continue that conversation or send questions, status updates, or completion handoffs to the supervisor in normal assistant text.
|
|
22
22
|
|
|
23
|
-
Use
|
|
24
|
-
- Need a decision or
|
|
25
|
-
- After
|
|
26
|
-
-
|
|
23
|
+
Use contact_supervisor first. It resolves the supervisor session "{orchestratorTarget}" and run metadata automatically.
|
|
24
|
+
- Need a decision, blocked, approval, or product/API/scope ambiguity: contact_supervisor({ reason: "need_decision", message: "<question>" })
|
|
25
|
+
- After contact_supervisor with reason "need_decision", stay alive and continue only after the reply arrives. Do not finish your final response with a choose-one question.
|
|
26
|
+
- Meaningful progress or unexpected discoveries that change the plan: contact_supervisor({ reason: "progress_update", message: "UPDATE: <summary>" })
|
|
27
|
+
- Generic intercom is lower-level plumbing/fallback only: intercom({ action: "ask", to: "{orchestratorTarget}", message: "<question>" })
|
|
27
28
|
|
|
28
|
-
Do not
|
|
29
|
+
Do not use contact_supervisor or intercom for routine completion handoffs. If no coordination is needed, return a focused task result.`;
|
|
29
30
|
|
|
30
31
|
export interface IntercomBridgeState {
|
|
31
32
|
active: boolean;
|
|
@@ -228,8 +229,9 @@ export function applyIntercomBridgeToAgent(agent: AgentConfig, bridge: IntercomB
|
|
|
228
229
|
if (!bridge.active || !bridge.orchestratorTarget) return agent;
|
|
229
230
|
if (!extensionSandboxAllowsIntercom(agent.extensions, bridge.extensionDir)) return agent;
|
|
230
231
|
|
|
231
|
-
const
|
|
232
|
-
|
|
232
|
+
const bridgeTools = ["intercom", "contact_supervisor"];
|
|
233
|
+
const tools = agent.tools
|
|
234
|
+
? [...agent.tools, ...bridgeTools.filter((tool) => !agent.tools?.includes(tool))]
|
|
233
235
|
: agent.tools;
|
|
234
236
|
const instruction = bridge.instruction;
|
|
235
237
|
const trimmedPrompt = agent.systemPrompt?.trim() || "";
|