False interruption keeps stale started_speaking_at for next user turn
Bug Description
After a confirmed false interruption resumes agent speech, LiveKit Agents keeps the discarded user recognition turn alive. The next real user transcript inherits the false turn's original speech-start anchor, so ChatMessage.metrics.started_speaking_at can predate the actual utterance and be ordered before agent speech that really occurred first.
This reproduces on livekit-agents==1.7.1. The ordering guard from #6093 / #6098 does not cover it because the resulting user metrics remain internally ordered (stopped_speaking_at >= started_speaking_at); the start anchor is stale but not mathematically impossible.
Deterministic timeline
Observed production timeline, UTC:
19:20:06.481— VAD opens a user turn; no STT is committed.19:20:10.114— LiveKit confirms a false interruption and resumes the paused agent speech.19:20:18.632— the user actually begins the later utterance.- The committed user
ChatMessagereportsstarted_speaking_at = 19:20:06.481, 12.151 seconds before the real utterance.
This incorrectly places the user line before the resumed agent response in timestamp-sorted transcripts.
Deterministic code-path reproduction
On 1.7.1:
- Create an
AgentActivitywithresume_false_interruption=True, paused speech whoseagent_state == "speaking", and an activeAudioRecognitionturn with_speech_start_timeset by VAD but no committed transcript. - Trigger
_start_false_interruption_timer(0)and let_on_false_interruption(resumed=True)complete. - Observe that agent speech starts/resumes, but
AudioRecognition._clear_user_turn()is never called. - Emit a later real user utterance and commit its transcript.
- The resulting
ChatMessage.metrics.started_speaking_atis the step-1 VAD timestamp, not the later utterance's start.
A deterministic spy around step 2 shows the current resume path lacks recognition cleanup. The local patch changes the event order to:
clear_user_turn -> start_agent_speech -> audio_resume
Expected Behavior
Once a false interruption is confirmed and paused agent audio will resume, the uncommitted recognition turn should be discarded before agent speech resumes. Its logical-turn/span anchor, speech timing anchors, buffered transcript, and related turn state must not survive into the next real user utterance.
Actual Behavior
_on_false_interruption resumes the agent state/audio without clearing the active recognition turn. The next committed user message can inherit the abandoned turn's started_speaking_at.
Proposed Solution
Call the recognition turn's existing full clear/reset path before _on_start_of_agent_speech and audio resume when agent_false_interruption(resumed=True) is accepted. Resetting only _speech_start_time would leave other discarded-turn state behind.
PeakSend has a version- and checksum-pinned 1.7.1 patch implementing and build-verifying this ordering:
- Patch PR: https://github.com/PeakSend-AI/peaksend/pull/561
- Production RCA: https://github.com/PeakSend-AI/peaksend/issues/559
Those links are in a private repository, but the complete reproduction timeline and patch boundary are included above.
Package Versions
livekit-agents==1.7.1
The original incident was observed on 1.6.9 and confirmed against the 1.7.1 source.
Confirmed on current main, and the root cause sits one step deeper than the resume path missing a cleanup call: _ensure_user_turn_span returns a recording span as-is, and _user_turn_start is only written when it is None. Once the false turn's span survives the resume, the next real utterance silently reuses both, and _bounce_eou_task stamps the abandoned turn's start into started_speaking_at at commit. The #6093 guard can't catch it because the anchors stay internally consistent; they are just anchored to a dead turn.
Fix: #7101. It follows the ordering you proposed (discard before state restore and audio resume), with two deviations:
- the clear is skipped when the user is speaking at the moment the timer fires. Those anchors belong to a live utterance, and the timer can genuinely fire mid-speech: a below-min_duration VAD segment never reaches the timer reset in
_interrupt_by_audio_activity. - the discard keeps the live STT stream (
reset_stt=False) instead of the full_clear_user_turnteardown. Recreating the provider stream on every false interruption is costly, and worse, it drops audio the provider is still decoding: if the barge-in was real after all (a VAD miss), that late final is the only thing left that can interrupt the resumed speech.
One behavior note: a final arriving after the resume now commits as a fresh turn without started_speaking_at, since the anchors are gone. Unknown seemed more honest than an anchor the system had already declared false.
A correction to my comment above: I hadn't seen #7066 and #7067 when I opened #7101, my mistake for missing the linked PRs. Since there are three attempts now, a comparison for whoever reviews this:
All three discard the abandoned turn on resume, so the reported bug is fixed by any of them. The differences are in what survives the discard.
#7067 calls the full _clear_user_turn() unconditionally. That recreates the STT pipeline (_update_stt(None) and back) on every false interruption, and it drops audio the provider is still decoding, which is the only thing left that can interrupt the resumed speech when the barge-in was real and VAD missed it.
#7066 splits by whether the end-of-turn decision ran: full clear for a decided-and-dropped turn, a lighter anchor release when no decision ever ran. The _open_user_turn centralization there is good hygiene whichever PR lands. Three things I'd flag: the decided-and-dropped branch still does the full STT teardown, and per that PR's own analysis the dropped backchannel is the common case, so the reconnect cost lands on the common path. The release can also fire while the user is mid-speech, through two windows: a below-min_duration VAD segment never resets the timer (and has no open eou task for the timeout to defer to), and in stt mode a premature STT END_OF_SPEECH clears _speaking while VAD is still mid-segment; in both, the release takes a live utterance's anchor and span with it. And since every path that appends a final to the transcript also starts the eou bounce, the undecided branch runs with an empty transcript in practice, so the preservation it buys is narrow.
#7101 keeps the STT pipeline in all branches (reset_stt=False on the existing clear) and skips the discard entirely while either STT or VAD still tracks live speech. The trade-off relative to #7066: no decided/undecided split, the release is uniform.
Happy to fold #7101's deltas into #7066 if that's the preferred base, the split and the deltas are not mutually exclusive.
This also happens without a false interruption. Any VAD segment that produces no transcript opens the user turn, and the next real utterance inherits its start time, because _user_turn_start is only cleared when a turn commits. A resumed false interruption is one way in. In our production calls it mostly happens when noise arrives while the agent is still generating its reply, before any audio plays, so there's nothing to resume.
Example from one call (seconds into the recording): a blip at 27.88, the agent spoke 29.98–40.25, the user answered 40.4–51.2, and the user message reported started_speaking_at = 27.88. Same call: 53.54 reported for an answer that started at 71.2.
#7666 fixes this where the start time is chosen: it reports the start of the utterance that produced the turn's first transcript. That covers the resume case in this issue too, and there's a test for it.
Additional reproduction on Python Agents 1.8.6: an untranscribed VAD cycle can backdate a later recording-consent retry, without any false-interruption resume.
Environment and reproduction boundary
livekit-agents==1.8.6,livekit-plugins-silero==1.8.6,livekit==1.1.20.- Unmodified installed SDK. Networkless deterministic local harness using a real
AgentSession, deterministic STT events and PCM output, and application consent logic. - The harness injects VAD events into the SDK's actual
_on_vad_eventhandler and reads the anchors; it does not assign either anchor or patch SDK behavior. This reproduces the event/state interaction, not the accuracy of an acoustic VAD classifier. - The application requires an answer spoken after its clarification finishes. It currently checks committed-message
started_speaking_atagainst the completed-playback boundary. Consent decisions below are made by that application, not a built-in SDK consent feature.
Deterministic sequence
- Clear the previous user turn before delivering a clarification.
- While the question is playing, deliver VAD
START_OF_SPEECH, thenEND_OF_SPEECH, with no transcript for that segment. - Let the question finish completely.
- Deliver a new VAD
START_OF_SPEECH, followed by STT START, FINAL(Yes, go ahead.), END. - Observe both the latest speech-segment anchor and the committed message metrics.
The latest _speech_start_time moves forward, but _user_turn_start remains the earlier uncommitted turn's start and is used for the committed started_speaking_at.
All three controls ran in the same networkless reproduction. Times below are relative to completion of the question in each case:
| Case | Latest speech-segment start | Committed started_speaking_at |
Application result |
|---|---|---|---|
| Fresh answer, no preceding empty VAD cycle | +21.065 ms | +21.065 ms | Granted, as expected |
| Empty VAD cycle during question, then the same fresh complete answer | +21.162 ms | −14.727 ms | Declined despite the fresh answer |
| Genuine speech overlap during question, delayed affirmative transcript | −12.581 ms | −12.581 ms | Declined, as expected |
Raw timing values for the second case:
{
"old_speech_start": 1791660369.400135,
"old_turn_start": 1791660369.400135,
"clarification_end": 1791660369.4148622,
"speech_start_before_final": 1791660369.436024,
"turn_start_before_final": 1791660369.400135,
"commit_metrics": {
"started_speaking_at": 1791660369.400135,
"stopped_speaking_at": 1791660369.44707
}
}
The reproduction retains the failing expected-grant assertion for the second case. The application continues to fail closed; we have not relaxed the consent guard.
Provenance contract needed for this use case
The old value can accurately describe the logical uncommitted turn. The difficulty is that it does not establish which speech segment produced the recognized words. An earlier segment without a transcript could contain real speech, including a delayed conditional prefix. We therefore cannot safely substitute the latest VAD timestamp, infer ownership from transcript receipt time, or discard input after playback just to make the positive case pass.
A supported per-segment/stream-epoch provenance field on committed transcript data, or a documented input/commit barrier that excludes delayed old-generation results from a new retry, would help. The important counterexamples are:
- complete fresh affirmative following a genuinely empty earlier segment;
- speech that really overlaps the question;
- delayed earlier words or a conditional prefix arriving after newer speech;
- missing/unaligned provider word timings, stream restarts and handoffs.
Relation to #7666
I found #7666 while checking for duplicates before posting this report. Its utterance tracking addresses this family of failures more directly than the separate end-time/late-final/manual-commit PRs #7694, #7717 and #7702.
I have not tested #7666 against this harness and am not claiming it fixes or breaks these cases. Two aspects of its current diff matter for our use case: it deliberately groups VAD segments less than 2 seconds apart, and when timing is missing or unmatched it associates the first final with the current utterance. The local reproduction above uses a short interval, so its expectation is a stricter provenance requirement than that documented grouping rule. Is there a supported way for an application to distinguish a verified segment match from that fallback, while retaining all delayed words? An explicit unknown/provenance status would be useful for consent without redefining logical-turn metrics.
This report concerns the independently reproduced timing case. Separate noisy-audio fragment timeouts and recognition losses in broader simulations are not attributed to this mechanism without matching evidence.
Thanks for the detailed reproductions and discussion.
started_speaking_at belongs to the whole user turn, which can include several VAD segments. Resuming agent speech doesn't close that turn. STT can still return words for earlier audio, so we keep the pending state until the turn commits.
For the transcript display, you can sort by stopped_speaking_at when available to get completion order. Overlapping speech can still make the order ambiguous, though.
If you want to ignore particular speech transcript, you can filter STT events using speech_end_time where available. Adaptive interruption does this after classifying the overlap as a backchannel. A resume timeout alone doesn't tell us that the input can be discarded.
I will close this as expected behavior next week. Feel free to comment if you have more to add.
Thanks for clarifying. I follow that started_speaking_at is turn-scoped and that a resume alone is not enough to discard pending input. The sharp edge for apps is transcript / consent ordering: an uncommitted VAD segment (false-interruption residue or noise with no transcript) can still stamp the next real utterance tens of seconds early, which is what #7067 and #7666 were trying to fix. If the current semantics stay, would you be open to documenting that apps should prefer stopped_speaking_at / speech_end_time for ordering, or to keeping a narrower transcript-facing fix under review before closing?
Following up on my earlier question: I am closing #7067, since the behaviour it changed is the behaviour you described as intended, and the other attempts (#7066, #7101, #7666) are easier to review without a fourth one in the queue.
Leaving the reproducible part of it here, in case it is useful later. As reported above, a VAD segment that never produces a transcript still opens a user turn; if that turn never commits, the next real utterance can inherit the stale start, so started_speaking_at on the committed turn is backdated. The false-interruption resume is one way in, but the untranscribed-noise case reproduces it on 1.8.6 with no resume involved.
The display guidance (sort by stopped_speaking_at when present) covers transcript consumers, so I am not asking for a change to the turn model. The open question for me is whether that stale-start path is a known trade-off or something you would treat as a bug. If it is the former, that is a fine answer, and it would help to have it written down where app authors will find it.
Thanks for the follow up! I can definitely see where you are coming from.
an uncommitted VAD segment (false-interruption residue or noise with no transcript) can still stamp the next real utterance tens of seconds early
I would say it is one of the possibilities:
- STT delays the transcript for the first utterance until the second VAD utterance helps it finalize;
- STT ignores the first utterance, even if the speech is valid;
- VAD speech is a false positive, coming from background noise;
The framework currently can't differentiate them cleanly. I think a better way to handle this is to tighten the window if word timestamps are available, so you can get:
- turn start and end
- within a turn, start and end from word timestamps
I will keep this issue open for now.