@d3ara1n/pi-subagent 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -177,7 +177,11 @@ Delegate tasks that would generate many tool calls or verbose output to keep you
177
177
 
178
178
  ## Background Delegation
179
179
 
180
- Foreground and background delegation share one async run engine — foreground is simply background-but-blocking. With `background: true`, `subagent_delegate` returns immediately with a run id, and two companion tools collect the outcome:
180
+ Three execution properties, kept separate:
181
+
182
+ - **Foreground** (default): the call blocks until the run finishes and returns the final output directly. (Under the hood foreground and background share one async run engine — foreground is simply background-but-blocking.)
183
+ - **Parallel**: multiple `subagent_delegate` calls in one turn run concurrently — foreground and background alike, no special flag.
184
+ - **Background** (`background: true`): non-blocking — `subagent_delegate` returns immediately with a run id. Use it when you have your own work to do (or a discussion with the user to continue) while the run executes; two companion tools collect the outcome:
181
185
 
182
186
  | Tool | Purpose | Returns to the model |
183
187
  |------|---------|---------------------|
@@ -204,6 +208,7 @@ Typical flow:
204
208
 
205
209
  Semantics worth knowing:
206
210
 
211
+ - **Results are pull-only.** Nothing delivers them to the model — no completion event, no notification, nothing wakes the model up. The model owns the collection point: `subagent_wait`, then `subagent_check` each run. The inbox reminder (below) lists unclaimed runs on every request, but it never pushes results.
207
212
  - **Background runs survive turn cancellation** and are unaffected by a cancelled `subagent_wait` — cancelling the wait never cancels the runs; call `subagent_wait` or `subagent_check` again later.
208
213
  - **Read-once collection:** `subagent_check` on a terminal run returns the result and frees it — the output now lives in the conversation history, and only a lightweight tombstone stays in the registry (`/subagent:status` lists it under "Collected"). Re-checking a collected id explains that its result is already in the history.
209
214
  - **Inbox reminder:** every LLM call carries a `[background subagent runs]` system reminder listing the unclaimed runs (queued, running, and finished-but-unchecked alike), injected at a cache-stable head position. Runs missing from the list were already collected — so a finished run the model forgot to check keeps surfacing until it does.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d3ara1n/pi-subagent",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "type": "module",
5
5
  "description": "Role-based subagent orchestration for pi — delegates tasks to specialized pi child processes with configurable model roles",
6
6
  "main": "src/index.ts",
package/src/index.ts CHANGED
@@ -149,13 +149,16 @@ export default function subagentExtension(pi: ExtensionAPI) {
149
149
  "",
150
150
  ...exampleLines,
151
151
  "",
152
- "For multiple independent substantial tasks, emit multiple subagent_delegate calls in one turn — they run in parallel.",
152
+ "EXECUTION MODES:",
153
153
  "",
154
- "BACKGROUND DELEGATION start runs now, collect results later:",
154
+ "- Foreground (default): the call blocks until the run finishes and returns the final output directly.",
155
+ "- Parallel: multiple subagent_delegate calls at the same time run concurrently — foreground and background alike, no special flag.",
156
+ "- Background (background: true): non-blocking — returns an id immediately so you can do your own work while the run executes.",
155
157
  "",
156
- "- Typical flow: subagent_delegate(background: true) ×N → keep working → subagent_wait(ids) to block until every listed run finishes (omit ids to wait for all) → subagent_check(id) for each finished run.",
157
- "- A terminal check collects the run — the output is returned once and the run leaves the registry. Mid-run checks are free: peek at progress as often as you like; only terminal checks collect.",
158
- "- Every LLM call carries a [background subagent runs] reminder listing your unclaimed runs (queued, running, and finished-but-unchecked alike). Runs missing from that list were already collected.",
158
+ "BACKGROUND DELEGATION:",
159
+ "",
160
+ "- Use it only when you have your own work this turn (including an ongoing discussion with the user) while the run executes; otherwise let the call block and return the result directly.",
161
+ "- Results are pull-only — no completion event, no notification, nothing wakes you. Dispatching means owning the collection point: finish your own work, then subagent_check(id) for each result. Use subagent_wait(ids) to block until the run finish.",
159
162
  "- Background delegation works only in the top-level session.",
160
163
  );
161
164
  }
@@ -267,7 +270,7 @@ export default function subagentExtension(pi: ExtensionAPI) {
267
270
  background: Type.Optional(
268
271
  Type.Boolean({
269
272
  description:
270
- "Run asynchronously: returns an id (sub-N) immediately instead of blocking. The run survives turn cancellation.",
273
+ "Non-blocking: returns an id immediately so you can do your own work (or keep discussing with the user) while the run executes — not for parallelism (several foreground calls in one turn already run concurrently). Results are pull-only: nothing delivers them to you or wakes you; fetch with subagent_wait/subagent_check when your own work is done. If the next thing you'd do is wait for the result, omit this and let the call block.",
271
274
  }),
272
275
  ),
273
276
  cwd: Type.Optional(Type.String({ description: "Working directory (defaults to current)" })),
@@ -111,9 +111,9 @@ describe("buildInboxReminder", () => {
111
111
  assert.ok(text.includes(`"${"x".repeat(70)}..."`));
112
112
  });
113
113
 
114
- test("header explains collection semantics", () => {
114
+ test("header explains pull-only collection semantics", () => {
115
115
  const text = buildInboxReminder([entry({ id: "sub-1", state: "running" })])!;
116
- assert.match(text, /^\[background subagent runs — subagent_check claims/);
116
+ assert.match(text, /^\[background subagent runs — results are pull-only/);
117
117
  assert.match(text, /already collected\]/);
118
118
  });
119
119
  });
package/src/reminder.ts CHANGED
@@ -28,7 +28,7 @@ export interface InboxEntry {
28
28
  }
29
29
 
30
30
  const INBOX_HEADER =
31
- "[background subagent runs — subagent_check claims a terminal run's output and removes it from this list; runs missing here were already collected]";
31
+ "[background subagent runs — results are pull-only: nothing notifies you. subagent_wait, then subagent_check to collect each run; a terminal check removes it from this list; runs missing here were already collected]";
32
32
 
33
33
  /** `42s`, `3m12s`, `4m` — whole seconds, no live clocks. */
34
34
  function formatDuration(totalSec: number): string {