From e7fd0a7b21e7c18a94f7dba3edff86621b969f09 Mon Sep 17 00:00:00 2001 From: zidongdesign Date: Sun, 8 Mar 2026 14:06:01 +0800 Subject: [PATCH] fix: wrap compaction start notice onBlockReply in try/catch to prevent unhandled rejection onAgentEvent is fired fire-and-forget (void ctx.params.onAgentEvent?.(...) in pi-embedded-subscribe.handlers.compaction.ts), so any rejection from the awaited onBlockReply call would escape unobserved. Wrap the delivery in a try/catch that swallows the error and logs a warning via params.logger, consistent with other non-critical notice delivery paths. --- src/auto-reply/reply/agent-runner-execution.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/auto-reply/reply/agent-runner-execution.ts b/src/auto-reply/reply/agent-runner-execution.ts index 9998cca29d3..1b7e486a446 100644 --- a/src/auto-reply/reply/agent-runner-execution.ts +++ b/src/auto-reply/reply/agent-runner-execution.ts @@ -430,7 +430,15 @@ export async function runAgentTurnWithFallback(params: { replyToCurrent: true, isCompactionNotice: true, }); - await params.opts.onBlockReply(noticePayload); + try { + await params.opts.onBlockReply(noticePayload); + } catch (err) { + // Non-critical notice delivery failure should not + // bubble out of the fire-and-forget event handler. + logVerbose( + `compaction start notice delivery failed (non-fatal): ${String(err)}`, + ); + } } } const completed = evt.data?.completed === true;