Repository navigation
Description
Bug Description
Turn commits with end_of_turn_probability: null when STT transcript arrives after turn flush, splitting one utterance into two turns
Summary
When a turn is committed by VAD and the final STT transcript arrives shortly afterwards, the late transcript triggers a second turn commit with end_of_turn_probability: null and unlikely_threshold: null. The single spoken utterance is delivered to the LLM as two separate conversation items.
Two distinct problems:
- A turn commits with no end-of-turn decision.
end_of_turn_probabilityandunlikely_thresholdare bothnull, andspeech_start_timeisnull. The pipeline proceeds anyway. - The log contradicts itself. In one variant,
stt transcript arrived after a turn flush, skipping eot predictionis logged, and aneot predictionevent is then emitted with null fields on the next line.
The user-visible effect is that a continuous sentence reaches the LLM fragmented, with the second fragment having bypassed turn detection entirely.
Environment
livekit 1.1.13
livekit-agents 1.6.5
livekit-api 1.2.0
livekit-blingfire 1.1.0
livekit-local-inference 0.2.6
livekit-plugins-ai-coustics 0.3.0
livekit-protocol 1.1.19
Python 3.14.5, Windows 11
agent-starter-pythontemplate, running inconsolemode- STT:
deepgram/nova-3,language="multi"(viainference.STT) - Turn detection:
inference.TurnDetector()(no arguments) — hosted inference path, notlivekit-plugins-turn-detector(that package is not installed) preemptive_generation=True- Turn detector reports
"model": "turn-detector-v1",default_threshold: 0.56
Reproduction
Speak a sentence with a pause of roughly one second mid-phrase, so that VAD commits the turn before STT has finalised the trailing words.
Observed on multiple occasions across two sessions.
Expected
Either the late transcript is merged into the already-committed turn, or it is genuinely skipped as the log message states. A turn should not commit with a null end-of-turn probability.
Actual
Case 1 — enhancement disabled
Spoken: "No. Date needed now."
04:48:24.760 DEBUG received user transcript
{"user_transcript": "Date", "transcript_delay": 0.058}
04:48:25.794 DEBUG eot prediction
{"probability": 0.737298846244812, "unlikely_threshold": 0.56,
"endpointing_delay": 0.3, "trigger": "vad", "from_cache": false}
04:48:25.805 DEBUG user turn committed
{"delay_completed": false, "source": "vad",
"end_of_turn_probability": 0.737298846244812}
04:48:25.822 DEBUG conversation_item_added
{"role": "user", "text": "No. Date"}
04:48:25.857 DEBUG received user transcript
{"user_transcript": "needed now."}
04:48:25.864 WARNING transcript arrives after turn has been committed. consider
raising `min_delay` in the endpointing options to accommodate a slow stt.
04:48:25.876 DEBUG eot prediction
{"probability": null, "unlikely_threshold": null,
"endpointing_delay": 0.3, "trigger": "stt", "from_cache": false}
04:48:26.158 DEBUG user turn committed
{"speech_start_time": null, "delay_completed": true, "source": "stt",
"end_of_turn_probability": null, "unlikely_threshold": null}
04:48:26.191 DEBUG conversation_item_added
{"role": "user", "text": "needed now."}
One utterance, two conversation items, second turn committed on a null probability.
Case 2 — the logged contradiction
Spoken: "Yeah. Can you share the link of that property?"
21:53:44.634 DEBUG user turn committed
{"delay_completed": false, "source": "vad",
"end_of_turn_probability": 0.7216790318489075}
21:53:44.640 DEBUG conversation_item_added
{"role": "user", "text": "Yeah. Can you share the link of the link of that"}
21:53:44.756 DEBUG received user transcript
{"user_transcript": "property?"}
21:53:44.759 DEBUG stt transcript arrived after a turn flush, skipping eot prediction
21:53:44.762 DEBUG eot prediction
{"probability": null, "unlikely_threshold": null,
"endpointing_delay": 0.3, "trigger": "stt", "from_cache": false}
21:53:45.059 DEBUG user turn committed
{"speech_start_time": null, "end_of_turn_probability": null,
"unlikely_threshold": null}
21:53:45.078 DEBUG conversation_item_added
{"role": "user", "text": "property?"}
skipping eot prediction is logged, then an eot prediction event is emitted 3 ms later with null fields.
Ruled out
The starter template applies ai_coustics audio enhancement on the input path by default. I disabled it and re-ran; the behaviour reproduces identically. The enhancement layer is not the cause.
Note on the min_delay suggestion
The warning suggests raising min_delay to accommodate slow STT. That may reduce how often the race occurs, but it does not address either problem above: a turn still commits with a null probability when it does occur, and the log still contradicts itself. Raising min_delay also directly increases response latency, which is costly in a telephony context.
Not the same as #3070
#3070 (closed) was the end-of-turn model timing out under CPU pressure, resolved by moving to a larger instance. Here there is no timeout and no CancelledError — the prediction is emitted, after the turn has already flushed, with null fields. That issue was also on the local turn_detector plugin; this is the hosted inference.TurnDetector() path.
Impact
In a voice pipeline where users produce short utterances with natural mid-sentence pauses, the LLM receives fragmented input and one of the fragments has bypassed turn detection. In my case the agent responded to "No. Date" before "needed now." had arrived.
Expected Behavior
Either the late transcript is merged into the already-committed turn, or it is genuinely skipped as the log message states — a turn should not commit with end_of_turn_probability: null and unlikely_threshold: null.
A single continuous utterance should reach the LLM as one conversation item, not split across two turns where the second bypassed turn detection entirely.
Reproduction Steps
Create a project from agent-starter-python (unmodified template).
Run uv run src/agent.py console.
Speak a sentence with a pause of roughly one second mid-phrase, so VAD commits the turn before STT has finalised the trailing words. Example: "No. Date … needed now."
Watch the debug log for transcript arrives after turn has been committed, immediately followed by an eot prediction with probability: null.
Observed on multiple occasions across two sessions. Reproduces with the template's default ai_coustics audio enhancement both enabled and disabled — the enhancement layer is not the cause.
The only deviation from the stock template in my runs was commenting out the room_options block to disable enhancement for the control test.Operating System
Windows 11
Models Used
STT: deepgram/nova-3 (language="multi") via inference.STT | LLM: google/gemma-4-31b-it via inference.LLM | TTS: cartesia/sonic-3 via inference.TTS | Turn detection: inference.TurnDetector() — hosted, reports "model": "turn-detector-v1"
Package Versions
livekit 1.1.13
livekit-agents 1.6.5
livekit-api 1.2.0
livekit-blingfire 1.1.0
livekit-local-inference 0.2.6
livekit-plugins-ai-coustics 0.3.0
livekit-protocol 1.1.19
Python 3.14.5Session/Room/Call IDs
N/A - console mode, no Cloud session
Proposed Solution
Resolve the race in one direction rather than both: either merge the late transcript into the already-committed turn, or genuinely skip it as the "skipping eot prediction" log line claims. A turn should never commit with end_of_turn_probability and unlikely_threshold both null. Note that the warning's suggestion to raise min_delay reduces how often the race occurs but does not fix either problem — and it increases response latency, which is costly in telephony.Additional Context
Config runs entirely through LiveKit's hosted inference gateway (inference.LLM / STT / TTS / TurnDetector); no third-party model keys. Distinct from #3070, which was an EOT model timeout under CPU pressure on the local turn_detector plugin.
Screenshots and Recordings
No response
Activity
chenghao-mou commentedon Jul 28, 2026
This is expected behavior. The late transcript could still show up as the same turn if there is no agent speech played. An user turn could have several chunks naturally, and for LLM, they are not different from STT sending them before committing the turn.
We can't retroactively change the history here because the agent might have already responded, and we need to surface late STT problems in case users want to tune STT settings or switch STT for better experience.
If your concern is more about empty values from the newly committed turn from late STT transcript, we can find other ways to mark the source clearly so you can filter them out accordingly in your code.
Propconnect-ai commentedon Jul 28, 2026
That makes sense - thanks for the detail on why the history can't be rewritten. My concern is exactly the filtering case you mentioned: right now the late-committed turn arrives with end_of_turn_probability: null and unlikely_threshold: null, which is hard to distinguish downstream from other null cases. If you're open to marking the source explicitly on these late-STT commits, that would let consumers filter them cleanly. Happy to open a PR for that if it'd be useful.
zkewal commentedon Oct 20, 2026
A related, deterministic variant of this split, for anyone using a non-streaming (batch) STT through
stt.StreamAdapterwithturn_detection="stt".Root cause
StreamAdapterWrapper._runinlivekit-agents1.8.4 (livekit/agents/stt/stream_adapter.py) sendsEND_OF_SPEECHfirst and only then callsrecognize()on the clip:END_OF_SPEECH, it sendsSpeechEvent(END_OF_SPEECH, speech_end_time=...).self._wrapped_stt.recognize(...)for that clip.FINAL_TRANSCRIPT.In
"stt"turn detection,AudioRecognition._process_stt_event(voice/audio_recognition.py, 1.8.4 L1333-1376)treats that
END_OF_SPEECHas the end of the turn. It sets_user_turn_committed = Trueand runs EOU detection,which commits once
min_delayhas passed sincespeech_end_time(L1730-1736). With a batch STT,recognize()for the last clip is often still in flight at that moment. So the turn commits without the last clip's text. That
text then arrives as a
FINAL_TRANSCRIPTafter the commit and becomes a second user turn.This is not a race that depends on network timing alone: the adapter's event order guarantees
END_OF_SPEECHbefore the last clip's text, every time. Whether the turn splits depends only on whether
recognize()takeslonger than what is left of
min_delay.Still present in 1.8.8:
stt/stream_adapter.pyis byte-identical between 1.8.4, 1.8.8 andmain(checkedtoday). In 1.8.8 the
audio_recognition.pycode paths below are unchanged; only line numbers shift by about +11.Numbers from production (one week, batch STT through StreamAdapter,
"stt"turn detection)Raising
min_delaypast about 1.6 s would hide most of these, but adds that latency to every turn.The fix we use (a subclass of StreamAdapter)
Send the clip's
FINAL_TRANSCRIPTfirst, thenEND_OF_SPEECH, with a cap so a slow provider cannot hold theturn open forever:
recognize(), and recognize closed clips in order in asecond task. That way new speech is still seen while an earlier clip is at the STT.
END_OF_SPEECHonly when all of these hold:END_OF_SPEECH(one with no text commits nothing; see below);min_delayhas already passed since the latestspeech_end_time(see the next section for why).END_OF_SPEECHgets its ownEND_OF_SPEECH, so it still commits.Turns whose text is in before
min_delayruns out commit no later than before.The
_user_turn_committedinteractionMoving
END_OF_SPEECHafter the text is not enough by itself. If it is sent beforemin_delayhas passed,_run_eou_detectionsleeps out the rest of the delay (1.8.4 L1730-1736). If the user resumes in that window, theSTT
START_OF_SPEECHhandler (L1378-1393) cancels_end_of_turn_task, but does not reset_user_turn_committed. It is only cleared at the end of_bounce_eou_task(L1822) or in_clear_user_turn(L1014), and the cancelled task never reaches L1822.
The turn is then "half-committed":
_user_turn_committedstaysTruewhile the user is speaking again. In thatstate a later VAD
END_OF_SPEECHruns EOU detection by itself (L1461-1465), and new final transcripts take thepreemptive-generation path (L1262). An
END_OF_SPEECHwith no text (L1520, no transcript, early return) leavesthe same state.
So our adapter holds
END_OF_SPEECHuntilmin_delayhas passed sincespeech_end_time. Then LiveKit commitsthe moment it gets the event, and there is no window for this to happen.
Question for maintainers: should the STT
START_OF_SPEECHbranch reset_user_turn_committed = Falsewhen itcancels
_end_of_turn_task? That looks like the intended invariant per the comment on L275 ("true if user turnended but EOU task not done").
Minimal repro (no network, no room)
Shows the event order from the stock
StreamAdapterwith a batch STT that takes 0.5 s.Output on 1.8.4 (the adapter file is identical in 1.8.8):
With
turn_detection="stt"andmin_delay0.5 s, the session counts the delay fromspeech_end_time(0.25 sbefore the
END_OF_SPEECH), so it commits about 0.25 s after the event, before the text at 0.50 s. The text thenbecomes a second turn. Expected order for a batch STT:
START_OF_SPEECH,FINAL_TRANSCRIPT,END_OF_SPEECH.johnwils commentedon Nov 16, 2026
Reading the code, this answers the open question on #6516 about the two variants.
Both variants are the same branch.
_on_missing_eot_prediction()runs only when the trigger issttand no prediction future is in flight:agents/livekit-agents/livekit/agents/voice/audio_recognition.py
Lines 1395 to 1398 in dbc38df
With a flushed detector, it logs the
transcript arrives after turn has been committedWARNING the first time andstt transcript arrived after a turn flush, skipping eot predictionat debug after that:agents/livekit-agents/livekit/agents/voice/audio_recognition.py
Lines 1331 to 1343 in dbc38df
So in both of your logs
_turn_detector_prediction_futwasNoneand_turn_detector_flushedwasTrue. A late final with a prediction still pending would log neither line. Links are to 1.6.5, your version. Main has the same code:agents/livekit-agents/livekit/agents/voice/audio_recognition.py
Lines 1610 to 1622 in 0f3af69
agents/livekit-agents/livekit/agents/voice/audio_recognition.py
Lines 1719 to 1722 in 0f3af69
For the marker idea above, that branch is the only place that knows a commit came from a late transcript.
_EndOfTurnInfohas no field to carry it yet:agents/livekit-agents/livekit/agents/voice/audio_recognition.py
Lines 71 to 83 in 0f3af69