brl-subagent 2.7.0 → 2.8.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/src/recovery.ts CHANGED
@@ -34,8 +34,10 @@
34
34
  import { listInflightRuns, type InflightRun } from "./run-registry";
35
35
  import { assertSafeAgentId } from "./sanitize";
36
36
  import { isProcAvailable, defaultRecoveryDeps } from "./proc";
37
- import { decideRecovery, reapPids, type RecoveryDeps, type RecoveryRecord } from "./recovery-engine";
37
+ import { decideRecovery, classifyOwner, reapPids, type RecoveryDeps, type RecoveryRecord } from "./recovery-engine";
38
38
  import type { Logger } from "./logging";
39
+ import type { SubagentRun } from "./types";
40
+ import { PROMPT_NEVER_ISSUED_MESSAGE } from "./types";
39
41
 
40
42
  // Re-export the pure engine and the production wiring so existing importers
41
43
  // (`index.ts`, the recovery/registry suites) keep their single entry point.
@@ -61,6 +63,14 @@ export interface BootScanSummary {
61
63
  skippedNoOwner: number;
62
64
  /** Registry entries skipped fail-closed because their id failed the write guard. */
63
65
  skippedUnsafeIds: number;
66
+ /**
67
+ * Issue #447: registry entries classified NEVER STARTED (`acceptedAt:
68
+ * null`) and settled `failed` instead of being offered as an interrupted,
69
+ * retryable run. Counted per FINALIZE attempt: an entry held back because its
70
+ * owner is still live (or unverifiable) is not counted, and a failed terminal
71
+ * write is warned — either way the entry stays out of the interrupted class.
72
+ */
73
+ neverStarted: number;
64
74
  }
65
75
 
66
76
  /** The all-zero summary (a skipped scan / an empty registry). */
@@ -75,6 +85,7 @@ export function emptyBootScanSummary(): BootScanSummary {
75
85
  skippedUnverifiable: 0,
76
86
  skippedNoOwner: 0,
77
87
  skippedUnsafeIds: 0,
88
+ neverStarted: 0,
78
89
  };
79
90
  }
80
91
 
@@ -211,10 +222,66 @@ export async function runBootScan(options: BootScanOptions): Promise<BootScanSum
211
222
  export interface PersistedAgentLike {
212
223
  status: string;
213
224
  interruptedAt?: string;
225
+ /**
226
+ * Issue #447: the acceptance marker, when the record carries one. Only the
227
+ * registry entry and the run entry write it today; this read keeps a record
228
+ * that DOES carry it authoritative (the entry is the fallback, not the
229
+ * override) — see `acceptanceState`.
230
+ */
231
+ acceptedAt?: string | null;
214
232
  owner?: RecoveryRecord["owner"];
215
233
  childMarker?: string;
216
234
  }
217
235
 
