WebRTC audio clear can replay a stashed output chunk

Author: andimarafiotiCreated Aug 9, 2026Updated Sep 28, 2026

Bug

The WebRTC output_audio_buffer.clear handler flushes unit.output_queue and calls transport.discard_pending_audio(), but it does not clear an audio chunk already held in unit.session.pending_output_item by the router send loop.

On the next send-loop iteration, that stashed chunk is consumed before output_queue, so audio can still be delivered after the client explicitly cleared the output buffer.

Expected behavior

output_audio_buffer.clear should discard all pending server-side audio, including a stashed router item, while preserving non-audio lifecycle/control events.

Notes

This was found while reviewing #453, but the pending-item behavior and clear handler both predate that PR and the bug reproduces independently of ordered assistant output. It is intentionally reported separately to keep #309 scoped.

Source: huggingface/speech-to-speech