From 468e159f9b4475d6c870f914f13389102fca3ad6 Mon Sep 17 00:00:00 2001 From: filipi87 Date: Wed, 28 Jan 2026 08:36:31 -0300 Subject: [PATCH 1/2] Fixed race condition in OpenAIRealtimeLLMService that could cause an error when truncating the conversation. --- src/pipecat/services/openai/realtime/llm.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pipecat/services/openai/realtime/llm.py b/src/pipecat/services/openai/realtime/llm.py index 11a83741e..cf249408c 100644 --- a/src/pipecat/services/openai/realtime/llm.py +++ b/src/pipecat/services/openai/realtime/llm.py @@ -599,6 +599,14 @@ class OpenAIRealtimeLLMService(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 bdae1771256cd83a0993564f22a19d374116d263 Mon Sep 17 00:00:00 2001 From: filipi87 Date: Wed, 28 Jan 2026 08:39:11 -0300 Subject: [PATCH 2/2] Adding changelog entry for the OpenAiRealtimeLLMService fix. --- changelog/3581.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/3581.fixed.md diff --git a/changelog/3581.fixed.md b/changelog/3581.fixed.md new file mode 100644 index 000000000..688bbcfbe --- /dev/null +++ b/changelog/3581.fixed.md @@ -0,0 +1 @@ +- Fixed race condition in `OpenAIRealtimeLLMService` that could cause an error when truncating the conversation. \ No newline at end of file