Is there a way to update AgentSession parameters l...
# ask-ai
l
Is there a way to update AgentSession parameters like session.stt, vad, min_interruption_duration, min_interruption_words when a new agent's
on_enter
function is hit or before transferring to the next agent? For example I wanted to change the stt model for an agent to
Copy code
session.stt = google.STT(
        model="telephony",
        spoken_punctuation=False,
        credentials_info=json.loads(GOOGLE_APPLICATION_CREDENTIALS),
    )
but I got this error: AttributeError: property 'stt' of 'AgentSession' object has no setter
t
Thanks for reaching out, Alok. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I understand it can be a bit tricky, but updating parameters like
session.stt
,
vad
,
min_interruption_duration
, and
min_interruption_words
dynamically during a session isn’t supported just yet. These settings are part of the
VoiceOptions
dataclass and need to be set right when you initialize the
AgentSession
. Here’s a little example to help you see how to set them up during session creation:
Copy code
session = AgentSession(
    stt=your_stt_instance,  # Cannot be changed later
    vad=your_vad_instance,  # Cannot be changed later
    min_interruption_duration=0.5,  # Cannot be changed later
    min_interruption_words=0,  # Cannot be changed later
    min_endpointing_delay=0.5,  # CAN be updated with update_options()
    max_endpointing_delay=3.0,  # CAN be updated with update_options()
)
It’s good to know that some parameters like
min_endpointing_delay
and
max_endpointing_delay
can be updated on the fly using
session.update_options()
. However, for the ones you mentioned, if you need to change them, you’ll have to recreate the session. If you’d like to share a bit more about what you’re trying to achieve, I’d be happy to help brainstorm some alternative solutions—maybe something like agent replacement or session recreation—that could work well for your needs. Sources: livekit-agents/livekit/agents/voice/agent_activity.py