How can I restart the user away timeout? The prob...
# ask-ai
p
How can I restart the user away timeout? The problem is that when I generate a speech inside a tool call the timeout starts - and if the tool call is a transfer it usually takes up to 30 seconds which leads to the away timeout to trigger
t
Thanks for reaching out, Jonas. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The user away timeout in LiveKit is automatically managed by the system and doesn't have a direct public method to manually restart it. However, there are ways to indirectly reset the timeout: • Generate agent activity: You can use
session.generate_reply()
to make the agent speak, which will reset the timer. For example:
await session.generate_reply("Are you still there?")
• Handle the
user_state_changed
event:
You can listen for when the user goes "away" and take action to reset the timer. For instance:
Copy code
@session.on("user_state_changed")
def handle_user_state(event):
    if event.new_state == "away":
        asyncio.create_task(session.generate_reply("Are you still there?"))
    elif event.new_state in ["listening", "speaking"]:
        pass
The timeout is automatically reset when there is activity, such as the user or agent speaking, or any state change that moves away from both being in the "listening" state. Sources: livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | Events and error handling | LiveKit Docs