@ferris1225/pi-subagents 7.0.5 → 7.0.6

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 7.0.6
4
+
5
+ - Show Escape cancellation progress and per-run statistics in the terminal before
6
+ the next user message. Finished workers report pending integration and retain
7
+ normal result delivery.
8
+ - Gate staged commits, pull requests, and publishing on unused-code checks.
9
+ The main-agent prompt delegates a dead-code review before an authorized push.
10
+ Clean up confirmed unused code before committing.
11
+
3
12
  ## 7.0.5
4
13
 
5
14
  - Shorten the main and child prompts with clear routing, brief, and review steps.
package/README.md CHANGED
@@ -109,6 +109,10 @@ subagent nor main repeats or edits that scope. Questions and review-only request
109
109
  implementation. Explicit requests to work in main take precedence. Parallel workers require independent
110
110
  scope and disjoint write ownership; a fix and its regression tests share an owner.
111
111
 
112
+ For an authorized push of code changes, main proactively delegates a read-only
113
+ audit of the diff. It removes confirmed dead code within the task's scope and
114
+ runs the project's checks before committing and pushing.
115
+
112
116
  There are two roles, each using its own model/thinking settings:
113
117
 
114
118
  | Scope | Tool parameter | Access |
@@ -201,13 +205,15 @@ worktree. Integration applies only its delta, is serialized per repository,
201
205
  and preserves the caller's index, branch, and HEAD. Failures retain recovery
202
206
  artifacts. Worktrees isolate Git changes, not permissions.
203
207
 
204
- Escape cancels unfinished workers without waking main. Main receives a cancellation
205
- receipt on the next user turn. A worker whose child already finished and is only
206
- integrating its worktree is not cancelled: it settles normally, and its real
207
- result, like any result already queued for delivery, arrives on the next user
208
- turn. `subagent_stop({ all: true })` also leaves such runs alone. Tree navigation,
209
- new/resume/fork/reload, and shutdown stop old work; interrupted evidence remains
210
- available for recovery.
208
+ Escape stops unfinished workers when it cancels a parent turn. Pi's terminal
209
+ shows which runs are stopping, then saves their elapsed time, model usage, and
210
+ worktree status in the transcript as available. A finished worker that is still
211
+ applying its worktree continues integrating and reports progress.
212
+ `subagent_stop({ all: true })` also lets those integrations finish. Main receives
213
+ the cancellation receipt and any deferred results the next time you send a
214
+ message. Tree navigation,
215
+ new/resume/fork/reload, and shutdown stop old work and retain interrupted evidence
216
+ for recovery.
211
217
 
212
218
  The task widget shows status, elapsed time, model, thinking, tokens, and worktree
213
219
  state in at most ten lines. Independent workers can start together; only
@@ -274,12 +280,22 @@ npm ci
274
280
  npm run check
