Realtime SIP calls not hanging up

When calling the hangup API endpoint, either directly or via the openai-agents python SDK, the call never terminates. This appears to happen only when using the Twilio SIP trunk and is a recent (couple of weeks) regeression that started to appear randomly at first but now it affects almost every call. Our logs show no errors, the hangup API call completes without any errors and when using a non Twilio SIP trunk functions normally.

I’ve tried reporting this via the support chat on help.openai.com, but seem to be stuck in some AI support hell loop.

Can someone at @OpenAI_Support @curt.kennedy take a look at this, our customers are getting really annoyed.

1 Like

Hey dear @sect2k
Do not worry - you are not alone :slight_smile:

We solved this by creating a tool to end the call. Name it “endcall”

Then in the prompt you say that you want to "Handoff” the call to available tools and one of the “handoffs” is that when you want to drop the call then use “endcall”

Handoff Definition

  • A handoff is any permitted next step executed via one of the actions listed below.
  • Do not use any action that is not listed below.

Always Allowed

  • “endcall”: End the conversation after a short courteous farewell.

Action Selection Rules

  • “endcall” may be used only if the caller explicitly asks to end the call or explicitly declines all other offered allowed actions.

Play in this direction and it will call the tool and end the call.

1 Like

hey @nbo2, thanks, but that’s not the issue, we have and end_call tool the agent uses and the tool works fine in terms of agent calling it and the tool calling the hangup endpoint. The problem is that calling the hangup endpoint, does not end the call, but only when using with twillio SIP, with a local SIP provider, it works fine, which indicates that the issue is not with our code. (and the fact that this worked, but stopped without us changing anything codewise)

Hi dear @sect2k

From your description, then it is not a tool issue. That’s good news.

The bad news is that “with a local SIP provider, it works fine”. The local sip provider is not a boss like Twilio. So the fact that it works, could simply mean that the local provider is just more “permissive” and could accept malformed or incomplete sip headers which would hide the problem to make it work.

I would go and dig in the Twilio logs.

Does Twilio receive the SIP BYE?

Is the call still active? Stuck, does it disconnect after 32 sec? Do you have a partial teardown?

If you can grab SIP traces (pcap or Twilio logs), that’ll probably make it obvious whether the BYE is missing or ignored.

Hope you find the problem - Cheers!