I'm using stt-llm-tts. How can I get the model to ...
# ask-ai
b
I'm using stt-llm-tts. How can I get the model to respond back to me/ask if I'm still there etc, if I don't say anything in the next 2-3 secs?
t
Thanks for reaching out, Charles. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! If you want your STT-LLM-TTS model to check in with you after 2–3 seconds of silence, here’s a simple way to set that up: 1. Adjust the
user_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:
Copy code
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:
Copy code
@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...