raise RuntimeError(“This generation handle does no...
# ask-ai
h
raise RuntimeError(“This generation handle does not allow interruptions”) 5|Universal_Agent | RuntimeError: This generation handle does not allow interruptions 5|Universal_Agent | 072157.355 ERROR asyncio Task exception was never retrieved 5|Universal_Agent | future: <Task finished 5|Universal_Agent | name=‘Task-213’ 5|Universal_Agent | coro=<RoomIO._on_user_text_input.<… 5|Universal_Agent | done, defined at 5|Universal_Agent | /home/ubuntu/CMS_VA_Agent_Python/.… 5|Universal_Agent | exception=RuntimeError(‘This 5|Universal_Agent | generation handle does not allow 5|Universal_Agent | interruptions’)> 5|Universal_Agent | Traceback (most recent call last): 5|Universal_Agent | File 5|Universal_Agent | “/home/ubuntu/CMS_VA_Agent_Python/… 5|Universal_Agent | line 408, in _read_text 5|Universal_Agent | text_input_result = 5|Universal_Agent | text_input_cb( 5|Universal_Agent | ^^^^^^^^^^… 5|Universal_Agent | File 5|Universal_Agent | “/home/ubuntu/CMS_VA_Agent_Python/… 5|Universal_Agent | line 53, in _default_text_input_cb 5|Universal_Agent | sess.interrupt() 5|Universal_Agent | File 5|Universal_Agent | “/home/ubuntu/CMS_VA_Agent_Python/… 5|Universal_Agent | line 971, in interrupt 5|Universal_Agent | return 5|Universal_Agent | self._activity.interrupt(force=for… 5|Universal_Agent | ^^^^^^^^^^^^^^^^^^^^^^^… 5|Universal_Agent | File 5|Universal_Agent | “/home/ubuntu/CMS_VA_Agent_Python/… 5|Universal_Agent | line 948, in interrupt 5|Universal_Agent | self._current_speech.interrupt… 5|Universal_Agent | File 5|Universal_Agent | “/home/ubuntu/CMS_VA_Agent_Python/… 5|Universal_Agent | line 123, in interrupt 5|Universal_Agent | raise RuntimeError(“This 5|Universal_Agent | generation handle does not allow 5|Universal_Agent | interruptions”) 5|Universal_Agent | RuntimeError: This generation 5|Universal_Agent | handle does not allow interruptions I am getting this error
t
Thanks for reaching out, rajan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I see you're hitting the RuntimeError raised when code tries to interrupt a speech/generation that was created as uninterruptible. What happened • Your stack trace shows
session.interrupt()
eventually calling
SpeechHandle.interrupt()
which raises: "This generation handle does not allow interruptions". • That means the current speech/reply was started with
allow_interruptions=False
, so normal interrupts are blocked. How to fix • If you want to force an interrupt, call:
Copy code
session.interrupt(force=True)
• If you control how the speech is created and want it interruptible, set:
Copy code
await session.say("...", allow_interruptions=True)
# or
session.generate_reply(..., allow_interruptions=True)
Quick safety tip • Wrap interrupts in try/except or use
force=True
when user input or other events must reliably stop playback:
Copy code
try:
    session.interrupt(force=True)
except Exception as e:
    logger.warning(f"Interrupt failed: {e}")
If you'd like, share the snippet where you call
say()
/
generate_reply()
and where you call
session.interrupt()
and I can point out the exact change. Sources: Turns overview | LiveKit docs | Agent speech and audio | LiveKit docs
h
I am creating agent session like this : session = AgentSession( stt=config[“stt”], llm=config[“llm”], tts=config[“tts”], turn_detection=MultilingualModel(), vad=ctx.proc.userdata[“vad”], preemptive_generation=True, user_away_timeout=None, # Disabled - using custom timer-based follow-up system mcp_servers=mcp_servers, )
t
Thanks — I see you shared your AgentSession creation. You're using
preemptive_generation=True
,
MultilingualModel()
for turn detection, and a custom VAD. That helps. Brief diagnosis • The RuntimeError you saw means an active speech/generation was marked uninterruptible (started with
allow_interruptions=False
) and then
session.interrupt()
was called. • With your config, two likely causes are: ◦ A speech handle was created as uninterruptible (explicitly or by default in some code path). ◦ A race between preemptive generation and your interrupt logic causes you to call interrupt when the current speech disallows interruptions or when no speech is active. Quick checks to try • Search your code for
say()
/
generate_reply()
calls and confirm whether
allow_interruptions
is set. If you want barge-in, set:
Copy code
await session.say("...", allow_interruptions=True)
# or
session.generate_reply(..., allow_interruptions=True)
• When interrupting, use force or guard the call:
Copy code
# safer interrupt
if session.current_speech:
    await session.current_speech.interrupt()
# or force
session.interrupt(force=True)
• Add logging around speech start/stop and interrupt calls to catch races:
Copy code
<http://logger.info|logger.info>("starting speech")
handle = await session.say(...)
<http://logger.info|logger.info>("interrupting")
await session.interrupt(force=True)
If you prefer, share the snippets where you: 1) call
say()
/
generate_reply()
and 2) call
session.interrupt()
(or any place you trigger interrupt), and I’ll point out the exact change to avoid the RuntimeError. Sources: Turns overview | LiveKit docs | Agent session | LiveKit docs | Agent speech and audio | LiveKit docs | LiveKit turn detector plugin | LiveKit docs