Skip to content

Commit ec5e666

Browse files
committed
fix(deepseek): exclude WebSocket turns from the HTTP SSE synthesis (#875)
1 parent 1d06d70 commit ec5e666

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/server/responses/core.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,6 +2251,7 @@ async function handleResponsesInner(
22512251
// terminal → [DONE]) so Codex commits the turn instead of hanging on a
22522252
// stream that never closes. Non-streaming clients keep the plain JSON.
22532253
if (clientRequestedStream === true
2254+
&& options.inboundTransport !== "websocket"
22542255
&& providerModelResponsesUpstreamStreaming(route.providerName, route.provider, route.modelId) === false
22552256
&& route.provider.adapter === "openai-responses") {
22562257
try {

tests/deepseek-inbound-wire.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,27 @@ describe("the inbound scope survives the handleResponses replay", () => {
132132
expect(request.body.stream).toBe(false);
133133
});
134134

135+
test("a Codex WebSocket turn keeps plain JSON downstream (no SSE synthesis)", async () => {
136+
globalThis.fetch = (async () => Response.json({
137+
id: "resp_deepseek",
138+
object: "response",
139+
status: "completed",
140+
output: [],
141+
})) as typeof fetch;
142+
const config = { providers: { deepseek: deepseekProvider() } } as unknown as OcxConfig;
143+
const response = await handleResponses(
144+
new Request("http://localhost/v1/responses", {
145+
method: "POST",
146+
headers: { "content-type": "application/json" },
147+
body: JSON.stringify({ model: MODEL, input: "ping", stream: true }),
148+
}),
149+
config,
150+
{ model: "", provider: "" },
151+
{ inboundTransport: "websocket" },
152+
);
153+
expect(response.headers.get("content-type")).not.toContain("text/event-stream");
154+
});
155+
135156
test("ordinary HTTP Responses requests also use bounded JSON upstream (#875)", async () => {
136157
// The reliability policy is transport-neutral: DeepSeek's Responses stream can
137158
// deliver output without a terminal, so HTTP turns get the same bounded JSON

0 commit comments

Comments
 (0)