fix: avoid duplicating streamed assistant completion text (#465)
This commit is contained in:
1 parent
40a7f4b4b1
commit
57aa6bf16c
2 files changed
+6
-1
No files matched your search
@@ -834,6 +834,7 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
payload: {
|
||||
itemType: "assistant_message",
|
||||
status: "completed",
|
||||
detail: "hello live",
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -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 }
|
||||
: {}),
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user