275
281
  ```
276
282
 
283
+ `npm run check:unused` runs TypeScript's unused declaration checks and Knip's
284
+ checks for unused files, exports, and dependencies. It runs before the tests in
285
+ `npm run check`. The release review also asks a read-only subagent to inspect
286
+ the diff and report dead code with evidence before main commits.
287
+
288
+ `npm ci` installs the repository's pre-commit hook in a checkout without custom
289
+ hooks. The hook runs the same check on the staged files, so unstaged edits stay
290
+ out of the check. If you already use a custom pre-commit hook, add
291
+ `npm run check:staged` to it to use the staged check.
292
+
277
293
  Runtime modules live in `src/`: configuration/UI, orchestration prompts,
278
294
  execution, lifecycle, isolation/recovery, and presentation. Native integration tests
279
295
  use a local fixture provider and do not consume paid model requests.
280
296
 
281
- Pushes of an unpublished version to `main` run checks on Windows, macOS, and
282
- Linux, then [publish to npm and create a GitHub Release](./.github/workflows/publish.yml).
283
- Do not publish locally.
297
+ Pull requests and pushes to `main` run the checks on Windows, macOS, and Linux.
298
+ A passing push of an unpublished version to `main` publishes to npm and creates
299
+ a GitHub Release through the [publish workflow](./.github/workflows/publish.yml).
284
300
 
285
301
  [Changelog](./CHANGELOG.md) · [MIT license](./LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ferris1225/pi-subagents",
3
- "version": "7.0.5",
3
+ "version": "7.0.6",
4
4
  "description": "Lead/worker orchestration for Pi: main plans and reviews, configurable workers execute with retained sessions and Git worktree isolation.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -36,8 +36,11 @@
36
36
  ]
37
37
  },
38
38
  "scripts": {
39
- "check": "tsc --noEmit && npm test",
39
+ "check": "npm run check:unused && npm test",
40
+ "check:unused": "tsc --noEmit && knip",
41
+ "check:staged": "node scripts/check-staged.mjs",
40
42
  "test": "node --test --test-concurrency=4 test/*.test.ts",
43
+ "prepare": "node scripts/install-git-hooks.mjs",
41
44
  "prepack": "npm run check"
42
45
  },
43
46
  "peerDependencies": {
@@ -51,6 +54,7 @@
51
54
  "@earendil-works/pi-coding-agent": "1.5.2",
52
55
  "@earendil-works/pi-tui": "1.5.2",
53
56
  "@types/node": "^22.10.0",
57
+ "knip": "6.48.0",
54
58
  "typebox": "^1.3.27",
55
59
  "typescript": "^5.9.0"
56
60
  },
@@ -242,7 +242,7 @@ export function registerSubagentTool(
242
242
 
243
243
  const blocks = await awaitRunResults(runtime, ids, signal, DEFAULT_MAX_RESULT_LINES, ctx.cwd, onUpdate
244
244
  ? (text) => onUpdate({ content: [{ type: "text", text }], details }) : undefined);
245
- if (signal?.aborted) await cancelActiveWork(runtime, "Parent run was cancelled.");
245
+ if (signal?.aborted) await cancelActiveWork(runtime, "Parent run was cancelled.", { context: ctx });
246
246
  else runtime.completeAwaitDelivery(ids);
247
247
  const settled = results.map((result) => result.runId === undefined ? result : runtime.settledRuns.get(result.runId) ?? result);
248
248
  return {
@@ -157,6 +157,7 @@ function delegationBody(agents: AgentConfig[]): string {
157
157
  const review = [
158
158
  "Treat child output as evidence. Review the actual diff, affected callers, and check evidence against the acceptance criteria. Reuse checks that still cover the code and read the result file when output was truncated.",
159
159
  "Use `subagent_message` to steer a running child or give a completed run a focused correction. Inspect failed or interrupted results with `subagent_status`, then correct the brief or finish in main. In a partial batch, leave accepted runs alone and address only the failed launches.",
160
+ "For an authorized push of code changes, first delegate a read-only audit of the diff for dead code and unused files, exports, or dependencies. If unavailable, audit in main. Remove confirmed dead code within scope. Delegate bounded fixes when practical. Run project checks before committing and pushing.",
160
161
  ];
161
162
 
162
163
  return `## Subagent orchestration
