From 340e87ddbb517715e0c2ad26b03bc5d5e3be321d Mon Sep 17 00:00:00 2001 From: Evan Jacobson Date: Sun, 15 Feb 2026 14:42:03 -0700 Subject: [PATCH 1/2] fix: remove duplicate text yield in OpenAI non-streaming mode The non-streaming path in OpenAiHandler.createMessage() yielded message.content as a "text" chunk twice: once in the kilocode_change block (lines 272-277) added for reasoning support, and again in the original code (lines 294-297). Since Task.ts accumulates text via `assistantMessage += chunk.text`, this caused the entire response to appear duplicated when streaming was disabled. Remove the redundant yield and update the test to use .filter() instead of .find() so duplicate text chunks are caught by assertions. --- src/api/providers/__tests__/openai.spec.ts | 6 +++--- src/api/providers/openai.ts | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/api/providers/__tests__/openai.spec.ts b/src/api/providers/__tests__/openai.spec.ts index c67e2e086af..644457c57e0 100644 --- a/src/api/providers/__tests__/openai.spec.ts +++ b/src/api/providers/__tests__/openai.spec.ts @@ -148,11 +148,11 @@ describe("OpenAiHandler", () => { } expect(chunks.length).toBeGreaterThan(0) - const textChunk = chunks.find((chunk) => chunk.type === "text") + const textChunks = chunks.filter((chunk) => chunk.type === "text") const usageChunk = chunks.find((chunk) => chunk.type === "usage") - expect(textChunk).toBeDefined() - expect(textChunk?.text).toBe("Test response") + expect(textChunks).toHaveLength(1) + expect(textChunks[0]?.text).toBe("Test response") expect(usageChunk).toBeDefined() expect(usageChunk?.inputTokens).toBe(10) expect(usageChunk?.outputTokens).toBe(5) diff --git a/src/api/providers/openai.ts b/src/api/providers/openai.ts index 8b36bce9d25..db36171d79b 100644 --- a/src/api/providers/openai.ts +++ b/src/api/providers/openai.ts @@ -291,11 +291,6 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl } } - yield { - type: "text", - text: message?.content || "", - } - yield this.processUsageMetrics(response.usage, modelInfo) } } From e29306d8f4ca9b5a0f9ad714b867a81ae5df17cb Mon Sep 17 00:00:00 2001 From: Evan Jacobson Date: Sun, 15 Feb 2026 17:15:21 -0700 Subject: [PATCH 2/2] Changeset --- .changeset/ready-taxis-hide.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/ready-taxis-hide.md diff --git a/.changeset/ready-taxis-hide.md b/.changeset/ready-taxis-hide.md new file mode 100644 index 00000000000..eded0dc805e --- /dev/null +++ b/.changeset/ready-taxis-hide.md @@ -0,0 +1,5 @@ +--- +"kilo-code": patch +--- + +Fix duplicate text output when using OpenAI-compatible providers with streaming disabled.