fix(voice): expand speech buffer to 60s, handle 2.1 cancellation race, and bound cleanup

- Expand max_input_buffer_bytes to 3,072,000 (64s at 24kHz PCM16) with 65s fixed deadline
- Broaden response_cancel_not_active race classifier to include gpt-realtime-2.1/shimmer
- Add transport abort method and bound cleanup waits during websocket close
- Record repair progress in docs/plans/live-conversation-repair-progress.md
This commit is contained in:
amirhosein mazaheri
2026-10-12 18:51:06 +03:30
parent d493752b81
commit 9e6864ae2a
14 changed files with 203 additions and 19 deletions
+29 -3
View File
@@ -121,7 +121,7 @@ def test_capacity_diagnostics_identify_the_failure_without_payloads(runner, pers
await runtime.input_audio(bytes(9600))
reason = "CAPTURE_TRANSPORT_CAPACITY"
elif branch == "late_start":
await stream(runtime, 1500, now)
await stream(runtime, 3300, now)
await runtime.handle(dict(type="input_audio_buffer.speech_started",
item_id="private-input-id", audio_start_ms=0))
reason = "UNCOMMITTED_SPEECH_BYTES"
@@ -129,12 +129,12 @@ def test_capacity_diagnostics_identify_the_failure_without_payloads(runner, pers
await runtime.handle(dict(type="input_audio_buffer.speech_started",
item_id="private-input-id", audio_start_ms=0))
# Fixed clock isolates the byte bound from the independent wall deadline.
for _ in range(50):
for _ in range(320):
await runtime.input_audio(bytes(9600))
async with asyncio.timeout(3):
while runtime.input_transport_count:
await asyncio.sleep(0)
assert runtime.uncommitted_speech_bytes == 480000
assert runtime.uncommitted_speech_bytes == 3072000
await runtime.input_audio(bytes(2))
reason = "UNCOMMITTED_SPEECH_BYTES"
assert runtime.failure == "LIVE_BUFFER_OVERFLOW" and runtime.close_code == 1013
@@ -146,3 +146,29 @@ def test_capacity_diagnostics_identify_the_failure_without_payloads(runner, pers
finally:
await runtime.close()
asyncio.run(scenario())
@pytest.mark.parametrize("speech_seconds", [10, 30, 60])
def test_continuous_speech_with_padding_reaches_new_bound(runner, persisted, speech_seconds):
async def scenario():
now = [0.]
runtime, _, _ = await make(SimpleNamespace(engine=None), runner, persisted,
clock=lambda: now[0])
try:
await runtime.handle(dict(type="input_audio_buffer.speech_started",
item_id="u1", audio_start_ms=0))
turn = runtime.current
assert turn.speech_deadline == 65
# Four seconds covers the maximum configured VAD prefix/silence padding.
for _ in range((speech_seconds + 4) * 5):
await runtime.input_audio(bytes(9600))
await until(lambda: runtime.input_transport_count == 0)
now[0] += .2
assert runtime.usable
assert runtime.uncommitted_speech_bytes == (speech_seconds + 4) * 48000
await runtime.handle(dict(type="input_audio_buffer.speech_stopped",
item_id="u1", audio_end_ms=(speech_seconds + 4) * 1000))
await runtime.handle(dict(type="input_audio_buffer.committed", item_id="u1"))
assert turn.committed and runtime.uncommitted_speech_bytes == 0
finally:
await runtime.close()
asyncio.run(scenario())