damp-belgium-53878
08/06/2025, 9:59 AMdef interrupt(self) -> asyncio.Future[None]:
"""Interrupt the current speech generation.
Returns:
An asyncio.Future that completes when the interruption is fully processed
and chat context has been updated.
How to prevent chat completion after interruption ? I would like something that stop the current session until session.update_agent is calledtall-airline-16756
08/06/2025, 9:59 AMtall-airline-16756
08/06/2025, 9:59 AMsession.interrupt
? Are you looking to pause all further processing of the session until session.update_agent
is explicitly called, or is there a specific behavior you want to enforce during this pause?
Sources: examples/voice_agents/push_to_talk.pydamp-belgium-53878
08/06/2025, 10:01 AMtall-airline-16756
08/06/2025, 10:02 AMsession.interrupt()
to immediately stop Agent 1’s speech and audio playback. This makes sure the interruption is fully handled.
2. Next, use session.clear_user_turn()
to clear out any leftover audio or transcription from Agent 1.
3. Then, call session.commit_user_turn()
to wrap up the current user turn and update the conversation context.
4. Finally, switch over to Agent 2 by calling session.update_agent(new_agent=agent_2)
.
Just a quick tip: make sure allow_interruptions
is set to True
in your session settings so interruptions can happen smoothly. Following these steps will ensure Agent 1 stops completely before Agent 2 starts talking.
If anything’s unclear or you want me to walk you through it, just let me know—I’m here to help!
Sources: livekit-agents/livekit/agents/voice/agent_activity.py