LiveKit Agent not triggering backend call hang-up on keyword detection

I have successfully set up a bot agent on my local system with UI integration. The agent is working properly without any issues during conversation.

Now I am implementing the next step: automatically ending the call from the backend when the conversation is complete.

Requirement:
The call should hang up automatically when specific keywords are detected from the user or AI side, such as: “thank you”, “bye”, “hang up”.

Current Behaviour:

  • Manual hang-up via UI button works correctly.

  • Backend-triggered hang-up is not working.

What I Tried:

  • Implemented keyword detection logic in the agent.

  • Added logic to close session and put the agent to sleep after detecting these keywords.

  • Tested multiple times with different approaches.

Issue:
Despite detecting the keywords, the call is not getting disconnected from the backend.

Request:
Please help identify:

  • The correct way to terminate a call/session from the backend in LiveKit agent.

  • Whether there is any specific API or method required to force disconnect the participant or room.

  • If additional configuration is needed for this functionality.

I am attaching the console logs below for reference.

Your session closing logic alone won’t disconnect the call. In LiveKit, you must either use EndCallTool (Python agents) or explicitly delete the room.

For Python agents, add the prebuilt EndCallTool so the agent can gracefully end the call and optionally delete the room, which disconnects all participants, including SIP callers. See EndCallTool.