From 60871f7ca75c1a7928a252123ba01d9ba3fbef4c Mon Sep 17 00:00:00 2001 From: Noa Flaherty Date: Tue, 24 Feb 2026 14:08:24 -0500 Subject: [PATCH] fix: create macOS delivery row before awaiting LLM copy generation Co-Authored-By: Claude --- assistant/src/calls/guardian-dispatch.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/assistant/src/calls/guardian-dispatch.ts b/assistant/src/calls/guardian-dispatch.ts index d3944595eb7..f81132d44a3 100644 --- a/assistant/src/calls/guardian-dispatch.ts +++ b/assistant/src/calls/guardian-dispatch.ts @@ -115,9 +115,9 @@ export async function dispatchGuardianQuestion(params: GuardianDispatchParams): // Create delivery rows and dispatch for (const dest of destinations) { if (dest.channel === 'macos') { - const guardianCopy = await guardianCopyPromise; - - // Create a dedicated server-side conversation for the mac guardian thread + // Create conversation and delivery row synchronously so they exist + // before awaiting LLM copy — prevents a race where an external channel + // reply resolves the request before the macOS delivery is created. const macConvKey = `asst:${assistantId}:guardian:request:${request.id}`; const { conversationId: macConversationId } = getOrCreateConversation(macConvKey); @@ -127,6 +127,9 @@ export async function dispatchGuardianQuestion(params: GuardianDispatchParams): destinationConversationId: macConversationId, }); + // Now await LLM-generated copy for the message content and thread title + const guardianCopy = await guardianCopyPromise; + // Add the guardian question as the initial message in the thread addMessage( macConversationId,