236
+ /**
237
+ * Issue #447: the tri-state read of the acceptance marker. `undefined` is the
238
+ * LEGACY/untracked state, and it must stay distinguishable from `null` (never
239
+ * started) — which is why this is an explicit `!== undefined` probe and never
240
+ * `??` (`null ?? agent` would silently reclassify every never-started entry as
241
+ * accepted and bring the false positive straight back).
242
+ */
243
+ function acceptanceState(
244
+ entry: InflightRun,
245
+ agent: PersistedAgentLike | null,
246
+ ): string | null | undefined {
247
+ if (entry.acceptedAt !== undefined) return entry.acceptedAt;
248
+ return agent?.acceptedAt;
249
+ }
250
+
251
+ /**
252
+ * The terminal `failed` record written for a dispatch that never reached the
253
+ * prompt: the durable summary the entry already holds, stamped with the honest
254
+ * reason. Projected here (next to the classification that decides it) so the
255
+ * caller only has to persist what it is handed. Deliberately does NOT carry
256
+ * `interruptedAt` — a never-started run is not an interrupted run, and the
257
+ * recovery surface keys on that mark alone.
258
+ */
259
+ export function neverStartedRunRecord(
260
+ entry: InflightRun,
261
+ finishedAt: string,
262
+ reason: string = PROMPT_NEVER_ISSUED_MESSAGE,
263
+ ): SubagentRun {
264
+ return {
265
+ id: entry.id,
266
+ task: entry.task ?? "",
267
+ ...(entry.label !== undefined ? { label: entry.label } : {}),
268
+ ...(entry.dispatchId !== undefined ? { dispatchId: entry.dispatchId } : {}),
269
+ ...(entry.attempt !== undefined ? { attempt: entry.attempt } : {}),
270
+ status: "failed",
271
+ model: entry.model ?? "unknown",
272
+ thinkingLevel: entry.thinkingLevel ?? "unknown",
273
+ startedAt: entry.startedAt,
274
+ finishedAt,
275
+ errorCategory: "unknown",
276
+ errorMessage: reason,
277
+ ...(entry.recoveryPosture !== undefined ? { recoveryPosture: entry.recoveryPosture } : {}),
278
+ ...(entry.originalParams !== undefined ? { originalParams: entry.originalParams } : {}),
279
+ // The marker stays `null` on the terminal record: this run never accepted
280
+ // the prompt, and the record must not claim otherwise after the fact.
281
+ acceptedAt: null,
282
+ };
283
+ }
284
+
218
285
  export interface RegistryScanOptions {
219
286
  deps: RecoveryDeps;
220
287
  /**
@@ -222,6 +289,13 @@ export interface RegistryScanOptions {
222
289
  * background). Returns `false` when the durable write did not land.
223
290
  */
224
291
  mark(record: RecoveryRecord, interruptedAt: string): boolean | void;
292
+ /**
293
+ * Issue #447: persist the terminal record of a dispatch that never reached
294
+ * the prompt (`acceptedAt: null`). Absent ⇒ the entry is left untouched —
295
+ * it is still never offered as interrupted, so the fail-closed direction is
296
+ * "no write", never "offer a retry".
297
+ */
298
+ finalizeNeverStarted?(run: SubagentRun, reason: string): boolean | void;
225
299
  /**
226
300
  * Read ONE background run's agent record by id (never the whole store).
227
301
  * Returns null when the record is absent; absent defaults to an in-flight
@@ -269,31 +343,89 @@ export async function recoverInflightRuns(options: RegistryScanOptions): Promise
269
343
  }
270
344
 
271
345
  const records: RecoveryRecord[] = [];
346
+ // Issue #447: `acceptedAt: null` = tracked but the prompt was never issued.
347
+ // Such an entry is NOT a recovery candidate: nothing was started, so there
348
+ // is nothing to reap, nothing to interrupt, and nothing to retry. It is
349
+ // finalized `failed` below instead of being handed to the decision engine.
350
+ const neverStarted: InflightRun[] = [];
272
351
  for (const entry of addressable) {
273
- if (entry.kind === "background") {
274
- const agent = options.readAgentRecord?.(entry.id) ?? null;
275
- if (agent && agent.status !== "running") continue;
276
- records.push({
352
+ const isBackground = entry.kind === "background";
353
+ // Only a background entry has an agent record to enrich from (and to drop
354
+ // a stale entry by); the read is that ONE file, never the whole store.
355
+ const agent = isBackground ? (options.readAgentRecord?.(entry.id) ?? null) : null;
356
+ if (agent && agent.status !== "running") continue;
357
+ // Issue #447: ONE tri-state read for both kinds, so the `null` rule cannot
358
+ // drift between the background and run branches.
359
+ if (acceptanceState(entry, agent) === null) {
360
+ neverStarted.push(entry);
361
+ continue;
362
+ }
363
+ records.push({
364
+ id: entry.id,
365
+ kind: isBackground ? "agent" : "run",
366
+ status: "running",
367
+ interruptedAt: agent?.interruptedAt ?? entry.interruptedAt,
368
+ owner: agent?.owner ?? entry.owner,
369
+ childMarker: agent?.childMarker ?? entry.childMarker,
370
+ source: entry,
371
+ });
372
+ }
373
+
374
+ const now = options.now?.() ?? new Date();
375
+ /** Entries this scan actually SETTLED (see `BootScanSummary.neverStarted`). */
376
+ let settledNeverStarted = 0;
377
+ for (const entry of neverStarted) {
378
+ if (!options.finalizeNeverStarted) {
379
+ options.log?.debug("Recovery: left a never-started dispatch untouched (no finalizer wired)", {
277
380
  id: entry.id,
278
- kind: "agent",
279
- status: "running",
280
- interruptedAt: agent?.interruptedAt ?? entry.interruptedAt,
281
- owner: agent?.owner ?? entry.owner,
282
- childMarker: agent?.childMarker ?? entry.childMarker,
283
- source: entry,
381
+ kind: entry.kind,
284
382
  });
285
- } else {
286
- records.push({
383
+ continue;
384
+ }
385
+ // A never-started entry is acted on ONLY when its owner is provably dead,
386
+ // the same ownership rule the decision engine applies before it marks
387
+ // anything. A LIVE owner may still be inside its own pre-start window (the
388
+ // git-branch lock, a slow transcript start) and will write its acceptance
389
+ // marker momentarily — finalizing it here would stamp a false `failed`
390
+ // terminal record the run's real terminal entry could not outrank (the
391
+ // store keeps the earlier entry, and readers prefer the LAST one). No owner or
392
+ // an unverifiable one ⇒ no write, exactly as for the mark path.
393
+ const owner = entry.owner;
394
+ const ownerDead =
395
+ !!owner &&
396
+ Number.isInteger(owner.pid) &&
397
+ owner.pid > 0 &&
398
+ classifyOwner(owner, options.deps) === "dead";
399
+ if (!ownerDead) {
400
+ options.log?.debug("Recovery: left a never-started dispatch with a live/unverified owner", {
287
401
  id: entry.id,
288
- kind: "run",
289
- status: "running",
290
- interruptedAt: entry.interruptedAt,
291
- owner: entry.owner,
292
- childMarker: entry.childMarker,
293
- source: entry,
402
+ kind: entry.kind,
403
+ });
404
+ continue;
405
+ }
406
+ settledNeverStarted++;
407
+ try {
408
+ options.finalizeNeverStarted(
409
+ neverStartedRunRecord(entry, now.toISOString()),
410
+ PROMPT_NEVER_ISSUED_MESSAGE,
411
+ );
412
+ options.log?.info("Recovery: finalized a never-started dispatch as failed", {
413
+ id: entry.id,
414
+ kind: entry.kind,
415
+ });
416
+ } catch (err) {
417
+ // Best-effort, exactly like the mark path: a failed finalize must not
418
+ // abort the scan for the OTHER candidates. The registry entry is cleared
419
+ // before the append lands (`persistRunRecord`), so the residue is gone
420
+ // even when the terminal entry cannot be written.
421
+ options.log?.warn("Recovery: never-started finalize failed", {
422
+ id: entry.id,
423
+ kind: entry.kind,
424
+ error: (err as Error).message,
294
425
  });
295
426
  }
296
427
  }
428
+
297
429
  const summary = await runBootScan({
298
430
  records,
299
431
  deps: options.deps,
@@ -302,6 +434,7 @@ export async function recoverInflightRuns(options: RegistryScanOptions): Promise
302
434
  log: options.log,
303
435
  });
304
436
  summary.skippedUnsafeIds = unsafeIds.length;
437
+ summary.neverStarted = settledNeverStarted;
305
438
  return summary;
306
439
  }
307
440
 
@@ -314,6 +447,8 @@ export interface ProductionRecoveryOptions {
314
447
  deps?: RecoveryDeps;
315
448
  /** Persist the D3 mark for this record; `false` = the durable write failed. */
316
449
  mark(record: RecoveryRecord, interruptedAt: string): boolean | void;
450
+ /** Issue #447: persist the terminal record of a never-started dispatch. */
451
+ finalizeNeverStarted?(run: SubagentRun, reason: string): boolean | void;
317
452
  readAgentRecord?(id: string): PersistedAgentLike | null;
318
453
  now?: () => Date;
319
454
  log?: Pick<Logger, "debug" | "info" | "warn">;
@@ -336,6 +471,7 @@ export async function recoverProduction(options: ProductionRecoveryOptions): Pro
336
471
  return recoverInflightRuns({
337
472
  deps: options.deps ?? defaultRecoveryDeps(),
338
473
  mark: options.mark,
474
+ finalizeNeverStarted: options.finalizeNeverStarted,
339
475
  readAgentRecord: options.readAgentRecord,
340
476
  now: options.now,
341
477
  log: options.log,
@@ -64,6 +64,13 @@ export interface InflightRun {
64
64
  // run record, so a post-crash retry restores the same 17-field shape a
65
65
  // same-session retry does (including `force`; decision 2026-10-11).
66
66
  originalParams?: SubagentRun["originalParams"];
67
+ /**
68
+ * Issue #447: the acceptance marker, mirrored from the run record.
69
+ * `null` = tracked but never accepted (never reached `session.prompt()`),
70
+ * ISO string = accepted, absent = legacy entry written before the field.
71
+ * The boot scan classifies on this tri-state (`recoverInflightRuns`).
72
+ */
73
+ acceptedAt?: string | null;
67
74
  startedAt: string;
68
75
  cwd: string;
69
76
  interruptedAt?: string;
@@ -83,6 +90,7 @@ export interface InflightRunInput {
83
90
  model?: string;
84
91
  thinkingLevel?: string;
85
92
  originalParams?: SubagentRun["originalParams"];
93
+ acceptedAt?: string | null;
86
94
  startedAt: string;
87
95
  cwd?: string;
88
96
  }
@@ -161,6 +169,14 @@ function normalizeEnrichment(value: InflightRun, raw: Record<string, unknown>):
161
169
  } else {
162
170
  delete entry.originalParams;
163
171
  }
172
+ // Issue #447: keep the tri-state intact and treat anything else as LEGACY
173
+ // (absent) rather than inventing a fourth state. A mistyped marker must
174
+ // never downgrade a real run into the never-started class.
175
+ if (raw.acceptedAt === null || typeof raw.acceptedAt === "string") {
176
+ entry.acceptedAt = raw.acceptedAt;
177
+ } else {
178
+ delete entry.acceptedAt;
179
+ }
164
180
  return entry;
165
181
  }
166
182
 
@@ -205,6 +221,9 @@ function mergeInput(base: InflightRun, input: InflightRunInput): InflightRun {
205
221
  if (input.model !== undefined) next.model = input.model;
206
222
  if (input.thinkingLevel !== undefined) next.thinkingLevel = input.thinkingLevel;
207
223
  if (input.originalParams !== undefined) next.originalParams = input.originalParams;
224
+ // Issue #447: `null` MUST copy (it is the never-started sentinel); only
225
+ // `undefined` is skipped, so a refresh without the marker cannot erase it.
226
+ if (input.acceptedAt !== undefined) next.acceptedAt = input.acceptedAt;
208
227
  return next;
209
228
  }
210
229
 
@@ -309,6 +328,7 @@ function toRegistryInput(run: SubagentRun, kind: InflightRunKind): InflightRunIn
309
328
  model: run.model,
310
329
  thinkingLevel: run.thinkingLevel,
311
330
  originalParams: run.originalParams,
331
+ acceptedAt: run.acceptedAt,
312
332
  startedAt: run.startedAt,
313
333
  cwd: process.cwd(),
314
334
  };
package/src/runner.ts CHANGED
@@ -45,7 +45,9 @@ import {
45
45
  } from "./kill-escalation";
46
46
  import { findByMarker, pidAlive, pidHasMarker, pidGone, groupHasMembers, killProcessGroup } from "./proc";
47
47
  import { getSafeEnv, DEPTH_ENV_KEY, CHILD_MARKER_ENV_KEY, sanitizeErrorMessage } from "./sanitize";
48
+ import { createLogger } from "./logging";
48
49
  import type { Logger } from "./logging";
50
+ import { buildEngineeringBarSection } from "./engineering-bar";
49
51
  import type { Intercom } from "./messaging";
50
52
  import { extractMessages, formatPendingMessages } from "./messaging";
51
53
  import type {
@@ -53,6 +55,16 @@ import type {
53
55
  TranscriptContentBlock,
54
56
  TranscriptToolCallBlock,
55
57
  } from "./transcript-tail";
58
+
59
+ /**
60
+ * The logger for diagnostics a CALLER did not instrument. `runSubagent`'s `log`
61
+ * is optional (its sweep/shutdown callers pass one; the foreground dispatch in
62
+ * `index.ts` passes one too), but the engineering bar's read failure (#421)
63
+ * must never be silent — so the bar's warning falls back to this sink instead of
64
+ * being dropped when `log` is absent.
65
+ */
66
+ const fallbackLog = createLogger("runner");
67
+
56
68
  // ---------------------------------------------------------------------------
57
69
  // In-flight child registry (Option B U1)
58
70
  // ---------------------------------------------------------------------------
@@ -478,7 +490,17 @@ export function buildSubagentArgs(
478
490
  "--thinking",
479
491
  thinkingLevel,
480
492
  ];
481
- if (toolOptions?.noBuiltinTools) {
493
+ // Issue #442: an EXPLICITLY empty allowlist means "no child tools", which is
494
+ // neither of the two states pi already expresses. Omitted keeps pi's
495
+ // defaults (no restriction flag at all), and `--no-builtin-tools` keeps
496
+ // extension and custom tools. `tools !== undefined` is therefore the
497
+ // emptiness test, not `.length > 0`: `[]` must reach pi's blanket
498
+ // `--no-tools`, and it must win over `noBuiltinTools` so an empty allowlist
499
+ // can never widen into "built-ins off, extension tools on". `--exclude-tools`
500
+ // stays additive below — it only disables, so it cannot re-enable a tool.
501
+ if (toolOptions?.tools !== undefined && toolOptions.tools.length === 0) {
502
+ args.push("--no-tools");
503
+ } else if (toolOptions?.noBuiltinTools) {
482
504
  args.push("--no-builtin-tools");
483
505
  } else if (toolOptions?.tools && toolOptions.tools.length > 0) {
484
506
  args.push("--tools", toolOptions.tools.join(","));
@@ -1078,11 +1100,19 @@ ${msgBlock}`;
1078
1100
 
1079
1101
  const args = buildSubagentArgs(model, thinkingLevel, toolOptions);
1080
1102
 
1103
+ // Issue #421: the project's engineering bar rides the same
1104
+ // --append-system-prompt channel as the caller's prompt, appended last.
1105
+ // Injected HERE (the foreground chokepoint all callers share) rather than
1106
+ // in each caller, so no preset selection can drop it; gated by the project
1107
+ // flag (ADR 0019), and `engineering-bar.ts` owns the read + its warning.
1108
+ const barSection = buildEngineeringBarSection(cwd, log ?? fallbackLog);
1109
+ const childSystemPrompt = barSection ? `${systemPrompt}${barSection}` : systemPrompt;
1110
+
1081
1111
  let tmpDir: string | null = null;
1082
1112
  let tmpFilePath: string | null = null;
1083
1113
 
1084
- if (systemPrompt.trim()) {
1085
- const tmp = await writeToTempFile(cwd, "system", systemPrompt);
1114
+ if (childSystemPrompt.trim()) {
1115
+ const tmp = await writeToTempFile(cwd, "system", childSystemPrompt);
1086
1116
  tmpDir = tmp.dir;
1087
1117
  tmpFilePath = tmp.filePath;
1088
1118
  args.push("--append-system-prompt", tmpFilePath);
@@ -1105,7 +1135,7 @@ ${msgBlock}`;
1105
1135
  thinkingLevel,
1106
1136
  cwd,
1107
1137
  taskPreview: task.slice(0, 80),
1108
- hasSystemPrompt: systemPrompt.trim().length > 0,
1138
+ hasSystemPrompt: childSystemPrompt.trim().length > 0,
1109
1139
  timeout,
1110
1140
  });
1111
1141
 
package/src/schema.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * Static<typeof delegateTaskParamsSchema>, so schema and types cannot drift.
6
6
  */
7
7
  import { Type } from "typebox";
8
- import { MAX_CHAIN_STEPS, MAX_PARALLEL_TASKS, MAX_GRAPH_TASKS } from "./types";
8
+ import { MAX_CHAIN_STEPS, MAX_PARALLEL_TASKS, MAX_GRAPH_TASKS, THINKING_LEVELS } from "./types";
9
9
 
10
10
  /**
11
11
  * Issue #381 (audit D7): the per-unit fields registered for `chain[]` steps,
@@ -24,8 +24,34 @@ const STEP_HEAD_FIELDS = {
24
24
  model: Type.Optional(Type.String({ description: "Model override for this step (provider/model-id). Defaults to the global subagent model." })),
25
25
  };
26
26
 
27
+ /**
28
+ * Issue #443: the accepted thinking levels as a schema `enum`, derived from
29
+ * `THINKING_LEVELS` so the declaration cannot drift from the runtime guard
30
+ * (`isThinkingLevel`).
31
+ *
32
+ * The EMPTY STRING is a member on purpose: it is an existing declaration with a
33
+ * meaning (call level → the configured maximum, per unit → inherit the global
34
+ * level), so the enum must not turn it into a validation failure. An `enum`
35
+ * beats a union of literals here because pi-schema's error names the whole set
36
+ * (`thinkingLevel: expected one of [...]`) instead of only the first branch.
37
+ *
38
+ * This is the FIRST line of defence only: pi validates raw tool arguments, so
39
+ * a preset object, a restored `retryRunId` value, the transport retry's rebuilt
40
+ * params and every per-unit declaration reach the handler WITHOUT passing here.
41
+ * `invalidThinkingLevelRejection` (prelude.ts) is the runtime guard.
42
+ */
43
+ const THINKING_LEVEL_ENUM = [...THINKING_LEVELS, ""];
44
+
27
45
  const STEP_THINKING_LEVEL_FIELD = {
28
- thinkingLevel: Type.Optional(Type.String({})),
46
+ thinkingLevel: Type.Optional(
47
+ Type.String({
48
+ enum: THINKING_LEVEL_ENUM,
49
+ description:
50
+ "Thinking level override for this subtask. Same values and rules as the call-level thinkingLevel: " +
51
+ `${THINKING_LEVELS.join(", ")} (exact match). An unknown value rejects the whole batch before anything starts. ` +
52
+ "Empty inherits the call-level level.",
53
+ }),
54
+ ),
29
55
  };
30
56
 
31
57
  /** Per-unit concurrency priority — tasks[] and graph[] only (issue #114). */
@@ -73,10 +99,12 @@ export const delegateTaskParamsSchema = Type.Object({
73
99
  ),
74
100
  thinkingLevel: Type.Optional(
75
101
  Type.String({
102
+ enum: THINKING_LEVEL_ENUM,
76
103
  description:
77
104
  "Requested thinking level for this subagent call. " +
78
- "One of: off, minimal, low, medium, high, xhigh. " +
79
- "Capped at the user's configured maximum. If omitted, the user's configured level is used.",
105
+ `One of: ${THINKING_LEVELS.join(", ")} — matched exactly, so case and whitespace matter. ` +
106
+ "An unknown value is rejected (pi's own `max` is not a delegated level). " +
107
+ "Capped at the user's configured maximum. If omitted, or an empty string, the user's configured level is used.",
80
108
  }),
81
109
  ),
82
110
  outputFile: Type.Optional(
@@ -114,7 +142,8 @@ export const delegateTaskParamsSchema = Type.Object({
114
142
  tools: Type.Optional(
115
143
  Type.Array(Type.String(), {
116
144
  description:
117
- "Explicit allowlist of tool names for the subagent. Maps to pi's --tools flag.",
145
+ "Explicit allowlist of tool names for the subagent. Maps to pi's --tools flag. " +
146
+ "An EMPTY array means no child tools (pi --no-tools); omitting the field keeps pi's defaults.",
118
147
  }),
119
148
  ),
120
149
  excludeTools: Type.Optional(
@@ -211,7 +240,8 @@ export const delegateTaskParamsSchema = Type.Object({
211
240
  minLength: 1,
212
241
  description:
213
242
  "Stated bypass for the Jev dispatch-line pre-flight, which is active ONLY in a project whose package.json sets the `brl-subagent.processChecks` field (this repository). " +
214
- "A NON-EMPTY reason string: the dispatch proceeds and the reason is surfaced as a warning in the result, so the bypass is never silent. " +
243
+ "A reason string that states WHY the line is missing: the dispatch proceeds and the reason is surfaced as a warning in the result, so the bypass is never silent. " +
244
+ "The reason is validated when the dispatch is handled, not by this schema: the argument validator coerces loosely typed input, so a boolean or a number arrives as its text (`true` becomes \"true\") and is REFUSED exactly like an absent bypass. " +
215
245
  "It bypasses ONLY the line check — capability conflicts still reject (unlike force). " +
216
246
  "Append `jev: unavailable` to the task instead when the classifier did not run.",
217
247
  }),
@@ -224,7 +254,7 @@ export const delegateTaskParamsSchema = Type.Object({
224
254
  "The conductor is woken with a completion message; use get_subagent_result for post-wake retrieval and stall checks. " +
225
255
  "Supports a single task or the tasks array (a fan-out that starts one background agent per task; with tasks the call returns one ID per task and the conductor is woken once per agent as each finishes); combining background with chain or graph is rejected. " +
226
256
  "Default: conditional. Omitted, a single task or tasks fan-out runs in the BACKGROUND when the effective approvalMode is 'auto' (call param, else config); it stays foreground for 'writes'/'always' (a background run has no approval dialog, so the gate must stay in front of the user) and for chain/graph, which block by definition. " +
227
- "Pass background: false for a quick probe whose answer the next step needs inline. Explicit true/false wins. ONE pre-flight exception exists, and only in a project that opted into its own process checks (package.json `brl-subagent.processChecks: true`; this repository): a high/xhigh-thinking dispatch with background: false AND an explicit timeout is switched to background and the explicit timeout is dropped, because a foreground run loses its whole work at a timeout while a background run keeps its session and is retried on a transport error; pass force: true to keep it foreground. Without that project opt-in the explicit shape and its timeout stand. " +
257
+ "Pass background: false for a quick probe whose answer the next step needs inline. Explicit true/false wins. ONE pre-flight exception exists, and only in a project that opted into its own process checks (package.json `brl-subagent.processChecks: true`; this repository): a high/xhigh-thinking dispatch that resolves FOREGROUND and carries an explicit timeout loses that timeout, because a foreground run persists nothing and a deadline there loses all its work. The shape it lands in depends on the effective approvalMode (call param, else config), in two outcomes: when a background run is possible (explicit background: false with 'auto'/'writes') the dispatch is switched to background, where the 30-minute default applies; when it is not (an effective 'always', which background cannot present a dialog for, or an omitted background whose approval mode keeps it foreground) the run STAYS FOREGROUND with NO deadline at all, so the call blocks until the child settles instead of being killed. Either outcome is announced to the conductor and the user; pass force: true to keep the explicit timeout. The same judgement is made PER BATCH UNIT: a tasks/chain/graph unit that declares its own high/xhigh thinking level with a positive timeout has that unit's timeout dropped before it runs, while a background fan-out unit keeps its own — there the deadline is the budget. Without that project opt-in the explicit shape and its timeout stand. " +
228
258
  "A background run defaults to a 30-minute deadline when no timeout is given.",
229
259
  }),
230
260
  ),