Skip to content

fix: handle Azure filter stream chunks#1982

Open
HAYDEN-OAI wants to merge 1 commit into
mainfrom
codex/handle-azure-filter-chunks
Open

fix: handle Azure filter stream chunks#1982
HAYDEN-OAI wants to merge 1 commit into
mainfrom
codex/handle-azure-filter-chunks

Conversation

@HAYDEN-OAI

Copy link
Copy Markdown
Contributor

Summary

  • tolerate Azure async content-filter annotation chunks that omit delta
  • keep empty-ID filter chunks attached to the current streamed completion
  • add a regression test for ChatCompletionStreamingRunner.fromReadableStream()

Why

Azure's asynchronous content filter can interleave annotation-only chunks with normal chat completion chunks. Those annotations may omit delta and use an empty id, which caused the streaming runner to dereference choice.delta and could also make it treat the annotation as a new completion.

Impact

Applications proxying Azure chat completion streams through fromReadableStream() no longer crash or finalize early when async filter annotations arrive. Normal OpenAI and Azure streaming behavior is unchanged.

Validation

  • pnpm exec jest tests/lib/ChatCompletionStream.test.ts --runInBand
  • pnpm exec tsc --noEmit
  • pnpm run lint
  • git diff --check

@HAYDEN-OAI HAYDEN-OAI marked this pull request as ready for review July 6, 2026 22:12
@HAYDEN-OAI HAYDEN-OAI requested a review from a team as a code owner July 6, 2026 22:12
@HAYDEN-OAI HAYDEN-OAI requested a review from apcha-oai July 6, 2026 22:12
@openai-sdks

openai-sdks Bot commented Jul 6, 2026

Copy link
Copy Markdown

OkTest Summary

237/237 SDK tests passed in 10.242s for Node SDK PR #1982.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 140ms
tests/chat-completions-create.test.ts ✅ Passed 241ms
tests/chat-completions-stream.test.ts ✅ Passed 204ms
tests/files-content-binary.test.ts ✅ Passed 162ms
tests/files-create-multipart.test.ts ✅ Passed 137ms
tests/files-list-pagination.test.ts ✅ Passed 160ms
tests/initialize-config.test.ts ✅ Passed 189ms
tests/instance-isolation.test.ts ✅ Passed 107ms
tests/models-list.test.ts ✅ Passed 140ms
tests/responses-background-lifecycle.test.ts ✅ Passed 197ms
tests/responses-body-method-errors.test.ts ✅ Passed 378ms
tests/responses-cancel-timeout.test.ts ✅ Passed 205ms
tests/responses-cancel.test.ts ✅ Passed 178ms
tests/responses-compact-retries.test.ts ✅ Passed 244ms
tests/responses-compact.test.ts ✅ Passed 204ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 122ms
tests/responses-create-advanced.test.ts ✅ Passed 165ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.193s
tests/responses-create-errors.test.ts ✅ Passed 185ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 129ms
tests/responses-create-retries.test.ts ✅ Passed 267ms
tests/responses-create-stream-failures.test.ts ✅ Passed 257ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 2.173s
tests/responses-create-stream-wire.test.ts ✅ Passed 2.586s
tests/responses-create-stream.test.ts ✅ Passed 70ms
tests/responses-create-terminal-states.test.ts ✅ Passed 197ms
tests/responses-create-timeout.test.ts ✅ Passed 226ms
tests/responses-create.test.ts ✅ Passed 138ms
tests/responses-delete.test.ts ✅ Passed 132ms
tests/responses-input-items-errors.test.ts ✅ Passed 200ms
tests/responses-input-items-list.test.ts ✅ Passed 152ms
tests/responses-input-items-options.test.ts ✅ Passed 185ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 328ms
tests/responses-input-tokens-count.test.ts ✅ Passed 218ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.161s
tests/responses-not-found-errors.test.ts ✅ Passed 213ms
tests/responses-parse.test.ts ✅ Passed 159ms
tests/responses-retrieve-retries.test.ts ✅ Passed 286ms
tests/responses-retrieve.test.ts ✅ Passed 209ms
tests/responses-stored-method-errors.test.ts ✅ Passed 492ms
tests/retry-behavior.test.ts ✅ Passed 3.021s
tests/sdk-error-shape.test.ts ✅ Passed 248ms

View OkTest run #28827072571

SDK merge (fd0e0f69b49b) · head (1762e8fabc5f) · base (95b54e589491) · OkTest (7fc645091b1a)

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a5b96f38e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib/ChatCompletionStream.ts
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.

1 participant