Skip to content

Commit 3cfab54

Browse files
SebTardifsteipete
authored andcommitted
fix: log subagent swallowed errors in hook emission and restore paths
Wire createSubsystemLogger into the two silent catch blocks that discard errors during subagent lifecycle: 1. emitSubagentEndedHookOnce (subagent-registry-completion.ts): catch { return false } -> catch (err) { log.warn(...); return false } 2. restoreSubagentRunsOnce (subagent-registry.ts): catch { /* ignore */ } -> catch (err) { log.warn(...) } Both paths now log the error message before continuing, providing a diagnostic trail when hook emission or disk restore fails silently. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent f68ed72 commit 3cfab54

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/agents/subagent-registry-completion.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { createSubsystemLogger } from "../logging/subsystem.js";
12
import { getGlobalHookRunner } from "../plugins/hook-runner-global.js";
23
import type { SubagentRunOutcome } from "./subagent-announce-output.js";
34
import {
@@ -10,6 +11,8 @@ import {
1011
} from "./subagent-lifecycle-events.js";
1112
import type { SubagentRunRecord } from "./subagent-registry.types.js";
1213

14+
const log = createSubsystemLogger("agents/subagent-registry-completion");
15+
1316
export function runOutcomesEqual(
1417
a: SubagentRunOutcome | undefined,
1518
b: SubagentRunOutcome | undefined,
@@ -113,7 +116,10 @@ export async function emitSubagentEndedHookOnce(params: {
113116
params.entry.endedHookEmittedAt = Date.now();
114117
params.persist();
115118
return true;
116-
} catch {
119+
} catch (err) {
120+
log.warn(
121+
`failed to emit subagent_ended hook for run ${runId}: ${err instanceof Error ? err.message : String(err)}`,
122+
);
117123
return false;
118124
} finally {
119125
params.inFlightRunIds.delete(runId);

src/agents/subagent-registry.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,10 @@ function restoreSubagentRunsOnce() {
646646
// Cold-start restore path: queue the same recovery pass that restart
647647
// startup also uses so resumed children are handled through one seam.
648648
scheduleSubagentOrphanRecovery();
649-
} catch {
650-
// ignore restore failures
649+
} catch (err) {
650+
log.warn(
651+
`failed to restore subagent runs from disk: ${err instanceof Error ? err.message : String(err)}`,
652+
);
651653
}
652654
}
653655

0 commit comments

Comments
 (0)