Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix: avoid duplicating streamed assistant completion text (#465)

James57aa6bf16cd0
diff --git a/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts b/apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts
index 96242b846..24409655e 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 022a19667..5a6f71d5e 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 }
: {}),
});