diff --git a/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts b/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts index 96242b846c..24409655eb 100644 --- a/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts +++ b/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts @@ -834,6 +834,7 @@ describe("ProviderRuntimeIngestion", () => { payload: { itemType: "assistant_message", status: "completed", + detail: "hello live", }, }); diff --git a/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts b/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts index 022a196674..5a6f71d5e6 100644 --- a/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts +++ b/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts @@ -951,6 +951,10 @@ const make = Effect.gen(function* () { if (assistantCompletion) { const assistantMessageId = assistantCompletion.messageId; const turnId = toTurnId(event.turnId); + const existingAssistantMessage = thread.messages.find((entry) => entry.id === assistantMessageId); + const shouldApplyFallbackCompletionText = + !existingAssistantMessage || + existingAssistantMessage.text.length === 0; if (turnId) { yield* rememberAssistantMessageId(thread.id, turnId, assistantMessageId); } @@ -963,7 +967,7 @@ const make = Effect.gen(function* () { createdAt: now, commandTag: "assistant-complete", finalDeltaCommandTag: "assistant-delta-finalize", - ...(assistantCompletion.fallbackText !== undefined + ...(assistantCompletion.fallbackText !== undefined && shouldApplyFallbackCompletionText ? { fallbackText: assistantCompletion.fallbackText } : {}), });