fix(responses): handle response.done terminal events (#2142)

Treat response.done as a terminal OpenAI Responses stream event so
passthrough streams ending with response.done are not flagged incomplete
and no synthetic response.failed is emitted. Restore the data: [DONE]
sentinel for same-format Responses passthrough streams.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
rifukiandCursor authored and decolua committed 2026-06-29 16:05:29 +07:00
1 parent 373850ee36
commit a9785a5f70
3 files changed
+26 -5

No files matched your search

@@ -67,6 +67,19 @@ describe("OpenAI Responses streaming termination", () => {
expect(output).toContain("data: [DONE]");
});
it("does not add response.failed when a Responses stream sends response.done", async () => {
const output = await runTransform([
`event: response.done`,
`data: ${JSON.stringify({ type: "response.done", response: { id: "resp_test" } })}`,
"",
].join("\n"));
expect(output).toContain("event: response.done");
expect(output).not.toContain("event: response.failed");
expect(output).not.toContain("data: null");
expect(output).toContain("data: [DONE]");
});
it("emits response.failed before DONE when a Responses stream sends DONE without a terminal event", async () => {
const output = await runTransform([
`event: response.created`,