wonderful-account-72949
09/18/2025, 6:07 AMsession = AgentSession(
llm=google.beta.realtime.RealtimeModel(
model=model,
voice=voice,
temperature=temperature,
instructions=instructions,
language="en-IN"
),
min_endpointing_delay=5,
)
await session.start(
agent=assistant,
room=ctx.room,
room_input_options=RoomInputOptions(
# LiveKit Cloud enhanced noise cancellation
# - If self-hosting, omit this parameter
# - For telephony applications, use `BVCTelephony` for best results
noise_cancellation=noise_cancellation.BVC(),
# Don't close session when participants disconnect - allow multiple users
close_on_disconnect=False,
),
)tall-airline-16756
09/18/2025, 6:07 AMtall-airline-16756
09/18/2025, 6:08 AMallow_interruptions parameter. Let me walk you through two simple ways to do this:
• Disable Interruptions at the Agent Level: You can set allow_interruptions=False when you initialize the agent. This way, all speech generated by the agent won’t be interrupted.
agent = Agent(
stt=..., # your STT instance
llm=..., # your LLM instance
tts=..., # your TTS instance
allow_interruptions=False # Disables interruptions for all agent speech
)
• Disable Interruptions for Specific Speech: If you want to prevent interruptions for just certain utterances, you can use allow_interruptions=False in methods like session.say().
await session.say(
"This message cannot be interrupted.",
allow_interruptions=False
)
These options should help make your AI speech flow more smoothly without interruptions during your sessions. If you have any questions or need a hand with anything else, please don’t hesitate to ask — I’m here to help!
Sources: pipeline-llm/interrupt_user.py | packages/basics/src/uninterruptable.ts | Agent speech and audio | LiveKit Docs | Agent speech and audio | LiveKit Docswonderful-account-72949
09/18/2025, 6:21 AMallow_interruptions false in AgentSession and got this error
0|livekit-agent | ERROR:livekit.agents:unhandled exception while running the job task
0|livekit-agent | Traceback (most recent call last):
0|livekit-agent | File "/home/ubuntu/ai-tutor/py-agent/.venv/lib/python3.12/site-packages/opentelemetry/util/_decorator.py", line 71, in async_wrapper
0|livekit-agent | return await func(*args, **kwargs) # type: ignore
0|livekit-agent | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
0|livekit-agent | File "/home/ubuntu/ai-tutor/py-agent/.venv/lib/python3.12/site-packages/livekit/agents/ipc/job_proc_lazy_main.py", line 240, in _traceable_entrypoint
0|livekit-agent | await self._job_entrypoint_fnc(job_ctx)
0|livekit-agent | File "/home/ubuntu/ai-tutor/py-agent/src/agent.py", line 1164, in entrypoint
0|livekit-agent | await session.start(
0|livekit-agent | File "/home/ubuntu/ai-tutor/py-agent/.venv/lib/python3.12/site-packages/opentelemetry/util/_decorator.py", line 71, in async_wrapper
0|livekit-agent | return await func(*args, **kwargs) # type: ignore
0|livekit-agent | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
0|livekit-agent | File "/home/ubuntu/ai-tutor/py-agent/.venv/lib/python3.12/site-packages/livekit/agents/voice/agent_session.py", line 502, in start
0|livekit-agent | await asyncio.gather(*tasks)
0|livekit-agent | File "/home/ubuntu/ai-tutor/py-agent/.venv/lib/python3.12/site-packages/livekit/agents/voice/agent_session.py", line 822, in _update_activity
0|livekit-agent | self._next_activity = AgentActivity(agent, self)
0|livekit-agent | ^^^^^^^^^^^^^^^^^^^^^^^^^^
0|livekit-agent | File "/home/ubuntu/ai-tutor/py-agent/.venv/lib/python3.12/site-packages/livekit/agents/voice/agent_activity.py", line 131, in __init__
0|livekit-agent | raise ValueError(
0|livekit-agent | ValueError: the RealtimeModel uses a server-side turn detection, allow_interruptions cannot be False, disable turn_detection in the RealtimeModel and use VAD on the AgentSession insteadtall-airline-16756
09/18/2025, 6:22 AMRealtimeModel uses server-side turn detection, which doesn't quite work when you set allow_interruptions=False. No worries though, I’m here to help you through it! You have two great options to fix this:
• Option 1: Disable Server-Side Turn Detection
You can turn off the Realtime model's turn detection and instead use client-side VAD for managing interruptions. This gives you full control, though it might add a bit of latency.
session = AgentSession(
allow_interruptions=False,
vad=silero.VAD.load(),
llm=openai.realtime.RealtimeModel(
turn_detection=None,
voice="alloy"
)
)
• Option 2: Use Server-Side Turn Detection
Alternatively, you can keep allow_interruptions=True and rely on the Realtime model’s built-in turn detection, which is optimized for performance. You can even tweak its behavior with settings like threshold and silence_duration_ms.
session = AgentSession(
llm=openai.realtime.RealtimeModel(
turn_detection=openai.realtime.ServerVadOptions(
threshold=0.6,
silence_duration_ms=500
)
)
)
For simplicity and smooth performance, I usually recommend Option 2. But if you have any questions or want help setting this up, just let me know—I’m happy to assist!
Sources: Turn detection and interruptions | LiveKit Docs | plugins/openai/src/realtime/realtime_model.ts | livekit-agents/livekit/agents/voice/events.py | Voice activity detection (VAD) parameters | LiveKit Docs