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", () => {
834834 payload: {
835835 itemType: "assistant_message",
836836 status: "completed",
837 detail: "hello live",
837838 },
838839 });
839840
apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts+5-1
......@@ -951,6 +951,10 @@ const make = Effect.gen(function* () {
951951 if (assistantCompletion) {
952952 const assistantMessageId = assistantCompletion.messageId;
953953 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;
954958 if (turnId) {
955959 yield* rememberAssistantMessageId(thread.id, turnId, assistantMessageId);
956960 }
......@@ -963,7 +967,7 @@ const make = Effect.gen(function* () {
963967 createdAt: now,
964968 commandTag: "assistant-complete",
965969 finalDeltaCommandTag: "assistant-delta-finalize",
966 ...(assistantCompletion.fallbackText !== undefined
970 ...(assistantCompletion.fallbackText !== undefined && shouldApplyFallbackCompletionText
967971 ? { fallbackText: assistantCompletion.fallbackText }
968972 : {}),
969973 });