Skip to content

fix(audio): prefer readable inputs over body metadata - #2548

Open
HAYDEN-OAI wants to merge 2 commits into
mainfrom
dev/hayden/autoimprove-audio-readable-body
Open

fix(audio): prefer readable inputs over body metadata#2548
HAYDEN-OAI wants to merge 2 commits into
mainfrom
dev/hayden/autoimprove-audio-readable-body

Conversation

@HAYDEN-OAI

@HAYDEN-OAI HAYDEN-OAI commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Preserve the documented Node-readable input path in playAudio() when the readable carries an unrelated body field.

The response discriminator previously treated any non-undefined body as a fetch response. A valid Node readable decorated with body: null or Buffer metadata was rejected before ffplay started. If that metadata was itself readable, the helper played the metadata bytes instead of the input stream.

The discriminator now recognizes the outer readable event/flow protocol (pipe, on, pause, and resume) before treating a body field as a response. A Response with an unrelated pipe method still follows its response body, and ended Node readables retain their stream path. Native Response inputs, the existing response-like Node-body path, File inputs, process arguments, and error handling are otherwise unchanged. No generated files, dependencies, exported types, or custom-code budget settings change.

Regression coverage

The existing public-subpath audio suite now covers Node readables with null, Buffer, and readable-stream body metadata. It verifies that the outer stream's audio reaches ffplay, metadata identity is preserved, and readable metadata remains unconsumed.

All three metadata regressions fail before the fix: two reject and one captures the wrong bytes. The review follow-up also reproduces and fixes a Response carrying a callable pipe property, with an already-ended readable as a control. All 46 focused playback/recording tests pass, including the existing Response, File, process-error, source-error, and cancellation controls.

Verification

  • ./scripts/test tests/helpers/audio.test.ts tests/helpers/audio-recording.test.ts — 46 tests passed.
  • pnpm lint — passed.
  • pnpm exec tsc --noEmit — passed.
  • pnpm build — CommonJS and ESM passed.
  • Public built-SDK CJS/ESM matrix on Node 22.0.0, 24.20.0, and 26.7.0: 48 baseline cases confirmed the metadata failures and unchanged controls; all 72 final cases produced the expected bytes or expected missing-body rejection. Final coverage includes native and response-like inputs with extra pipe methods, bodyless Responses with that metadata, and ended Node readables. A local ffplay fixture captured stdin and process invocation counts; no live API, audio hardware, or real credentials were used.
  • An independent scratch build/pack/install check also confirmed the null/Buffer regressions and existing input controls through the actual packed public subpath on all three runtimes and both module formats.
  • Emitted helpers/audio.d.ts and helpers/audio.d.mts are byte-for-byte identical to the baseline packed declarations.
  • CI=true ./scripts/test — 7,014 handwritten tests across 163 files and 556 generated tests across 82 suites passed, plus all 12 snapshots; the existing two generated test skips and one skipped suite are unchanged.

Two adversarial review passes checked protocol precedence, inherited Node stream methods, unchanged Response/File handling and process lifecycle, metadata preservation, unchanged public declarations, and supported runtime behavior. The fix adds no new parser, retained state, or fallback abstraction.

@HAYDEN-OAI
HAYDEN-OAI requested a review from a team as a code owner August 31, 2026 23:21
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T23:40:56.938643Z d06e3bd Manual request
🔒 Security Review Completed 2026-08-31T23:42:24.244295Z d06e3bd Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

32 mixed files remain; 0 existing customizations changed.

Compared eea2292a4a52d06e3bdcc5a4. Generated baselines verified.

32 existing customizations unchanged
  • api.md
  • scripts/castiron/README.md
  • scripts/castiron/custom_code_report.py
  • scripts/castiron/test_custom_code_report.py
  • src/client.ts
  • src/resources/audio/transcriptions.ts
  • src/resources/audio/translations.ts
  • src/resources/beta/assistants.ts
  • src/resources/beta/beta.ts
  • src/resources/beta/index.ts
  • src/resources/beta/responses/internal-base.ts
  • src/resources/beta/responses/responses.ts
  • src/resources/beta/threads/index.ts
  • src/resources/beta/threads/runs/index.ts
  • src/resources/beta/threads/runs/runs.ts
  • src/resources/beta/threads/threads.ts
  • src/resources/chat/completions/completions.ts
  • src/resources/chat/completions/index.ts
  • src/resources/conversations/index.ts
  • src/resources/embeddings.ts
  • src/resources/files.ts
  • src/resources/fine-tuning/checkpoints/permissions.ts
  • src/resources/images.ts
  • src/resources/responses/internal-base.ts
  • src/resources/responses/responses.ts
  • src/resources/skills/skills.ts
  • src/resources/skills/versions/versions.ts
  • src/resources/vector-stores/file-batches.ts
  • src/resources/vector-stores/files.ts
  • src/resources/webhooks/index.ts
  • src/resources/webhooks/webhooks.ts
  • tests/lib/data-residency.test.ts

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download the exact patch produced by this run (requires repository access):

