Skip to content

fix(voice): reject non-positive audio frame rates - #4382

Merged
seratch merged 1 commit into
openai:mainfrom
hsusul:fix/conversations-nonpositive-history-limit
Aug 13, 2026
Merged

fix(voice): reject non-positive audio frame rates#4382
seratch merged 1 commit into
openai:mainfrom
hsusul:fix/conversations-nonpositive-history-limit

Conversation

@hsusul

@hsusul hsusul commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

_buffer_to_audio_file validates sample width, buffer dtype, channel count, and multichannel frame completeness, but previously did not validate the frame rate. A zero or negative frame_rate reached wave.setframerate and surfaced as a low-level wave.Error instead of the UserError used by the adjacent input validations.

This adds an up-front frame_rate <= 0 check so invalid rates fail consistently and actionably. Valid audio conversion is unchanged.

The earlier negative-history-limit changes have been removed to preserve the released SQLite behavior documented by v0.20.0 and #4001.

Test plan

  • Added test_audio_input_rejects_non_positive_frame_rate, parametrized over 0 and -8000.
  • uv run pytest -q tests/voice/test_input.py — 24 passed.
  • env UV_DEFAULT_INDEX=https://pypi.org/simple bash .agents/skills/code-change-verification/scripts/run.sh — passed:
    • Ruff format: 897 files unchanged.
    • Ruff lint: passed.
    • mypy and Pyright: passed.
    • Full test suite: passed.
  • git diff --check — passed.

Issue number

None.

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • If using Codex, I've run /review before submitting this PR

@seratch seratch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@hsusul Thanks for suggesting this but your another PR #4383 is quite similar, so we may want to avoid taking our time to review these small PRs one by one. If you don't mind, can you do thorough investigation to detect similar opportunities to improve and include all of them in this PR?

@seratch seratch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for expanding this after the earlier review. I reran the new tests against the merge base: the frame-rate test demonstrates a real, bounded exception-contract gap, but the negative-history work should not be included. v0.20.0 and #4001 intentionally preserve SQLite's historical negative-limit behavior (limit=-1 returns all items), while this branch changes it to an empty history. The OpenAI-specific negative case is not a demonstrated supported scenario, and silently treating invalid negative input as no history is not a safe cross-backend compatibility fix.

Please keep the frame-rate validation and regression test, remove both negative-limit commits and their tests, and update the title and description to the remaining voice scope. This preserves released session behavior while retaining the demonstrated improvement.

_buffer_to_audio_file validates sample width, dtype, channel count, and
frame completeness, but not the frame rate. A frame rate of 0 or a negative
value reached wave.setframerate and surfaced as a low-level wave.Error rather
than the UserError contract the other input validations raise. Reject a
non-positive frame rate up front so the failure is consistent and actionable.
@hsusul
hsusul force-pushed the fix/conversations-nonpositive-history-limit branch from 340cedc to 17a8814 Compare August 13, 2026 04:56
@hsusul hsusul changed the title fix(memory): treat negative conversation history limits as empty fix(voice): reject non-positive audio frame rates Aug 13, 2026
FU-max-boop

This comment was marked as off-topic.

@seratch seratch added this to the 0.21.x milestone Aug 13, 2026
@seratch
seratch merged commit 6bef354 into openai:main Aug 13, 2026
14 checks passed
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.

3 participants