From f6fafeee3879a0a0b0ede958fc08c004f2097b99 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 17 Oct 2025 14:55:24 +0000 Subject: [PATCH 1/2] Initial plan From a95280993fbd86834e71b5a34daa6c25504fbaba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 17 Oct 2025 15:02:13 +0000 Subject: [PATCH 2/2] Fix missing model field in first streaming response --- src/routes/chat-completions/handler.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/routes/chat-completions/handler.ts b/src/routes/chat-completions/handler.ts index 04a5ae9ed..f1a675989 100644 --- a/src/routes/chat-completions/handler.ts +++ b/src/routes/chat-completions/handler.ts @@ -1,7 +1,7 @@ import type { Context } from "hono" import consola from "consola" -import { streamSSE, type SSEMessage } from "hono/streaming" +import { streamSSE } from "hono/streaming" import { awaitApproval } from "~/lib/approval" import { checkRateLimit } from "~/lib/rate-limit" @@ -56,9 +56,22 @@ export async function handleCompletion(c: Context) { consola.debug("Streaming response") return streamSSE(c, async (stream) => { - for await (const chunk of response) { - consola.debug("Streaming chunk:", JSON.stringify(chunk)) - await stream.writeSSE(chunk as SSEMessage) + for await (const rawEvent of response) { + consola.debug("Copilot raw stream event:", JSON.stringify(rawEvent)) + if (rawEvent.data === "[DONE]") { + await stream.writeSSE({ + data: "[DONE]", + }) + break + } + + if (!rawEvent.data) { + continue + } + + await stream.writeSSE({ + data: rawEvent.data, + }) } }) }