fix: handle async tool start handler rejections

Add .catch() to handleToolExecutionStart call to prevent unhandled
promise rejections when onAgentEvent or typing signaling fails.
This commit is contained in:
Tyler Yust
2026-01-15 21:10:52 -08:00
parent 2ee71e4154
commit 0d5dec4c66

View File

@@ -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);