From 2f23f2e39cf1469ac0fa2f85a1a1fd3eb19ffb4f Mon Sep 17 00:00:00 2001 From: filipi87 Date: Mon, 26 Jan 2026 17:08:27 -0300 Subject: [PATCH 1/2] Fixed race condition in OpenAIRealtimeBetaLLMService that could cause an error when truncating the conversation. --- src/pipecat/services/openai_realtime_beta/openai.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pipecat/services/openai_realtime_beta/openai.py b/src/pipecat/services/openai_realtime_beta/openai.py index 128bcc93a..1199d8556 100644 --- a/src/pipecat/services/openai_realtime_beta/openai.py +++ b/src/pipecat/services/openai_realtime_beta/openai.py @@ -525,6 +525,14 @@ class OpenAIRealtimeBetaLLMService(LLMService): # note: ttfb is faster by 1/2 RTT than ttfb as measured for other services, since we're getting # this event from the server await self.stop_ttfb_metrics() + + if self._current_audio_response and self._current_audio_response.item_id != evt.item_id: + logger.warning( + f"Received a new audio delta for an already completed audio response before receiving the BotStoppedSpeakingFrame." + ) + logger.debug("Forcing previous audio response to None") + self._current_audio_response = None + if not self._current_audio_response: self._current_audio_response = CurrentAudioResponse( item_id=evt.item_id, From 98fcfd7c91d6380436d4bacd89ed8c51922b343f Mon Sep 17 00:00:00 2001 From: filipi87 Date: Mon, 26 Jan 2026 17:19:08 -0300 Subject: [PATCH 2/2] Adding changelog entry for the OpenAiRealtimeBetaLLMService fix. --- changelog/3567.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/3567.fixed.md diff --git a/changelog/3567.fixed.md b/changelog/3567.fixed.md new file mode 100644 index 000000000..92ecabeca --- /dev/null +++ b/changelog/3567.fixed.md @@ -0,0 +1 @@ +- Fixed race condition in `OpenAIRealtimeBetaLLMService` that could cause an error when truncating the conversation.