Skip to content

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

Closed
rifuki wants to merge 1 commit into
decolua:masterfrom
rifuki:fix/responses-done-terminal
Closed

rifuki wants to merge 1 commit into
decolua:masterfrom
rifuki:fix/responses-done-terminal

Conversation

@rifuki

@rifuki rifuki commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • treat response.done as a terminal OpenAI Responses stream event
  • keep emitting the OpenAI data: [DONE] sentinel for same-format Responses passthrough streams
  • add a regression test for response.done

Why

Codex/OpenAI Responses streams can terminate with:

event: response.done
data: {"type":"response.done", ...}

9router already recognizes response.done in some older response conversion paths, but the current Responses passthrough terminal-event helper only accepts response.completed, response.failed, and error. When upstream sends response.done, the stream can be treated as incomplete and a synthetic response.failed may be emitted, which causes clients to surface errors like stream closed before response.completed / stream disconnected before completion.

This patch makes the same-format Responses passthrough path accept response.done as terminal, and restores the [DONE] sentinel for Responses passthrough streams so OpenAI-compatible SSE clients see a clean stream ending.

Related scan

I checked the current open PRs/issues before opening this:

Tests

./node_modules/.bin/vitest run --config tests/vitest.config.js \
  tests/unit/openai-responses-terminal-event.test.js \
  tests/unit/responses-abort-terminal.test.js \
  tests/unit/headroom-responses-format.test.js \
  tests/unit/codex-tool-normalization.test.js

Result: 4 files passed, 11 tests passed.

@decolua

decolua commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Thanks @rifuki! Reviewed and accepted — response.done correctly added to the Responses passthrough terminal-event set, and the data: [DONE] sentinel is restored with proper dedupe guards. Merging into master locally.

@decolua decolua closed this Jun 29, 2026
decolua pushed a commit that referenced this pull request Jun 29, 2026
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>
decolua pushed a commit that referenced this pull request Jun 29, 2026
## Features
- Add Kimchi OAuth provider — Nant361
- Refine Qwen vision/video + thinking model patterns — decolua
- Opt-in Codex auto-ping quota keep-alive — Emirhan

## Fixes
- **Responses**: handle response.done terminal events (#2142) — rifuki
- **Headroom**: skip unsafe responses tool history (#2132) — Sutarto Jordan Chrisfivo
- **Translator**: map mid-conversation system message to user (claude→openai) — decolua
- **Gemini**: normalize contents to prevent 400 invalid_argument (#2192) — warelik
- **Gemini**: backfill thoughtSignature + suppress stream done sentinel — WARELIK
- **Alicode**: preserve cache_control for DashScope providers (#2069) — Rex
- **Antigravity**: strip deprecated/readOnly/writeOnly from tool schemas — iletai, Yudhistira-Official
- **CodeBuddy CN**: show bonus packs as one-time, not monthly-replenishing — whale9820
- **Kiro**: strip leaked <thinking> tags from content stream (#2158) — hamsa0x7
- **Tray**: make Windows context menu DPI-aware — Emirhan
- **Kilocode**: expose full gateway catalog in combo model picker — jellylarper
- **OpenCode**: fix Go GLM — decolua
Vanszs pushed a commit to Vanszs/VansRouter that referenced this pull request Jun 30, 2026
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>
ibanunmangun pushed a commit to ibanunmangun/9router that referenced this pull request Jul 22, 2026
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>
ibanunmangun pushed a commit to ibanunmangun/9router that referenced this pull request Jul 22, 2026
## Features
- Add Kimchi OAuth provider — Nant361
- Refine Qwen vision/video + thinking model patterns — decolua
- Opt-in Codex auto-ping quota keep-alive — Emirhan

## Fixes
- **Responses**: handle response.done terminal events (decolua#2142) — rifuki
- **Headroom**: skip unsafe responses tool history (decolua#2132) — Sutarto Jordan Chrisfivo
- **Translator**: map mid-conversation system message to user (claude→openai) — decolua
- **Gemini**: normalize contents to prevent 400 invalid_argument (decolua#2192) — warelik
- **Gemini**: backfill thoughtSignature + suppress stream done sentinel — WARELIK
- **Alicode**: preserve cache_control for DashScope providers (decolua#2069) — Rex
- **Antigravity**: strip deprecated/readOnly/writeOnly from tool schemas — iletai, Yudhistira-Official
- **CodeBuddy CN**: show bonus packs as one-time, not monthly-replenishing — whale9820
- **Kiro**: strip leaked <thinking> tags from content stream (decolua#2158) — hamsa0x7
- **Tray**: make Windows context menu DPI-aware — Emirhan
- **Kilocode**: expose full gateway catalog in combo model picker — jellylarper
- **OpenCode**: fix Go GLM — decolua
Shinzzyak pushed a commit to Shinzzyak/VansRouter that referenced this pull request Sep 11, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants