wooden-librarian-60399
08/12/2025, 4:07 AMtall-airline-16756
08/12/2025, 4:07 AMtall-airline-16756
08/12/2025, 4:07 AMsession.update_agent
and how long draining or pausing lasts can vary. It really depends on wrapping up current tasks, like finishing speech generation and getting the new agents ready to go.wooden-librarian-60399
08/12/2025, 4:22 AMtall-airline-16756
08/12/2025, 4:23 AMsession.update_agent
or when draining/pausing — there isn't an exact average time documented. The time it takes can vary depending on things like the size of the model, how busy the system is, and network speed. For draining, there's a drain_timeout
parameter in WorkerOptions
that defaults to 30 minutes, but that's more of a maximum timeout rather than a typical duration. Hope that helps clear things up!great-tiger-31125
09/10/2025, 8:31 AMtall-airline-16756
09/10/2025, 8:31 AMsession.update_agent
or session.say
?
With these details, I'll be better equipped to assist you. Looking forward to your reply!great-tiger-31125
09/10/2025, 8:45 AMsession.update_agent
, then added a delay with await asyncio.sleep(0.3)
then speaking a phrase await session.say(phrase, allow_interruptions=False)
But sometimes getting error -->
in entrypoint: cannot schedule new speech, the speech scheduling is draining/pausing Traceback (most recent call last): File "/home/appuser/main.py", line 1198, in entrypointtall-airline-16756
09/10/2025, 8:46 AMAgentActivity
transition, like inside session.update_agent()
. This happens because the current activity is in a draining state, which means new speech can’t be scheduled unless it’s explicitly allowed.
Here’s how you can smoothly resolve this:
1. Try using session.say()
to schedule speech. This method is designed to handle the draining state gracefully and will route speech to the next available activity for you:
await session.say("Hello, how can I help you?", allow_interruptions=False)
1. Make sure to sequence your calls properly when using session.update_agent()
. For any speech during the transition, use session-level methods like `say()`:
await session.update_agent(new_agent)
await session.say("Switching to new agent configuration.")
By following these steps, you’ll help ensure that speech scheduling fits nicely with the agent’s state transitions and avoid running into that draining/pausing error. If you need any more help, feel free to ask—we’re here for you!
Sources: tests/test_agent_session.py | agents/src/voice/agent_session.tsgreat-tiger-31125
09/10/2025, 8:51 AMawait session.say("Switching to new agent configuration.")
only after its explicitly allowedtall-airline-16756
09/10/2025, 8:52 AMsession.say()
to schedule your speech. This handy method takes care of the draining state for you and makes sure the speech flows smoothly to the next activity when it’s ready.
2. Keep an eye on the order of your calls. For instance, it’s best to wait until the agent update process finishes before you schedule any speech.
Here’s a little example to guide you:
# Step 1: Update the agent\nawait session.update_agent(new_agent)\n\n# Step 2: Schedule speech\nawait session.say("Switching to new agent configuration.", allow_interruptions=False)
This way, you’re making sure speech only happens after the agent transition is fully done and the system is all set to handle new speech requests. If you have any questions or want to chat more about this, I’m here to help!
Sources: Agent speech and audio | LiveKit Docs | tests/test_agent_session.py | agents/src/voice/agent_session.ts