@@ -101,16 +101,13 @@ export class RunControl {
101
101
  private stopRequested = false;
102
102
  private stopMessage = "Subagent was aborted";
103
103
  private childPids = new Set<number>();
104
- readonly generation: number;
105
104
  private readonly onPhase?: (phase: RunControlPhase) => void;
106
105
 
107
106
  constructor(
108
107
  objective: string,
109
- generation: number,
110
108
  onPhase?: (phase: RunControlPhase) => void,
111
109
  ) {
112
110
  this.objective = objective;
113
- this.generation = generation;
114
111
  this.onPhase = onPhase;
115
112
  }
116
113
 
@@ -46,8 +46,6 @@ function directoryBytes(path: string): number {
46
46
  }
47
47
 
48
48
  interface CleanupUsage {
49
- /** Absolute path of the extension's durable root. */
50
- root: string;
51
49
  /** Per-project usage, largest first. */
52
50
  projects: Array<{ path: string; bytes: number; sessions: number; worktrees: number }>;
53
51
  totalBytes: number;
@@ -70,7 +68,7 @@ export function measureDurableUsage(root: string): CleanupUsage {
70
68
  try {
71
69
  projects = readdirSync(root, { withFileTypes: true });
72
70
  } catch {
73
- return { root, projects: [], totalBytes: 0 };
71
+ return { projects: [], totalBytes: 0 };
74
72
  }
75
73
  const measured = projects
76
74
  .filter((entry) => entry.isDirectory() && !entry.isSymbolicLink() && !entry.name.endsWith(".lock"))
@@ -85,7 +83,6 @@ export function measureDurableUsage(root: string): CleanupUsage {
85
83
  })
86
84
  .sort((left, right) => right.bytes - left.bytes);
87
85
  return {
88
- root,
89
86
  projects: measured,
90
87
  totalBytes: measured.reduce((sum, project) => sum + project.bytes, 0),
91
88
  };
@@ -115,8 +115,6 @@ export interface WorktreeFinalization {
115
115
  /** True once the patch was successfully applied to the original worktree. */
116
116
  integrated: boolean;
117
117
  hadChanges: boolean;
118
- /** Repository a recovery path can prune stale worktree metadata against. */
119
- originalRoot?: string;
120
118
  worktreePath?: string;
121
119
  patchPath?: string;
122
120
  error?: string;
@@ -546,7 +544,6 @@ class GitWorktreeIsolation implements WorktreeIsolation {
546
544
  status: "retained",
547
545
  integrated,
548
546
  hadChanges,
549
- originalRoot: this.originalRoot,
550
547
  ...(existsSync(this.worktreePath) ? { worktreePath: this.worktreePath } : {}),
551
548
  ...(patchWritten && existsSync(this.patchPath) ? { patchPath: this.patchPath } : {}),
552
549
  error,
@@ -6,34 +6,70 @@
6
6
  * user turn without waking the parent. Branch navigation abandons the
7
7
  * conversation, so it stops everything and discards results. */
8
8
 
9
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
10
- import type { SubagentRuntime, SubagentThread } from "./runtime.ts";
9
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
10
+ import { Text } from "@earendil-works/pi-tui";
11
+ import { formatDuration, formatTaskSummary } from "../presentation/monitor.ts";
12
+ import { formatUsage } from "../presentation/format.ts";
13
+ import { CANCELLATION_STATS_ENTRY, type SubagentRuntime, type SubagentThread } from "./runtime.ts";
11
14
  import { stopThreads } from "./stop.ts";
12
15
 
13
16
  const cancellations = new WeakMap<SubagentRuntime, Promise<void>>();
14
17
 
18
+ interface CancellationOptions {
19
+ context?: Pick<ExtensionContext, "mode" | "ui">;
20
+ notifyParent?: boolean;
21
+ }
22
+
23
+ function showTuiNotice(context: CancellationOptions["context"], text: string): void {
24
+ if (context?.mode !== "tui") return;
25
+ try {
26
+ context.ui.notify(text, "info");
27
+ } catch {
28
+ /* The terminal may have closed during cancellation. */
29
+ }
30
+ }
31
+
32
+ function formatStoppedRun(runtime: SubagentRuntime, thread: SubagentThread): string {
33
+ const result = runtime.settledRuns.get(thread.id);
34
+ return [
35
+ `#${thread.id} ${thread.agentName}`,
36
+ formatDuration(thread.elapsedMs),
37
+ result?.model ? formatTaskSummary(result.model, 60, false) : undefined,
38
+ result && formatUsage(result.usage),
39
+ result?.integrationStatus && `worktree ${result.integrationStatus.replaceAll("_", " ")}`,
40
+ ].filter(Boolean).join(" · ");
41
+ }
42
+
15
43
  /** The child has settled and only Git integration and delivery remain. */
16
44
  export function isSettlingThread(thread: SubagentThread): boolean {
17
45
  return !thread.retired && thread.lifecycleOperation === "settle";
18
46
  }
19
47
 
20
- export function cancelActiveWork(runtime: SubagentRuntime, reason: string, notifyParent = true): Promise<void> {
48
+ export function cancelActiveWork(
49
+ runtime: SubagentRuntime,
50
+ reason: string,
51
+ { context, notifyParent = true }: CancellationOptions = {},
52
+ ): Promise<void> {
21
53
  const existing = cancellations.get(runtime);
22
54
  if (existing) return existing;
23
55
  runtime.suppressCompletions = true;
24
- if (notifyParent) runtime.deferPendingCompletions();
56
+ const deferredCount = notifyParent ? runtime.deferPendingCompletions() : 0;
25
57
  runtime.discardCompletions();
26
58
  const threads = [...runtime.threads.values()];
27
59
  // Only a parent cancellation keeps finished work; an abandoned branch stops it.
28
- const keepSettling = notifyParent;
29
- if (keepSettling) for (const thread of threads.filter(isSettlingThread)) runtime.deferRunDelivery(thread.id);
60
+ const settlingThreads = notifyParent ? threads.filter(isSettlingThread) : [];
61
+ for (const thread of settlingThreads) runtime.deferRunDelivery(thread.id);
30
62
  const activeThreads = threads
31
- .filter((thread) => !thread.retired && !(keepSettling && isSettlingThread(thread))
63
+ .filter((thread) => !thread.retired && !(notifyParent && isSettlingThread(thread))
32
64
  && (thread.lifecycleOperation !== undefined || ["queued", "running", "interrupting"].includes(thread.state)));
33
65
  const threadIds = activeThreads.map((thread) => thread.id);
66
+ const runCount = `${threadIds.length} subagent run${threadIds.length === 1 ? "" : "s"}`;
34
67
  const done = stopThreads(runtime, threadIds, reason).then(() => {
35
68
  if (notifyParent && runtime.sessionActive && threadIds.length > 0) {
36
- runtime.recordCancellation(threadIds);
69
+ const stats = context?.mode === "tui"
70
+ ? [`Stopped ${runCount}`, ...activeThreads.map((thread) => formatStoppedRun(runtime, thread))]
71
+ : undefined;
72
+ runtime.recordCancellation(threadIds, stats);
37
73
  }
38
74
  }).finally(() => {
39
75
  runtime.discardCompletions();
@@ -41,12 +77,27 @@ export function cancelActiveWork(runtime: SubagentRuntime, reason: string, notif
41
77
  cancellations.delete(runtime);
42
78
  });
43
79
  cancellations.set(runtime, done);
80
+ if (notifyParent && runtime.sessionActive) {
81
+ const notices: string[] = [];
82
+ if (threadIds.length) notices.push(`Stopping ${runCount} · ${threadIds.map((id) => `#${id}`).join(", ")}`);
83
+ for (const thread of settlingThreads) {
84
+ const progress = thread.isolation === "worktree" ? "applying worktree changes" : "finalizing its result";
85
+ notices.push(`#${thread.id} ${thread.agentName} finished and is ${progress}.`);
86
+ }
87
+ if (deferredCount) notices.push(`${deferredCount} completed subagent result${deferredCount === 1 ? "" : "s"} ready for your next message.`);
88
+ if (notices.length) showTuiNotice(context, notices.join("\n"));
89
+ }
44
90
  return done;
45
91
  }
46
92
 
47
93
  export function registerCancellationHooks(pi: ExtensionAPI, runtime: SubagentRuntime): void {
48
- pi.on("agent_settled", (event) => event.aborted ? cancelActiveWork(runtime, "Parent run was cancelled.") : undefined);
49
- pi.on("session_before_tree", () => cancelActiveWork(runtime, "Parent navigated to another conversation branch.", false));
94
+ pi.registerEntryRenderer<string[]>(CANCELLATION_STATS_ENTRY, (entry, _options, theme) => {
95
+ if (!Array.isArray(entry.data) || !entry.data.length) return undefined;
96
+ const [title, ...runs] = entry.data;
97
+ return new Text([theme.bold(title!), ...runs].join("\n"), 0, 0);
98
+ });
99
+ pi.on("agent_settled", (event, context) => event.aborted ? cancelActiveWork(runtime, "Parent run was cancelled.", { context }) : undefined);
100
+ pi.on("session_before_tree", () => cancelActiveWork(runtime, "Parent navigated to another conversation branch.", { notifyParent: false }));
50
101
  // Pi emits session_shutdown for new/resume/fork/reload. The runtime's
51
102
  // shutdown path stops children, retains recovery evidence, and disables delivery.
52
103
  }
@@ -22,7 +22,6 @@ export interface DispatchCore {
22
22
  startBackground: StartBackgroundInternal;
23
23
  /** Stamp a terminal monitor state and toast the result once. */
24
24
  finishRun: (runId: number, status: "done" | "failed", opts?: { silent?: boolean }) => void;
25
- makeLiveHandler: (runId: number, generation?: number) => (event: SubagentLiveEvent) => void;
26
25
  makeDetails: (mode: "single" | "parallel") => (results: SingleResult[]) => SubagentDetails;
27
26
  }
28
27
 
@@ -145,7 +144,6 @@ export function createDispatchCore(runtime: SubagentRuntime): DispatchCore {
145
144
  },
146
145
  startBackground,
147
146
  finishRun,
148
- makeLiveHandler,
149
147
  makeDetails,
150
148
  };
151
149
  }
@@ -25,6 +25,8 @@ import type { RunControl, SteeringReceipt } from "../execution/run-control.ts";
25
25
  import { isFailedResult, type SingleResult } from "../execution/spawn.ts";
26
26
  import type { IsolationMode, WorktreeFinalization, WorktreeIsolation } from "../isolation/worktree.ts";
27
27
 
28
+ export const CANCELLATION_STATS_ENTRY = "subagent-cancellation-stats";
29
+
28
30
  export type ThreadState = "queued" | "running" | "interrupting" | "parked" | "completed" | "failed" | "stopped";
29
31
 
30
32
  type ThreadLifecycleOperation = "stop" | "settle";
@@ -86,13 +88,13 @@ export interface SubagentRuntime {
86
88
  /** Cancelling a parent must not wake it again with old child results. */
87
89
  suppressCompletions: boolean;
88
90
  discardCompletions: () => void;
89
- /** Hand held completions to the next user turn without waking the parent. */
90
- deferPendingCompletions: () => void;
91
+ /** Hand held completions to the next user turn and return the number queued. */
92
+ deferPendingCompletions: () => number;
91
93
  /** Route a run that already finished its child to the next user turn, even
92
94
  * while completions are suppressed: its result is real and must not be lost. */
93
95
  deferRunDelivery: (runId: number) => void;
94
- /** Record cancellation for the next user turn without waking the parent. */
95
- recordCancellation: (runIds: number[]) => void;
96
+ /** Show optional terminal stats and queue the cancellation receipt for the next user turn. */
97
+ recordCancellation: (runIds: number[], stats?: string[]) => void;
96
98
  /** Resolves when the load-time durable restore pass has finished. Everything
97
99
  * that answers "which threads exist" awaits it — the lookup tools, a fresh
98
100
  * dispatch before it allocates a run id, and the restored-thread notice — so
@@ -160,13 +162,23 @@ export function createRuntime(pi: ExtensionAPI, configPath: string): SubagentRun
160
162
  getToolInfos: () => pi.getAllTools(),
161
163
  sessionActive: true,
162
164
  suppressCompletions: false,
163
- recordCancellation: (runIds) => {
165
+ recordCancellation: (runIds, stats) => {
164
166
  if (!runIds.length) return;
167
+ let display = true;
168
+ if (stats) {
169
+ try {
170
+ // Custom entries render immediately and stay out of model context.
171
+ pi.appendEntry(CANCELLATION_STATS_ENTRY, stats);
172
+ display = false;
173
+ } catch {
174
+ /* Keep the next-turn receipt visible if the entry could not be saved. */
175
+ }
176
+ }
165
177
  const targets = "runs " + runIds.map((id) => `#${id}`).join(", ");
166
178
  pi.sendMessage({
167
179
  customType: "subagent-cancelled",
168
180
  content: `Parent cancellation stopped ${targets}. These runs are already cancelled; no further subagent_stop is needed. Do not restart cancelled work unless the user requests it. Partial edits and retained integration artifacts may remain; inspect them only if continuing the task.`,
169
- display: true,
181
+ display,
170
182
  details: { runIds },
171
183
  }, { deliverAs: "nextTurn", triggerTurn: false });
172
184
  },
@@ -179,6 +191,7 @@ export function createRuntime(pi: ExtensionAPI, configPath: string): SubagentRun
179
191
  const pending = [...runtime.completionBatcher.dispose(), ...heldCompletions];
180
192
  heldCompletions = [];
181
193
  sendNextTurn(pending);
194
+ return pending.length;
182
195
  },
183
196
  deferRunDelivery: (runId) => {
184
197
  deferredRuns.add(runId);
@@ -63,10 +63,15 @@ export async function stopThreads(runtime: SubagentRuntime, targets: readonly nu
63
63
  // An isolated stop may need the repository lane for final integration;
64
64
  // cancelling all holders first prevents stop-all from waiting behind a
65
65
  // later run that this same operation has not interrupted yet.
66
- const interruptionPromises = claimed.map(({ thread, stopMessage, controller }) => {
66
+ const interruptions = claimed.map(({ runId, thread, stopMessage, controller }) => {
67
67
  const stopping = thread.control.stop(stopMessage).catch(() => undefined);
68
68
  runtime.backgroundQueue.cancel(controller);
69
- return stopping;
69
+ // Capture each duration as its child stops. A sibling may spend much
70
+ // longer integrating its worktree before we can remove this monitor row.
71
+ const captureElapsed = quiesced(stopping).then(() => {
72
+ thread.elapsedMs = monitor.getElapsedMs(runId) ?? thread.elapsedMs;
73
+ });
74
+ return { stopping, captureElapsed };
70
75
  });
71
76
 
72
77
  const stopped: string[] = [];
@@ -93,7 +98,8 @@ export async function stopThreads(runtime: SubagentRuntime, targets: readonly nu
93
98
  // unkillable child can stall even process termination. Stop owns the
94
99
  // lifecycle synchronously, so a stuck tail settles silently after we
95
100
  // proceed; none of its late paths can publish a second result.
96
- await quiesced(interruptionPromises[claimIndex]);
101
+ const interruption = interruptions[claimIndex]!;
102
+ await interruption.captureElapsed;
97
103
  if (!(await quiesced(completion))) runtime.backgroundQueue.cancel(controller);
98
104
  if (runtime.runControllers.get(runId) === controller) runtime.runControllers.delete(runId);
99
105
  if (thread.queueController === controller) thread.queueController = undefined;
@@ -127,7 +133,7 @@ export async function stopThreads(runtime: SubagentRuntime, targets: readonly nu
127
133
  exitCode: 1,
128
134
  messages: [],
129
135
  stderr: stopMessage,
130
- usage: emptyUsage(),
136
+ usage: run?.usage ?? emptyUsage(),
131
137
  model: run?.model,
132
138
  thinking: run?.thinking,
133
139
  projectCwd: thread.cwd,
@@ -186,7 +192,7 @@ export async function stopThreads(runtime: SubagentRuntime, targets: readonly nu
186
192
  if (thread.durableId) await removeThreadRecord(runtime.configPath, thread.durableId, thread.cwd).catch(() => undefined);
187
193
  // Returning from a bounded stop retires context, but cannot release a
188
194
  // writer or phase lease while a child or Git tail can still change files.
189
- void Promise.allSettled([interruptionPromises[claimIndex]!, completion, finalizationCompletion]).then(() => {
195
+ void Promise.allSettled([interruption.stopping, completion, finalizationCompletion]).then(() => {
190
196
  if (thread.lifecycleVersion === stopVersion && thread.lifecycleOperation === "stop") {
191
197
  thread.lifecycleOperation = undefined;
192
198
  }
@@ -140,7 +140,7 @@ export function createBackgroundDispatcher(options: BackgroundDispatcherOptions)
140
140
  };
141
141
 
142
142
  let thread!: SubagentThread;
143
- const control = new RunControl(task, generation, (phase) => {
143
+ const control = new RunControl(task, (phase) => {
144
144
  if (runtime.threads.get(runId)?.generation !== generation || phase === "settled") return;
145
145
  const state: ThreadState =
146
146
  phase === "queued" || phase === "starting"
@@ -58,7 +58,7 @@ function createRestoredThread(
58
58
  isolation: record.isolation,
59
59
  worktree,
60
60
  state,
61
- control: new RunControl(record.task, record.generation),
61
+ control: new RunControl(record.task),
62
62
  generationCompletion: Promise.resolve(),
63
63
  lifecycleVersion: 0,
64
64
  elapsedMs: record.elapsedMs,
@@ -278,7 +278,7 @@ export function registerLookupTools(pi: ExtensionAPI, runtime: SubagentRuntime,
278
278
  const blocks = await awaitRunResults(runtime, [result.runId], _signal, DEFAULT_MAX_RESULT_LINES, thread.cwd, (text) => {
279
279
  onUpdate?.({ content: [{ type: "text", text }], details });
280
280
  });
281
- if (_signal?.aborted) await cancelActiveWork(runtime, "Parent run was cancelled.");
281
+ if (_signal?.aborted) await cancelActiveWork(runtime, "Parent run was cancelled.", { context: ctx });
282
282
  else runtime.completeAwaitDelivery([result.runId]);
283
283
  const settled = runtime.settledRuns.get(result.runId);
284
284
  return {