Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix: avoid duplicating streamed assistant completion text #465

Mergedjamesx0416(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/465/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 2 changed files with 6 additions and 1 deletion.

x
0 of 2 viewed, 2 left
1 addition and 0 deletionsapps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.tsModified
View file
@@ -834,6 +834,7 @@
payload: {
itemType: "assistant_message",
status: "completed",
+ detail: "hello live",
});
​
5 additions and 1 deletionapps/server/src/orchestration/Layers/ProviderRuntimeIngestion.tsModified
View file
@@ -951,6 +951,10 @@
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 @@
createdAt: now,
commandTag: "assistant-complete",
finalDeltaCommandTag: "assistant-delta-finalize",
- ...(assistantCompletion.fallbackText !== undefined
+ ...(assistantCompletion.fallbackText !== undefined && shouldApplyFallbackCompletionText