RealtimeAudioWebSocketVoice Agents

Keep unheard speech out of a Realtime conversation after interruption

Realtime WebSocket interruption requires immediate playback stop, queue cleanup, and history truncation at the played position. Generation and tool state need separate handling.

Keep unheard speech out of a Realtime conversation after interruption

An assistant has generated eight seconds of speech when the user interrupts after two. Muting the speaker alone can leave the model assuming everything was heard; canceling generation alone can leave queued audio playing. A Realtime WebSocket client must reconcile playback and conversation history at the position actually played.

Reviewed November 24, 2026 against OpenAI's interruption and truncation guidance, VAD guide, and Nbility's Realtime documentation. Events and arithmetic were checked offline only. No live session or device-level playback measurement was performed.

What do cancellation, playback stop, and truncation change?

They change different states. Generation can run faster than playback, so receiving eight seconds of audio does not mean the user heard eight seconds.

ActionState changedDoes not establish
Cancel an in-progress responseServer generationLocal playback queue is empty
Stop and discard queued audioWhat can be heard nextUnheard content is absent from history
conversation.item.truncateConversation audio itemAn external business action was undone

With automatic VAD interruption enabled, user speech cancels the in-progress response. If automatic interruption is disabled or push-to-talk is implemented manually, follow that flow's cancellation steps. See VAD response controls; do not disable interrupt_response while assuming the server will still interrupt automatically.

Generation, playback queue, and conversation history are three separate states to reconcile

What should a WebSocket client do on speech_started?

Stop the interrupted item's playback immediately, discard its queued audio, then send truncation using its played duration. OpenAI's guide starts this work on input_audio_buffer.speech_started; cancellation completion is not a prerequisite.

  1. Identify the playing item_id, audio content_index, and played position.
  2. Stop that item, discard its queue, and prevent late audio for it from being queued again.
  3. Send conversation.item.truncate and record the item and position.
  4. For automatic interruption, observe response.done with response.status set to cancelled. Use it to observe completion, not to delay stopping playback.

This illustrative event retains the first 1.5 seconds of one audio content part. Replace the ID with the actual playing item and use its real content index:

{
  "type": "conversation.item.truncate",
  "item_id": "item_demo_audio",
  "content_index": 0,
  "audio_end_ms": 1500
}

The time is relative to that audio content, not page load or the entire recording. Discard late deltas by their item and response identity rather than accidentally clearing the next response.

Speech onset triggers immediate stop and queue removal, then truncation; cancellation completion is observed separately

Can audio_end_ms come from downloaded audio length?

No. Received or queued audio is not a record of what has played. Use playback progress, consumed sample frames, or an appropriate device clock, accounting for pauses, underruns, and output buffering.

For an offline arithmetic example, 36,000 played sample frames at 24,000 Hz represent:

36,000 frames / 24,000 frames per second × 1,000 = 1,500 ms

This assumes the stated format; it is not every model's sample rate and cannot turn downloaded bytes into an audible position. A multichannel frame includes one sample per channel, so do not divide by channel count again. Hardware buffering may still require validation. Elapsed wall-clock time since the request is not a universal playback clock.

Transcript handling has a separate limitation. OpenAI says the model cannot align text and audio precisely enough to provide a millisecond-accurate truncated transcript. Truncation handles the transcript history associated with unheard content, but does not return precisely cut subtitles. A UI displaying the full generated transcript must not treat it as proof of what remains in server history.

Does WebRTC need the same client events?

Do not copy WebSocket playback responsibilities unchanged. OpenAI manages output buffering for WebRTC and SIP, and automatically truncates unheard audio on automatic interruption. WebSocket clients manage playback and truncation themselves.

Manual push-to-talk is different again. The documented flow disables VAD. WebSocket clients cancel an in-progress response, stop local playback, and truncate; WebRTC/SIP use output_audio_buffer.clear to clear unplayed output and truncate the conversation, along with their required input-buffer handling. Switching transport URLs does not make these flows equivalent.

Nbility documents generic WebSocket access. That is not evidence that all channels provide OpenAI's WebRTC buffer behavior. Verify the actual model, event contract, and transport before testing a full interruption. The API-format comparison explains why similar names alone do not establish compatibility.

How should interruption be accepted before release?

Interrupt a long public response early, midway, and near the end. Check audio, history, and the next turn separately. These are proposed acceptance cases, not online results:

ConditionRequired behavior
A large old audio queue remainsNo old tail continues playing
An old delta arrives after cancellationIt does not re-enter playback
User asks where the answer stoppedThe model does not assume the unheard tail was heard
A tool query was already startedResults remain associated with the appropriate intent

Early, middle, and late interruptions each check audible output, retained history, and the next reply

“Stop talking” does not roll back an order or message already sent. Inspect business-operation records and handle that separately; see retry side effects. For bytes arriving without sound, inspect decoding and playback queues. Then validate a complete read-only conversation using the Realtime channel actually available to you through Nbility.

Related posts

How long should Realtime VAD wait before replying?
RealtimeAudioVAD

How long should Realtime VAD wait before replying?

Tune silence detection, semantic turn-taking, and response controls separately. Check pauses, clipped starts, and playback timing without treating a VAD timeout as total latency.

Choosing between audio transcription and translation
AudioTranscriptionTranslation

Choosing between audio transcription and translation

Choose an audio workflow by its output: original-language text, translated subtitles, or live interpretation. Account for the legacy OpenAI translation endpoint shutdown.

Run your Agent workflow through Nbility

Get an API key and connect OpenAI-compatible models and developer tools from one place.

Get an API key