Updated Speechmatics STT integration#4359
Conversation
longcw
left a comment
There was a problem hiding this comment.
LGTM! could you help to resolve the conflicts with the main branch. and something nit:
|
|
commit c46013d Author: Long Chen <longch1024@gmail.com> Date: Tue Feb 3 20:02:57 2026 +0800 add exclude_config_update to ChatContext copy (livekit#4700) commit 7849a8c Author: Chenghao Mou <chenghao.mou@livekit.io> Date: Tue Feb 3 09:51:07 2026 +0000 fix: commit user turn with STT and realtime (livekit#4663) commit edfa391 Author: Chenghao Mou <chenghao.mou@livekit.io> Date: Tue Feb 3 09:48:36 2026 +0000 add STT usage for google (livekit#4599) commit 34d0d62 Author: Long Chen <longch1024@gmail.com> Date: Tue Feb 3 15:53:42 2026 +0800 fix gemini live tool execution interrupted by generation_complete event (livekit#4699) commit 1725929 Author: Long Chen <longch1024@gmail.com> Date: Tue Feb 3 11:08:27 2026 +0800 prevent tool cancellation when AgentTask is called inside it (livekit#4586)
| old_allow_interruptions = speech_handle.allow_interruptions | ||
| speech_handle.allow_interruptions = False | ||
|
|
||
| blocked_tasks = [current_task] | ||
| if ( | ||
| old_activity._on_enter_task |
There was a problem hiding this comment.
🔴 SpeechHandle.allow_interruptions not restored if session._update_activity raises
In the InlineTask.__await_impl__ method, speech_handle.allow_interruptions is set to False before entering the try block, but restoration only occurs in the finally block. If session._update_activity() raises an exception (line 790), the finally block never executes and allow_interruptions remains permanently disabled.
Click to expand
Code flow showing the issue:
# Line 768-769: allow_interruptions is set to False
old_allow_interruptions = speech_handle.allow_interruptions
speech_handle.allow_interruptions = False
# Lines 770-790: Various setup code runs OUTSIDE try block
blocked_tasks = [current_task]
# ...
await session._update_activity(...) # If this raises, finally won't run!
# Line 801-806: try/finally starts here
try:
return await asyncio.shield(self.__fut)
finally:
if speech_handle:
speech_handle.allow_interruptions = old_allow_interruptions # Never reached if above throwsImpact:
If _update_activity fails for any reason (network issues, invalid state, etc.), the speech handle will be stuck with allow_interruptions=False, preventing all future interruptions for that speech. This could cause the agent to become uninterruptible, leading to a poor user experience where users cannot stop the agent from speaking.
(Refers to lines 768-790)
Recommendation: Move the speech_handle.allow_interruptions = False assignment inside the try block, or wrap the entire section from line 768 to the try block in a try/finally to ensure restoration happens regardless of where exceptions occur.
Was this helpful? React with 👍 or 👎 to provide feedback.
I have closed this PR and created a new one as the code base was far a drift from master. |
What's Changed?
Deprecation Warning
end_of_utterance_modehas been changed toturn_detection_modeto reduce ambiguityTurnDetectionMode.EXTERNAL(default) for any VAD within LiveKitTurnDetectionMode.ADAPTIVEorTurnDetectionMode.SMART_TURNto use the plugin VAD / turn detection