Measuring Voice Agent Latency: Per-Stage Timings, p50 vs p95, and a Launch Checklist
The problem
You built a voice agent. It feels quick when you test it at your desk. Then real callers start using it, and some of them say it "freezes" or "talks over them". Your average response time still looks fine.
That gap usually comes from three mistakes:
- You measured one number for the whole reply, so you can't tell which stage was slow.
- You looked at the average, which hides the slow turns people remember.
- You measured inside your server, not from the caller's ear.
This post fixes all three. It shows which stages to time, how to join those timings into one record per turn, why p95 matters more than p50, how to check latency from the user's side, and what to verify before you put real traffic on the agent.
The running example is a fictional pharmacy refill line. A caller says "I need to refill my blood pressure prescription", the agent checks the refill status with a tool, and then answers. Part 2 of this series, where the time goes in a real-time voice agent, covers the latency budget in general. This part is about measuring it.
The code below uses LiveKit Agents for Python, written against version 1.9.0 (the latest on PyPI on 26 Nov 2026) and the LiveKit data hooks docs page. It is an example. It has not been run.
The stages worth timing
A cascade voice agent (speech to text, then a language model, then text to speech) has four waits between "the caller stops talking" and "the caller hears the agent". If you need a refresher on cascades versus speech-to-speech models, see part 5.
1. End of utterance delay. The time from the moment voice activity detection (VAD, the model that hears speech versus silence) says the caller stopped, to the moment the system decides the turn is really over. This is a deliberate wait. The agent holds back in case the caller is only pausing. Part 3 explains how a turn detector makes that call.
2. STT final. The time until the speech to text (STT) service returns its final transcript after speech ends. LiveKit's docs say its end of utterance metric is measured from VAD end of speech and includes this transcription delay, so do not add the two together.
3. LLM time to first token (TTFT). How long the language model takes to produce its first piece of text after it gets the prompt. Tool calls matter here. In the pharmacy example, the model first asks for the refill-status tool, waits for the result, and then generates the spoken answer. That is two model calls in one turn.
4. TTS time to first byte (TTFB). How long the text to speech (TTS) service takes to return the first chunk of audio after it receives text.
Then there is the gap nobody's server sees: audio travelling over the network to the caller and sitting in their device's jitter buffer (a small queue that smooths out uneven packet arrival) before it plays.
Where LiveKit puts these numbers
The data hooks page lists four surfaces for metrics. Two matter for per-turn latency.
Per-turn metrics on chat messages. Every ChatMessage in the conversation has a metrics field. From the 1.9.0 source, the user message carries:
transcription_delay: time to get the transcript after the user's speech ended.end_of_turn_delay: time between the end of speech and the decision to end the user's turn.stopped_speaking_at: a timestamp.
The assistant message carries:
llm_node_ttft: time for the LLM step to return its first token.llm_node_ttfs: time from LLM generation start until the first sentence reached the TTS provider.tts_node_ttfb: time for the TTS step to return its first audio chunk after the first text was sent.e2e_latency: time from when the user finished speaking to when the agent began responding. In the 1.9.0 source this is computed as the agent'sstarted_speaking_atminus the user'sstopped_speaking_at.playback_latency: the source docstring says this is near zero for the default room output, because it is recorded when the frame is pushed to the track and does not account for network delivery to the client.provider_request_ids: IDs you can use to find the same turn in a provider's own logs.
sequenceDiagram participant U as Caller participant V as VAD and turn detector participant S as STT participant L as LLM participant T as TTS U->>V: stops speaking Note over U,V: stopped_speaking_at S-->>V: final transcript Note over V,S: transcription_delay Note over U,S: end_of_turn_delay, speech end to turn decision V->>L: turn committed, prompt sent Note over L: llm_node_ttft L->>T: first sentence Note over L,T: llm_node_ttfs Note over T: tts_node_ttfb T-->>U: agent starts speaking Note over U,T: e2e_latency stops here, network and jitter buffer come after
Sequence: where each per-turn metric field from the LiveKit 1.9.0 source sits in one turn, measured on the server.
Per-plugin metrics events. Each STT, LLM and TTS plugin also emits a metrics_collected event with its own metrics objects (for example EOUMetrics, LLMMetrics, TTSMetrics). The docs flag some edge cases that break naive joins: LLMMetrics.speech_id is absent for tool-call follow-ups, tool calls emit their own LLM metrics, and TTSMetrics.speech_id is absent for say() and the greeting.
One warning. The session-level metrics_collected event and the UsageCollector helper are deprecated in the current docs. Older tutorials, and plenty of code on GitHub, still use them. Use the per-message metrics instead.
Also note that for realtime (speech-to-speech) models, the docs say llm_node_ttft and tts_node_ttfb are empty, because there is no separate LLM and TTS step.
Joining stages into one record per turn
The goal is one line per turn with every stage in it. The simplest join in LiveKit is to listen to conversation_item_added, remember the last user message's metrics, and write a row when the next assistant message arrives.
python# latency_log.py # Example for livekit-agents 1.9.0. Based on the ChatMessage.metrics # fields described on docs.livekit.io/testing/observability/data/. # Not run. import json import time from livekit.agents import AgentSession, ConversationItemAddedEvent USER_KEYS = ("transcription_delay", "end_of_turn_delay") AGENT_KEYS = ("llm_node_ttft", "llm_node_ttfs", "tts_node_ttfb", "e2e_latency") def attach_latency_log(session: AgentSession, path: str, call_id: str) -> None: last_user: dict = {} @session.on("conversation_item_added") def _on_item(ev: ConversationItemAddedEvent) -> None: nonlocal last_user item = ev.item if item.type != "message": # skip agent handoffs return m = item.metrics or {} if item.role == "user": last_user = {k: m.get(k) for k in USER_KEYS} return if item.role != "assistant": return row = { "call_id": call_id, "logged_at": time.time(), "interrupted": item.interrupted, **last_user, **{k: m.get(k) for k in AGENT_KEYS}, } with open(path, "a") as f: f.write(json.dumps(row) + "\n") last_user = {}
You attach it right after you create the session: attach_latency_log(session, "latency.jsonl", ctx.room.name).
A few things to keep in mind:
- The handler is a plain function, not
async. Keep it short. File writes are fine for a test; in production you would send rows to your logging pipeline instead. - Keep
interruptedin the row. A turn the caller cut off is a different kind of event, and part 4 on barge-in explains why. You may want to report those separately. - Missing values are normal. A greeting has no user turn before it. A reply from a realtime model has no TTFT. Store
null, don't store zero. e2e_latencyalready covers the whole server-side wait. The stage fields tell you which part of it was slow. Don't expect them to add up exactly: stages can overlap, for example when the agent starts generating before the turn is confirmed.
p50 vs p95, and why the tail matters
A percentile is the value below which a given share of your measurements fall. The p50 (median) is the turn in the middle. The p95 is the turn that 95% of turns were faster than.
Here is a small sketch that reads the JSONL file and prints both for each stage. It uses the nearest-rank method, which picks an actual measured value rather than averaging two of them.
python# percentiles.py # Plain Python, no LiveKit imports. Example, not run. import json import math import sys def nearest_rank(values: list[float], p: float) -> float: ordered = sorted(values) rank = max(1, math.ceil(p / 100 * len(ordered))) return ordered[rank - 1] rows = [json.loads(line) for line in open(sys.argv[1])] for key in ("end_of_turn_delay", "transcription_delay", "llm_node_ttft", "tts_node_ttfb", "e2e_latency"): vals = [r[key] for r in rows if r.get(key) is not None] if not vals: continue print(f"{key:20} n={len(vals):4} " f"p50={nearest_rank(vals, 50):.3f}s " f"p95={nearest_rank(vals, 95):.3f}s")
Two pieces of arithmetic are worth doing before you read those numbers.
Small samples lie at the tail. With 20 turns, nearest-rank p95 is rank ceil(0.95 × 20) = 19, so it is the second slowest turn. One bad turn moves it. With 200 turns, p95 is rank 190, and there are ten turns slower than it. Collect hundreds of turns before you trust a p95.
Animation: 20 turns as illustrative, unitless bars. Nearest-rank p95 is the 19th, so one more slow turn makes it jump while p50 stays put.
Calls have many turns, so callers meet the tail. If each turn independently has a 5% chance of being slower than your p95, the chance that a 10-turn call has no slow turn at all is 0.95 to the power of 10, which is about 0.60. So roughly 4 in 10 such calls would include at least one turn beyond your p95. That is an estimate under a simple independence assumption, not a measurement, but it shows why p95 is closer to what callers experience than p50.
The same idea appears in "The Tail at Scale" by Jeffrey Dean and Luiz André Barroso (Communications of the ACM, 2013). They give a hypothetical where a server typically answers in 10 ms but has a 99th-percentile latency of one second: if a request must wait on 100 such servers, 63% of requests take more than a second. They also report a real Google service where the 99th-percentile latency for one random request was 10 ms but 140 ms for all requests to finish. A voice turn is a small version of that chain. It waits on turn detection, STT, the LLM, maybe a tool, and TTS, and the slowest link sets the pause.
Why does a pause matter so much in speech? Stivers and colleagues (PNAS, 2009) measured question and answer timing across 10 languages. Each language's most common gap fell between 0 and 200 ms, and the cross-language median was about 100 ms. The paper also notes that delays carry meaning: in English, responses that don't answer the question are often delayed by up to a second. So a long pause is not neutral. A p50 that looks fine with a p95 well above it means many callers will hit a gap far outside normal conversation timing.
The paper also gives you a tool. Dean and Barroso describe "hedged requests": send a backup request after the first one has been outstanding longer than the 95th-percentile expected time. Their Google benchmark sent about 2% more requests and cut 99.9th-percentile latency from 1,800 ms to 74 ms. You can apply the same thinking to a slow LLM call, which is what an attempt timeout on a fallback adapter does (more on that below).
Measuring from the user's side
Everything above is measured on the agent server. e2e_latency stops when the agent starts sending audio. The caller hears it later, after network transit and their device's jitter buffer.
Two ways to see the real number:
Record both sides and measure the gap. Record a test call with the caller's audio and the agent's audio on separate channels. For each turn, find where the caller's speech ends and where the agent's audio begins, and subtract. Do it at the caller's end, on the phone or browser they actually use. This is slow and manual, but it is the number the caller feels. Comparing it with e2e_latency for the same turns tells you how much the network and playback add.
Read WebRTC stats in the browser client. If your callers use a web client, WebRTC exposes inbound audio statistics. MDN documents jitterBufferDelay, the accumulated time audio samples spent in the jitter buffer, and says the average is jitterBufferDelay / jitterBufferEmittedCount. MDN also notes that a rising average indicates growing latency. Logging that average per call adds one more stage the server never sees.
For phone callers, the path through SIP and the carrier adds its own delay. That is covered in the voice agent stack on SIP latency budget and how a phone call reaches an AI voice agent, so I won't repeat it here.
LiveKit Cloud also shows per-turn latency in its Agent insights view, according to the data hooks page, and the voice AI quickstart says the Agent Console shows model timing for each turn. Those are useful for a quick look. Your own JSONL gives you the raw rows to compute percentiles across many calls.
A production-readiness checklist
Latency numbers are only one part of being ready for real callers. Here is the list I would check before turning on traffic for the pharmacy line. Each item points to the doc page it comes from.
flowchart TD A[Agent works at your desk] --> B{Backup model for each stage?} B -->|no| X[Fix it, then check again] B -->|yes| C{Timeouts set for LLM and tools?} C -->|no| X C -->|yes| D{Spoken line for slow tools and fatal errors?} D -->|no| X D -->|yes| E{One row per turn, p50 and p95 per stage?} E -->|no| X E -->|yes| F{Load test run, p95 compared?} F -->|no| X F -->|yes| G[Turn on real traffic]
Flowchart: the five checks below in order (fallbacks, timeouts, error speech, observability, load), each one a gate before real callers.
Fallbacks. The LiveKit fallback strategies page describes three mechanisms: a server-side fallback inside LiveKit Inference for STT and TTS, an in-process fallback adapter for STT, TTS and LLM, and a fallback adapter for realtime models. Check these points:
- Each stage has at least one backup model.
- You know that the LLM adapter raises an error, rather than switching, if text was already sent, unless you set
retry_on_chunk_sent=True. - You know that an Inference TTS fallback replays the whole turn, so the caller might hear the start twice.
- You listen for availability-change events on the adapter so you can see when a provider drops out.
Timeouts.
- The LLM fallback adapter has an
attempt_timeout(default 5.0 seconds in 1.9.0) that fits your budget. - MCP tool servers have a
client_session_timeout_secondsthat fits your slowest tool. See part 7 on giving a voice agent tools with MCP. - A slow tool has a spoken filler, so the caller doesn't sit in silence while the refill lookup runs.
Error speech.
- The fallback strategies page says a successful fallback raises no error event; an
errorevent fires only when no provider can serve. That event carries arecoverableflag. When it isFalse, the agent says something short like "Sorry, I'm having trouble on my end. Please call back in a few minutes," instead of going silent.
Observability.
- One row per turn with every stage, as above, plus
provider_request_idsso you can match a slow turn to the provider's logs. - p50 and p95 per stage, per day, with the sample size next to each.
- A session report at the end of each call. The data hooks page describes
ctx.make_session_report()in anon_session_endcallback.
Load.
- Run a load test before launch. The LiveKit load testing page describes
lk perf agent-load-test. It opens rooms one at a time, dispatches your running agent to each, and plays the agent's own speech back to it after a delay (--echo-speech-delay, default 5 s) to simulate a user. Options include--rooms,--agent-nameand--duration. When the test ends, it prints each room's dispatch time and agent join delay. - Note the page's caution: load testing on LiveKit Cloud is restricted by its acceptable use policy, and test traffic counts toward your plan's included allowances.
- Compare p95 from your JSONL at low load and under load. If the tail grows under load while p50 barely moves, you are queueing somewhere.
- Check where the turn detector runs. The turn detector page says the
v1-minimodel runs locally on CPU, its weights use about 310 to 340 MB, and it recommends compute-optimized instances. A busy CPU there shows up directly as a longer end-of-turn delay.
What to do with the numbers
Once you have per-stage p50 and p95:
- If
end_of_turn_delaydominates, tune endpointing. The turn handling options reference listsendpointingwithmin_delay(default 0.5 s) andmax_delay(default 3.0 s), and the turn detector page says the defaults become 0.3 s and 2.5 s when the turn detector is used. - If
llm_node_ttftdominates on tool turns, look at the tool itself before you swap models. A slow pharmacy database lookup looks like a slow LLM in these numbers. - If the server numbers look fine but callers still complain, the gap is in the network or playback. Go back to the two-channel recording.
LiveKit's turn-taking tuning page notes that preemptive generation (starting the reply before the turn is confirmed) doesn't always reduce latency, and it says to use observability to check. That is the whole point of this post. Measure first, then change one thing, then measure again.
Part 9, build a voice agent with LiveKit Agents, puts this metrics hook into a complete agent.
New to a term used here? The series glossary defines VAD, endpointing, barge-in, full-duplex, MCP, p95 and the rest in plain language.
Sources
- LiveKit docs: Data hooks (metrics, usage and session reports)
- LiveKit docs: Fallback strategies
- LiveKit docs: Turn detector
- LiveKit docs: Turn handling options reference
- LiveKit docs: Turn-taking tuning
- LiveKit docs: Load testing with lk perf
- LiveKit docs: Voice AI quickstart
- livekit-agents on PyPI (version 1.9.0 source read for field definitions)
- Dean and Barroso, The Tail at Scale, Communications of the ACM, February 2013
- Stivers et al., Universals and cultural variation in turn-taking in conversation, PNAS 2009
- MDN: RTCInboundRtpStreamStats jitterBufferDelay
