authorgravatar for 105842516+jamesx0416@users.noreply.github.comJames <105842516+jamesx0416@users.noreply.github.com> 2026-03-09 10:29:34+11:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-03-08 16:29:34-07:00
log57aa6bf16cd0dcfbe9037a5ca29ad61bdd2a857e
treeefc0c4a009cdb7201691ce5114a406d844f530d1
parent40a7f4b4b1780c24db24a201f5b0860ce9763028
signature Signed by PGP key B5690EEEBB952194

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


2 files changed, 6 insertions(+), 1 deletions(-)

apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts+1
...@@ -834,6 +834,7 @@ describe("ProviderRuntimeIngestion", () => {...@@ -834,6 +834,7 @@ describe("ProviderRuntimeIngestion", () => {
834 payload: {834 payload: {
835 itemType: "assistant_message",835 itemType: "assistant_message",
836 status: "completed",836 status: "completed",
837 detail: "hello live",
837 },838 },
838 });839 });
839840
apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts+5-1
...@@ -951,6 +951,10 @@ const make = Effect.gen(function* () {...@@ -951,6 +951,10 @@ const make = Effect.gen(function* () {
951 if (assistantCompletion) {951 if (assistantCompletion) {
952 const assistantMessageId = assistantCompletion.messageId;952 const assistantMessageId = assistantCompletion.messageId;
953 const turnId = toTurnId(event.turnId);953 const turnId = toTurnId(event.turnId);
954 const existingAssistantMessage = thread.messages.find((entry) => entry.id === assistantMessageId);
955 const shouldApplyFallbackCompletionText =
956 !existingAssistantMessage ||
957 existingAssistantMessage.text.length === 0;
954 if (turnId) {958 if (turnId) {
955 yield* rememberAssistantMessageId(thread.id, turnId, assistantMessageId);959 yield* rememberAssistantMessageId(thread.id, turnId, assistantMessageId);
956 }960 }
...@@ -963,7 +967,7 @@ const make = Effect.gen(function* () {...@@ -963,7 +967,7 @@ const make = Effect.gen(function* () {
963 createdAt: now,967 createdAt: now,
964 commandTag: "assistant-complete",968 commandTag: "assistant-complete",
965 finalDeltaCommandTag: "assistant-delta-finalize",969 finalDeltaCommandTag: "assistant-delta-finalize",
966 ...(assistantCompletion.fallbackText !== undefined970 ...(assistantCompletion.fallbackText !== undefined && shouldApplyFallbackCompletionText
967 ? { fallbackText: assistantCompletion.fallbackText }971 ? { fallbackText: assistantCompletion.fallbackText }
968 : {}),972 : {}),
969 });973 });