gh run download 33451672913 --repo openai/openai-node \
  --name castiron-custom-code-33451672913-1 --dir /tmp/castiron-custom-code-33451672913-1
git apply --stat /tmp/castiron-custom-code-33451672913-1/custom-code.patch
cat /tmp/castiron-custom-code-33451672913-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin eea2292a4a523da9405161dde0a79ac5dc2ecb2a d06e3bdcc5a441213bb83f4e111aa236272d7887
python3 scripts/castiron/custom_code_report.py report \
  --base eea2292a4a523da9405161dde0a79ac5dc2ecb2a \
  --head d06e3bdcc5a441213bb83f4e111aa236272d7887 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-d06e3bdcc5a4
cat /tmp/castiron-custom-code-d06e3bdcc5a4/custom-code.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

@openai-sdks

openai-sdks Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

237/237 SDK tests passed in 10.187s for Node SDK PR #2548.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 138ms
tests/chat-completions-create.test.ts ✅ Passed 211ms
tests/chat-completions-stream.test.ts ✅ Passed 179ms
tests/files-content-binary.test.ts ✅ Passed 174ms
tests/files-create-multipart.test.ts ✅ Passed 158ms
tests/files-list-pagination.test.ts ✅ Passed 140ms
tests/initialize-config.test.ts ✅ Passed 154ms
tests/instance-isolation.test.ts ✅ Passed 101ms
tests/models-list.test.ts ✅ Passed 132ms
tests/responses-background-lifecycle.test.ts ✅ Passed 226ms
tests/responses-body-method-errors.test.ts ✅ Passed 290ms
tests/responses-cancel-timeout.test.ts ✅ Passed 219ms
tests/responses-cancel.test.ts ✅ Passed 207ms
tests/responses-compact-retries.test.ts ✅ Passed 255ms
tests/responses-compact.test.ts ✅ Passed 179ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 113ms
tests/responses-create-advanced.test.ts ✅ Passed 193ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.095s
tests/responses-create-errors.test.ts ✅ Passed 173ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 163ms
tests/responses-create-retries.test.ts ✅ Passed 239ms
tests/responses-create-stream-failures.test.ts ✅ Passed 211ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 2.148s
tests/responses-create-stream-wire.test.ts ✅ Passed 2.493s
tests/responses-create-stream.test.ts ✅ Passed 105ms
tests/responses-create-terminal-states.test.ts ✅ Passed 215ms
tests/responses-create-timeout.test.ts ✅ Passed 239ms
tests/responses-create.test.ts ✅ Passed 173ms
tests/responses-delete.test.ts ✅ Passed 232ms
tests/responses-input-items-errors.test.ts ✅ Passed 170ms
tests/responses-input-items-list.test.ts ✅ Passed 179ms
tests/responses-input-items-options.test.ts ✅ Passed 112ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 245ms
tests/responses-input-tokens-count.test.ts ✅ Passed 273ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.144s
tests/responses-not-found-errors.test.ts ✅ Passed 236ms
tests/responses-parse.test.ts ✅ Passed 206ms
tests/responses-retrieve-retries.test.ts ✅ Passed 301ms
tests/responses-retrieve.test.ts ✅ Passed 234ms
tests/responses-stored-method-errors.test.ts ✅ Passed 550ms
tests/retry-behavior.test.ts ✅ Passed 3.032s
tests/sdk-error-shape.test.ts ✅ Passed 251ms

View OkTest run #33451573841

SDK merge (2d99bbb73b10) · head (d06e3bdcc5a4) · base (eea2292a4a52) · OkTest (2b1bdfd25e98)

@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: 6445c0787c

ℹ️ 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/helpers/audio.ts Outdated
@HAYDEN-OAI

Copy link
Copy Markdown
Contributor Author

@codex review

Addressed the Response compatibility finding in d06e3bd. The discriminator now checks the readable event/flow protocol (pipe, on, pause, resume) rather than a lone pipe method, without using stream liveness or an instanceof restriction.

The new decorated-Response regression fails on the prior head and passes now; an already-ended readable with body metadata remains accepted. Validation: 46 focused audio tests, 7,014 handwritten plus 556 generated tests, lint, strict type checking, CJS/ESM builds, unchanged public declarations, and 72 built-SDK CJS/ESM input cases on Node 22.0.0, 24.20.0, and 26.7.0.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: d06e3bdcc5

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: d06e3bdcc5

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants