how to update_options during on_user_turn_complete...
# ask-ai
t
how to update_options during on_user_turn_completed
t
Thanks for reaching out, Joseph. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I’m glad you asked about using
update_options
during
on_user_turn_completed
! This is a great way to tailor your agent’s behavior dynamically based on what the user just said, right before the agent responds. Here’s a friendly overview to help you along: • Universal Options: You have control over things like tool selection (
tool_choice
), endpointing delays (
min_endpointing_delay
,
max_endpointing_delay
), and more. • Realtime Model Options: For OpenAI models, you can tweak voice, speech speed, response creativity (
temperature
), and transcription settings. If you’re working with Google models, options like
temperature
and
tool_behavior
are available too. • Implementation: Simply use the
update_options
method inside the
on_user_turn_completed
function to make these adjustments on the fly, based on the user’s message or the context of your conversation. If you’d like, I’d be happy to share some specific examples or dive deeper into any of these options. Just let me know! Sources: tests/test_agent_session.py | Pipeline nodes and hooks | LiveKit Docs | Agent Session & Client Integration | livekit/livekit_composite | DeepWiki
t
the voice did nopt change though
t
It sounds like the voice not changing might be happening because of preemptive speech generation. When this feature is on, the system sometimes uses a pre-generated response that doesn’t reflect any recent voice setting updates. But don’t worry, there are a few ways to fix this: • Disable Preemptive Generation: This will make sure your updated voice settings are applied for the next response. • Update Voice Options Earlier: Try applying the voice change before the
on_user_turn_completed
method runs. • Force Invalidation of Preemptive Responses: You can tweak the chat context inside
on_user_turn_completed
to invalidate the preemptive response and make sure the new voice settings take effect. If you’d like, I’m happy to walk you through any of these solutions step-by-step. Just let me know! Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/tts.py | Hume TTS plugin guide | LiveKit Docs | Agent speech and audio | LiveKit Docs