Hey everyone! I’ve been using the Realtime API for a while and recently, over the past week or two, I’ve been running into an issue where the AI starts looping the same response over and over.
It usually happens a few minutes into the conversation, and once it starts, it just keeps repeating itself. It seems like it gets stuck in some kind of loop and won’t move forward with the conversation properly unless the websocket connection is broken.
I can’t reveal the exact prompt that produces this issue, but it seems to happen a lot more with longer user prompts – I was wondering if anyone else has noticed this? Would love to hear if anyone has found a fix or a way to prevent it!
1 Like
Hi there, i am having similar issue with Realtime API but only on android, on ios works fine. I am guessing it has something to do with echo or mic being on always, so it is listening to itself and keeps repeating the same sentence
1 Like
The connection time for the RealTime API is limited to a maximum of 30 minutes.
https://platform.openai.com/docs/guides/realtime-model-capabilities#session-lifecycle-events
I suspect that this might be the cause of the looping issue during extended conversations; in my tests, once the conversation exceeded 30 minutes, the responses began to loop.
However, this is different from a situation where the conversation has only progressed a few minutes. Are you using Function Calling?
Since the RealTime API supports Function Calling, it’s possible that some bug related to it might be causing this.
In any case, because it’s possible to send context data even after disconnecting the WebSocket connection, I think it would be a good idea to disconnect and then reconnect the WebSocket—sending along the context—if the responses start looping.
I hope this explanation serves as some kind of rationale.
1 Like
Hi! Thanks for your response, we are not using function calling, how would you be able to detect when the responses are looping - when this occurs, the message transcript from the AI doesn’t even come in. Should the user have a button to disconnect and reconnect the websocket?
HI,
Set a timer for 30mins from the moment you make the socket connection and re-establish that connection every 20 or so when the user is idle.
The conversation only lasts <5 minutes though, I’ll look into this more if this is an issue on our setup and if no one else is facing this problem.
I don’t use server VAD so this shouldn’t be the issue.