numerous-whale-53652
07/06/2025, 5:52 PMtall-airline-16756
07/06/2025, 5:53 PMtall-airline-16756
07/06/2025, 5:53 PMuser_away_timeout
parameter. Here's a brief overview of the process:
• Set the user_away_timeout
parameter when creating an AgentSession. For example: session = AgentSession(
vad=silero.VAD.load(),
llm=openai.LLM(model="gpt-4o-mini"),
stt=deepgram.STT(),
tts=cartesia.TTS(),
user_away_timeout=12.5, # Set timeout to 12.5 seconds
)
• Handle the user_state_changed
event to detect when the user goes into the "away" state and take appropriate actions. For example: @session.on("user_state_changed")
def _user_state_changed(ev: UserStateChangedEvent):
nonlocal inactivity_task
if ev.new_state == "away":
inactivity_task = asyncio.create_task(user_presence_task())
return
if inactivity_task is not None:
inactivity_task.cancel()
• Define a task to handle inactivity, such as prompting the user or closing the session after multiple attempts. For example: async def user_presence_task():
for _ in range(3):
await session.generate_reply(
instructions=("The user has been inactive. Politely check if the user is still present.")
)
await asyncio.sleep(10)
await asyncio.shield(session.aclose())
ctx.delete_room()
This setup allows you to manage user silence effectively and take appropriate actions based on inactivity.
Sources: GitHub::livekit::agents | livekit-plugins/livekit-plugins-gladia/livekit/pl...numerous-whale-53652
07/06/2025, 5:54 PMtall-airline-16756
07/06/2025, 5:54 PMnumerous-whale-53652
07/06/2025, 5:55 PMtall-airline-16756
07/06/2025, 5:55 PM