incalculable-address-14672
12/03/2025, 12:32 AMuser_away_timeout=5 but if the user asks for moment to think we set the timeout to 30 seconds for the next turn?tall-airline-16756
12/03/2025, 12:32 AMtall-airline-16756
12/03/2025, 12:33 AMuser_away_timeout but extend it to 30s when the user asks for a moment to think.
Short answer: you cannot change user_away_timeout mid-session, but you can implement the behavior you want by disabling the built-in timeout and handling it yourself.
How to do it (high level)
1. Create the session with user_away_timeout=None.
2. Listen for user_state_changed to know when the user stops speaking/starts listening.
3. When the user asks for more time (detect via transcription or an intent), set a session flag like session.userdata["extend_timeout"] = True.
4. Start a small background task after the user stops speaking that checks elapsed silence and uses 5s or 30s depending on that flag.
5. If the chosen timeout elapses, take your desired action (prompt, end turn, etc.). Reset the flag when the user speaks again.
Example (pseudo-Python)
session = AgentSession(..., user_away_timeout=None)
session.userdata["extend_timeout"] = False
last_spoke = time.time()
@session.on("user_state_changed")
def on_user_state_changed(ev):
global last_spoke
if ev.new_state == "speaking":
last_spoke = time.time()
session.userdata["extend_timeout"] = False
elif ev.new_state == "listening":
asyncio.create_task(check_silence())
async def check_silence():
while True:
timeout = 30 if session.userdata.get("extend_timeout") else 5
if time.time() - last_spoke > timeout:
await session.say("Are you still there?")
break
await asyncio.sleep(0.5)
If you want, I can:
• Provide a more complete code sample for your language (Python/Node).
• Suggest ways to detect "give me a moment" reliably (simple keyword vs. intent model). Which would you prefer? Sources: Agent session | LiveKit docs | Events and error handling | LiveKit docs | Turn detection and interruptions | LiveKit Docs | Pipeline nodes and hooks | LiveKit docs