fix(voice): reject non-positive audio frame rates - #4382
Conversation
seratch
left a comment
There was a problem hiding this comment.
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.
340cedc to
17a8814
Compare
Summary
_buffer_to_audio_filevalidates sample width, buffer dtype, channel count, and multichannel frame completeness, but previously did not validate the frame rate. A zero or negativeframe_ratereachedwave.setframerateand surfaced as a low-levelwave.Errorinstead of theUserErrorused by the adjacent input validations.This adds an up-front
frame_rate <= 0check 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
test_audio_input_rejects_non_positive_frame_rate, parametrized over0and-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:git diff --check— passed.Issue number
None.
Checks
.agents/skills/code-change-verification/scripts/run.sh/reviewbefore submitting this PR