hey, im having an issue with the pre-connect buffe...
# agents
a
hey, im having an issue with the pre-connect buffer when the audio is really short and all the user speech goes through pre-connect buffer, because im getting the response interrupted/cancelled. however, if the user speech goes beyond the preconnect, then it works correctly. EDIT: im using OpenAI Realtime model with sematic vad server side
@refined-appointment-81829 sir do you have any insight on this?
r
Can you try and increase
pre_connect_audio_timeout
and see if that helps https://github.com/livekit/agents/blob/main/livekit-agents/livekit/agents/voice/room_io/room_io.py#L80
a
i have it set at 10.0 and pre-connect audios are around 2-3secs
r
How do you reproduce this?
a
Client side: i have a Python Client upgraded to the latest release and that is connected to a room without the agent. when user presses a button the first time to speak, we make a request to dispatch an agent to the room and start buffering user speech locally when we receive the agent connected event on the client, we stop buffering, send the pre-connect audio to the lk-preconnect-buffer topic and immediately all subsequent audio from client is normally sent via RTC Agent side: just follow the examples and set the preconnect buffer timeout to 10s the pattern i've seen is that when user speech is all inside the preconnect buffer, there's an interrupt coming from user speech started event and then the answer from the AI is never generated whereas when user input comes from both pre-connect audio and the normal webrtc channel, all flows smoothly
Copy code
2025-09-13 23:48:12,275 - DEBUG livekit.agents - pre-connect audio received
2025-09-13 23:48:12,278 - DEBUG livekit.agents - pre-connect audio buffer pushed 
2025-09-13 23:48:12,280 - DEBUG livekit.plugins.openai - >>> {'audio': '...', 'type': 'input_audio_buffer.append'} # multiple times
...
2025-09-13 23:48:12,525 - DEBUG livekit.plugins.openai - <<< {'type': 'input_audio_buffer.speech_started', 'event_id': 'event_CFaouKWSWPtfRUrqYrQj7', 'audio_start_ms': 652, 'item_id': 'item_CFaoukbfUFuESCnOgYy7d'}
2025-09-13 23:48:12,525 - INFO events - User state changed from: listening to speaking
2025-09-13 23:48:12,526 - DEBUG livekit.plugins.openai - >>> {'type': 'response.cancel'}
2025-09-13 23:48:12,599 - DEBUG livekit.plugins.openai - >>> {'audio': '...', 'type': 'input_audio_buffer.append'
2025-09-13 23:48:12,851 - DEBUG livekit.plugins.openai - <<< {'type': 'input_audio_buffer.speech_stopped', 'event_id': 'event_CFaouZhoBEzJIhBCVlztZ', 'audio_end_ms': 3328, 'item_id': 'item_CFaoukbfUFuESCnOgYy7d'} 
2025-09-13 23:48:12,853 - INFO events - User state changed from: speaking to listening
...
2025-09-13 23:48:12,858 - INFO main_agent - Setting conversation ID: conv_CFaouXVjyCFMxgOoBA35N 
2025-09-13 23:48:12,903 - DEBUG livekit.plugins.openai - <<< {'type': 'response.done', 'event_id': 'event_CFaouzeoQLnP4bnYBRCLK', 'response': {'object': 'realtime.response', 'id': 'resp_CFaouHOnTclUNp1ZDIJlK', 'status': 'cancelled', 'status_details': {'type': 'cancelled', 'reason': 'client_cancelled'}, 'output': [], 'conversation_id': 'conv_CFaouXVjyCFMxgOoBA35N', 'modalities': ['audio', 'text'], 'voice': 'coral', 'output_audio_format': 'pcm16', 'temperature': 0.6, 'max_output_tokens': 'inf', 'usage': {'total_tokens': 0, 'input_tokens': 0, 'output_tokens': 0, 'input_token_details': {'text_tokens': 0, 'audio_tokens': 0, 'image_tokens': 0, 'cached_tokens': 0, 'cached_tokens_details': {'text_tokens': 0, 'audio_tokens': 0, 'image_tokens': 0}}, 'output_token_details': {'text_tokens': 0, 'audio_tokens': 0}}, 'metadata': None}}
@refined-appointment-81829 sorry i pick up on this topic again, but do you have any clue on this issue? it happens every time
https://github.com/livekit/agents/blob/f530c225bc3fc2acbdbcaa1fe03a4b2da1528c13/livekit-agents/livekit/agents/voice/agent_activity.py#L1013-L1024 i think it's related to this together with the pre-connect buffer, because this generates the interruption everytime
opened this PR to address the issue: https://github.com/livekit/agents/pull/3447