Skip to content

Handle keepalive events in Responses streams#1965

Merged
HAYDEN-OAI merged 1 commit into
openai:mainfrom
koriyoshi2041:fix-response-stream-keepalive
Jul 6, 2026
Merged

Handle keepalive events in Responses streams#1965
HAYDEN-OAI merged 1 commit into
openai:mainfrom
koriyoshi2041:fix-response-stream-keepalive

Conversation

@koriyoshi2041

Copy link
Copy Markdown
Contributor

Problem
Responses streaming can receive keepalive SSE events on long-running requests. They do not carry Response state, but the accumulator currently falls through to the exhaustive error path and ends the stream. Fixes #1964.

Fix
Treat keepalive as a no-op accumulator event, alongside other stream events that do not map onto the Response snapshot. Unknown event types still go through the existing error path.

Test

  • pnpm test tests/lib/ResponseAccumulator.test.ts
  • pnpm exec prettier --check src/lib/responses/ResponseAccumulator.ts tests/lib/ResponseAccumulator.test.ts
  • pnpm build
  • git diff --check

Risk
Low. This only ignores the explicit keepalive event; it does not change handling for normal response deltas or undocumented unknown event types.

@HAYDEN-OAI HAYDEN-OAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the thoughtful fix and the focused regression test. this is a nice, narrowly scoped way to handle keepalive events while preserving the error path for genuinely unknown events. great work!

@HAYDEN-OAI HAYDEN-OAI merged commit dac0368 into openai:main Jul 6, 2026
10 checks passed
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.

v6.45.0 can't handle stream keepalive events

2 participants