This message was deleted.
# ask-ai
s
This message was deleted.
t
Thanks for reaching out, Nuwan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Let's walk through how you can set up your AI agent to let users interrupt it, while making sure it doesn’t interrupt itself. Here’s a simple guide to help you: 1. Enable User Interruptions: Just set
allow_interruptions=True
in your
AgentSession
configuration. This way, users can jump in and interrupt the agent while it’s speaking. 2. Per-Turn Interruption Control: You can manage interruptions for each speech segment with the
SpeechHandle
object. Each piece of generated speech has an
allow_interruptions
flag, which is set to
True
by default. 3. Prevent Self-Interruption: The agent is smart enough to avoid interrupting itself. While it’s generating or playing back speech, it checks the
SpeechHandle
to make sure only interruptions from users are accepted. 4. Realtime LLM Models: If you’re working with a realtime LLM model that has built-in turn detection, just double-check your model settings to match the interruption behavior you want, since the
allow_interruptions
parameter might not apply there. Good news: by default, the agent runtime already takes care of blocking self-interruptions, so you don’t need to tweak anything extra for that. If you have any questions or need more help, feel free to ask—I’m here to help! Sources: Turn detection and interruptions | LiveKit Docs | tests/test_agent_session.py
p
async def entrypoint(ctx: agents.JobContext): session = AgentSession( llm=openai.realtime.RealtimeModel( model="gpt-4o-mini-realtime-preview", api_key=os.getenv("OPENAI_API_KEY") ), ) assistant = Assistant() await session.start( room=ctx.room, agent=assistant, room_input_options=RoomInputOptions( # For telephony applications, use
BVCTelephony
instead for best results
noise_cancellation=noise_cancellation.BVC(), ), ) how can i improve this configuaration for user can interupt AI agent. but AI agent should not interupt by it's own voice of AI agent. beacuse sometime my agent interupt by it's own voice of agent sound
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!