when using manual turn detection and push to talk ...
# ask-ai
a
when using manual turn detection and push to talk agent sample code, the
on_user_turn_completed
method is called with empty transcript content. why is there no transcript in that event, even though it is added to ai's chat context perfectly fine?
t
Thanks for reaching out, Jeel. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
In a push-to-talk implementation with manual turn detection, the
on_user_turn_completed
method may be called with an empty transcript if the user has not provided any meaningful input. To handle this scenario, you can modify the method to check for empty transcript content and prevent the agent from generating a response when there is no meaningful content. Here is an example of how you can handle this:
Copy code
async def on_user_turn_completed(self, turn_ctx: ChatContext, new_message: ChatMessage) -> None:
    # callback before generating a reply after user turn committed
    if not new_message.text_content:
        # for example, raise StopResponse to stop the agent from generating a reply
        <http://logger.info|logger.info>("ignore empty user turn")
        raise StopResponse()
This code checks if the user’s message has any text content. If not, it raises a
StopResponse()
exception to abort the generation entirely, ensuring the agent does not respond to empty input. This is particularly useful in push-to-talk interfaces where users might accidentally trigger the microphone without speaking. Sources: Tree View: | dse-workbench | Voice pipeline nodes | LiveKit Docs
a
it ALWAYS raises StopResponse because the text_content is always empty.
t
I'm sorry, but I don't have the information you need at the moment. If you would like a member of the LiveKit team to respond, please ask your question in one of the other channels.
a
Copy code
2025-06-06 15:02:45,335 - INFO root - on user turn completed: id='item_390244575016' type='message' role='user' content=[''] interrupted=False hash=None {"user_id": 5, "pid": 280418, "job_id": "AJ_okkcpxZTo3fT"}
2025-06-06 15:02:45,336 - INFO root - ignore empty user turn: id='item_390244575016' type='message' role='user' content=[''] interrupted=False hash=None {"user_id": 5, "pid": 280418, "job_id": "AJ_okkcpxZTo3fT"}
2025-06-06 15:02:46,764 - DEBUG root - Conversation item Added : type='conversation_item_added' item=ChatMessage(id='item_BfNjItzO4H1JNpQvJbbIP', type='message', role='user', content=['Hello.\n'], interrupted=False, hash=None) {"user_id": 5, "pid": 280418, "job_id": "AJ_okkcpxZTo3fT"}