Skip to content

feat: add fromReadableStream to ResponseStream#1987

Merged
HAYDEN-OAI merged 3 commits into
openai:mainfrom
morgan-coded:fix/1376-response-stream-readable
Jul 13, 2026
Merged

feat: add fromReadableStream to ResponseStream#1987
HAYDEN-OAI merged 3 commits into
openai:mainfrom
morgan-coded:fix/1376-response-stream-readable

Conversation

@morgan-coded

Copy link
Copy Markdown
Contributor
  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

ResponseStream does not have the same readable-stream rehydration helper that ChatCompletionStream and AssistantStream expose, so callers proxying newline-delimited response stream events cannot turn them back into a ResponseStream. This adds ResponseStream.fromReadableStream() and a protected _fromReadableStream() path that reads ResponseStreamEvent values through Stream.fromReadableStream() and feeds them through the existing response-stream event handling. Generated response resources stay unchanged.

Additional context & links

Fixes #1376

@morgan-coded
morgan-coded requested a review from a team as a code owner July 8, 2026 22:40
Copilot AI review requested due to automatic review settings July 8, 2026 22:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@HAYDEN-OAI

Copy link
Copy Markdown
Contributor

pushed a follow-up fix for cancellation. Stream.fromReadableStream now holds the source reader and cancels it when the runner aborts, so ResponseStream.fromReadableStream will not hang on a stalled proxy body. i also added a regression test that verifies the source stream is canceled and done() rejects with APIUserAbortError.

@HAYDEN-OAI
HAYDEN-OAI merged commit 5984f44 into openai:main Jul 13, 2026
10 checks passed
@stainless-app stainless-app Bot mentioned this pull request Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants