Skip to content

fix(helpers): propagate audio stream producer errors - #3817

Open
Hughhhhcoder wants to merge 1 commit into
openai:mainfrom
Hughhhhcoder:codex/openai-python-audio-producer-failure
Open

fix(helpers): propagate audio stream producer errors#3817
Hughhhhcoder wants to merge 1 commit into
openai:mainfrom
Hughhhhcoder:codex/openai-python-audio-producer-failure

Conversation

@Hughhhhcoder

@Hughhhhcoder Hughhhhcoder commented Sep 8, 2026

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

Changes being requested

LocalAudioPlayer.play_stream() currently waits only for the audio callback's completion event before it awaits the input producer task. If the supplied async generator raises, the producer task finishes with that exception but no one sets the playback event, so the public method hangs and asyncio reports that the task exception was never retrieved.

This change waits for playback completion and producer completion together. A producer failure is propagated immediately; normal producer completion still waits for the callback to consume the queued completion sentinel, so buffered playback behavior is unchanged. The cleanup path also cancels and retrieves either internal task when the caller exits early.

A hardware-free regression replaces sounddevice.OutputStream with a silent context manager and verifies that a synthetic input-generator failure reaches the caller instead of timing out.

Validation:

  • uv run --locked --all-extras pytest -q tests/test_local_audio_player.py tests/lib/test_audio.py — 5 passed on Python 3.10.
  • The same focused command with uv run --isolated --python 3.14 — 5 passed.
  • ./scripts/lint with the repository-pinned Node.js 22.22.3 — Ruff passed; Pyright reported 0 errors; Mypy reported no issues in 1614 source files; import check passed.
  • Reproduction against unmodified main: the same input timed out after 200 ms and emitted Task exception was never retrieved for the original RuntimeError.

The generated API audio tests require the repository's Steady mock server. They were not counted as passing in this environment; without that server they returned HTTP 502 before exercising this helper.

Additional context & links

The affected file is under src/openai/helpers/, which CONTRIBUTING.md identifies as hand-maintained code. I searched open and closed issues and pull requests for play_stream producer failures and did not find an existing fix. Existing audio-helper PRs concern get_running_loop() or array shape handling rather than this failure path.

@Hughhhhcoder
Hughhhhcoder requested a review from a team as a code owner September 8, 2026 04:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 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-09-08T04:42:31.545616Z 54eb21e PR opened
🔒 Security Review Completed 2026-09-08T04:43:05.105278Z 54eb21e PR opened
ℹ️ 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.

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