billions-apple-82268
08/23/2025, 4:01 AMtall-airline-16756
08/23/2025, 4:01 AMtall-airline-16756
08/23/2025, 4:02 AMuser_away_timeout parameter: This tells the system how long to wait before thinking you might’ve stepped away. For a 2–3 second pause, set it like this:
session = AgentSession(
vad=silero.VAD.load(),
llm=openai.LLM(model="gpt-4o-mini"),
stt=deepgram.STT(),
tts=cartesia.TTS(),
user_away_timeout=3.0, # Set to 3 seconds
)
2. Listen for the user_state_changed event: When it notices you’re “away,” it’ll gently prompt you:
@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())
else:
if inactivity_task is not None:
inactivity_task.cancel()
inactivity_task = None
async def user_presence_task():
await session.generate_reply(
instructions="It seems quiet—just checking, are you still there?"
)
3. (Optional) Customize it further: Feel free to tweak user_presence_task() to try again or even end the session after a few prompts.
If you hit any snags or want a hand setting this up, just give me a shout—I’m here to help!
Sources: Turn detection and interruptions | LiveKit Docs | Agents Core Architecture | livekit/livekit_composite | DeepWiki | Example Applications | livekit/livekit_composite | DeepWiki | livekit-plugins/livekit-plugins-speechmatics/livekit/plugins/speechmatics/s...