#5921·pipecat

UserBotLatencyObserver drops STT events arriving before VADUserStoppedSpeakingFrame

Author: maviszeng-qarlCreated Sep 25, 2026Updated Oct 1, 2026

Summary

  • UserBotLatencyObserver (pipecat 1.9+) silently drops any TranscriptionFrame or STT-owned TTFBMetricsData that arrives before VADUserStoppedSpeakingFrame. This happens when a streaming STT service (Azure / Deepgram / etc.) reaches its own internal endpointing before Silero VAD's stop_secs accumulator does.

  • Result: LatencyBreakdown.contributions is missing the transcription and turn_detection stages for every affected turn, and stage.transcription / stage.turn_detection disappear from downstream dashboards.

Repro

  • pipecat 1.11.0 (also present since PR #5445 in 1.9.0)
  • STT: AzureSTTService (streaming, self-endpointing)
  • VAD: SileroVADAnalyzer with stop_secs=1.0
  • Pipeline: standard STT → LLM → TTS

Evidence

Wall-clock timestamps of TranscriptionFrame vs VADUserStoppedSpeakingFrame reaching the observer, over three consecutive turns:

Turn transcription (ms) vad_stopped (ms) delta
1 27619 27692 -73
2 39183 39301 -118
3 41865 41992 -127

TranscriptionFrame reliably lands 70-130 ms before the VAD frame in this setup. Azure's own endpointing (silence + LM + intonation) finalizes around 900 ms after the user stops speaking; Silero with stop_secs=1.0 fires around 1000 ms. Both timers run in parallel and independently.

Root cause

PR #5445 introduced these three changes in user_bot_latency_observer.py:

  1. _mark() gates on if not self._measuring: return None
  2. _measuring is True only after _user_stopped_time is set
  3. _user_stopped_time is set only when VADUserStoppedSpeakingFrame arrives

_handle_metrics_frame has an identical gate for TTFBMetricsData.

The gate implicitly assumes "TranscriptionFrame always lands after VADUserStoppedSpeakingFrame". That holds for local Whisper-style STTs and for streaming STTs in EXTERNAL turn-detection mode. It doesn't hold when a streaming STT does its own endpointing and Silero's stop_secs is raised (we use stop_secs=1.0 to absorb speech pauses in dual-bot testing).

Impact

  • LatencyBreakdown.contributions is missing transcription and turn_detection entries for the affected turns
  • LatencyBreakdown.ttfb is missing the STT service's TTFB
  • The lost time (~1s) falls through to the "pipeline" bucket via _build_contributions()'s span-pair fallback
  • Downstream OTel spans and dashboards lose the stages

Suggested direction (leaving to maintainers)

Options I can think of, in rough order of intrusiveness:

  • Buffer pre-VAD_STOP TRANSCRIPT moments and STT TTFBMetricsData and replay them into _moments / _ttfb when VADUserStoppedSpeakingFrame arrives, backdating at to VAD_STOP.at + epsilon so the canonical moment-pair order in _SPANS_BY_MOMENTS is preserved.
  • Or: only gate on cross-cycle staleness (reset marker) rather than on _user_stopped_time is not None, since VADUserStartedSpeakingFrame is a clear "current cycle started" signal.

Workaround

For anyone hitting this before an upstream fix, monkey-patching the observer to defer early TRANSCRIPT moments works — the STT frame's payload is intact, only its at needs to be shifted just after VAD_STOP.at to keep the sort canonical.