From 0d5dec4c6692d885bcd24e158761154b14a10420 Mon Sep 17 00:00:00 2001 From: Tyler Yust Date: Thu, 15 Jan 2026 21:10:52 -0800 Subject: [PATCH] fix: handle async tool start handler rejections Add .catch() to handleToolExecutionStart call to prevent unhandled promise rejections when onAgentEvent or typing signaling fails. --- src/agents/pi-embedded-subscribe.handlers.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/agents/pi-embedded-subscribe.handlers.ts b/src/agents/pi-embedded-subscribe.handlers.ts index b2f35bb3a..92ed49111 100644 --- a/src/agents/pi-embedded-subscribe.handlers.ts +++ b/src/agents/pi-embedded-subscribe.handlers.ts @@ -33,7 +33,10 @@ export function createEmbeddedPiSessionEventHandler(ctx: EmbeddedPiSubscribeCont return; case "tool_execution_start": // Async handler - awaits typing indicator before emitting tool summaries. - void handleToolExecutionStart(ctx, evt as never); + // Catch rejections to avoid unhandled promise rejection crashes. + handleToolExecutionStart(ctx, evt as never).catch((err) => { + ctx.log.debug(`tool_execution_start handler failed: ${String(err)}`); + }); return; case "tool_execution_update": handleToolExecutionUpdate(ctx, evt as never);