📍 Join the 1st DeepEval meetup in SF, this Friday 5pm PT. RSVP on Luma →
💥 Introducing JevEval: Jev-as-a-Judge for LLM evaluation. Read the post →
Voice AgentsTiming

Response Latency

Beta
Multi-turn
Referenceless
Chatbot
Voice

The response latency metric checks whether your voice agent answers without a long wait, rather than leaving the caller in silence after they finish speaking. It returns the share of agent replies that started in time, between 0 and 1.

CallerAgent
0.0s / 15.4s

Required Arguments

To use the ResponseLatencyMetric, you'll have to provide a ConversationalTestCase with at least one of:

  • audio on the test case, a 16-bit stereo WAV recording of the whole call*
  • audio on the caller's and agent's turns, each with a start_time

Agent turns can also carry latency_ms, the response latency your connector recorded for that reply. It's only used with per-turn audio.

* Full call audio has to be a 16-bit stereo WAV, with the caller and agent on separate channels. Mono full call audio is ignored, because the two voices can't be told apart, and so is audio in any other format, such as MP3.

See How Is It Calculated for how each is used.

Usage

The ResponseLatencyMetric() can be used for end-to-end evaluation of voice calls, such as ones produced by the ConversationSimulator in voice mode:

from deepeval import evaluate
from deepeval.dataset import ConversationalGolden
from deepeval.metrics import ResponseLatencyMetric
from deepeval.simulator import ConversationSimulator
from deepeval.voice import ElevenLabsConnector, VoiceConfig


golden = ConversationalGolden(
    scenario="The user asks the agent to look up an order by its number.",
    expected_outcome="The agent reads back the order status.",
)

simulator = ConversationSimulator(
    voice_config=VoiceConfig(
        connector=ElevenLabsConnector(agent_id="your-agent-id"),
    )
)
test_cases = simulator.simulate([golden])

metric = ResponseLatencyMetric(threshold=0.8, max_latency_seconds=4)
evaluate(test_cases=test_cases, metrics=[metric])

There are TWO optional parameters specific to the ResponseLatencyMetric, on top of the common voice metric parameters:

  • [Optional] max_latency_seconds: an integer for the longest wait, in seconds, between the caller finishing and the agent starting to speak. Must be greater than 0. Defaulted to 4.
  • [Optional] use_speech_detection: a boolean which, when set to True, only counts the caller as talking when speech is detected, so background noise isn't mistaken for the caller and doesn't shorten or stretch a wait. With per-turn audio it's also used to find the agent's speech. Defaulted to True.

As a standalone

You can also run the ResponseLatencyMetric on a single test case as a standalone, one-off execution:

metric.measure(test_cases[0])

print(metric.score, metric.reason)
print(metric.score_breakdown)

See Events for what score_breakdown contains.

Events

Each slow reply shows up in score_breakdown. Here is what the example call returns:

{
    "eligible_turns": 3,
    "turns_with_events": 1,
    "events": [
        {
            "type": "slow_response",
            "duration_seconds": 4.8,
            "start_time": 10.0,
            "mark": "range",
            "timing_source": "call_recording",
            "description": "Agent took 4.8s to reply",
            "reply_start": 14.8,
            "response_delay_seconds": 4.8,
        }
    ],
    "skipped": [
        {"reply_start": 25.0, "error": "Agent started before the caller finished."}
    ],
    "timing_source": "call_recording",
}
FieldWhat it means
reply_startWhen the slow reply started, in seconds into the call
response_delay_secondsHow long the caller waited for it
start_timeWhere the wait begins: when the caller stopped talking
duration_secondsHow long the wait lasted, the same as response_delay_seconds

Every event also has the fields all voice events share, such as mark and description. Replies that couldn't be timed are listed under skipped with the reason. With per-turn audio, events and skipped entries carry turn, the index of the agent turn, instead of reply_start.

eligible_turns is how many agent replies were timed and turns_with_events how many were slow. The score is the share that weren't.

How Is It Calculated?

The ResponseLatencyMetric score is calculated according to the following equation:

Response Latency=Number of Agent Replies Within the Wait LimitTotal Number of Timed Agent Replies\text{Response Latency} = \frac{\text{Number of Agent Replies Within the Wait Limit}}{\text{Total Number of Timed Agent Replies}}

With per-turn audio instead of full call audio, each agent clip that directly follows a caller clip is one reply, and the speech heard inside each clip is placed on the call's clock by its Audio.start_time. Events carry the agent turn's index, turn, instead of reply_start.

Counting agent replies

CallerAgentgreetingreply 1reply 20s2s4s6s8s10s12s

A reply is a timed reply that comes after the caller spoke. An opening line spoken before the caller makes any sound answers no one, so it isn't counted. Time to First Response times it instead.

Latency criteria

The wait runs from where the caller's speech ends to where the agent's speech starts.

CallerAgent0.8 s4.6 s0s2s4s6s8s10s12s14s

With full call audio, that is the silence between the two channels, and latency_ms on the turns is ignored. With per-turn audio, an agent turn's latency_ms is the wait when it has one; otherwise the silence heard between the clips is used.

A reply is slow when:

CheckRule
WaitMore than max_latency_seconds, 4 seconds by default
OverlapThe agent starting up to 0.5 seconds before the caller finishes counts as no wait

A reply isn't timed, and is listed under skipped, when:

  • the agent started more than 0.5 seconds before the caller finished, which Agent Interruption judges instead,
  • with per-turn audio, the caller's or the agent's clip can't be decoded, or
  • with per-turn audio, the two clips touch with speech right up to where they meet, and there's no latency_ms, so no silence can be heard.

If there's nothing to count, the metric is skipped.

Example call

A call where the agent is sometimes slow to answer. Each row is one agent reply and how long the caller waited for it.

CallerAgent0.8 s4.8 s1.2 sover caller0s5s10s15s20s25s
Agent replyWaitSlow?
0.2 sGreeting, before the caller spokeNot counted
5.4 s0.8 sNo
14.8 s4.8 sYes
20.6 s1.2 sNo
25.0 sStarted 1.2 s before the caller finishedSkipped
3 replies1 slow → 2/3 = 0.67

FAQs

Which wins, latency_ms or the audio?
With stereo full call audio, the audio always wins and latency_ms is ignored. With per-turn audio, latency_ms wins when the agent turn has one, and the silence heard between the clips is only used for turns without it.
How is this different from turn-taking naturalness?
TurnTakingNaturalnessMetric runs this metric together with both kinds of interruption and response delay consistency, and scores the share of agent replies none of them flagged. This metric only checks whether the caller waited too long.
Does this metric call an LLM or an external speech model?
No. It only reads when each speaker is talking, so it has no model or token cost. With use_speech_detection on, it runs the small Silero VAD model locally.
Does it check the caller's audio too?
No. The caller's audio is only used to know when the caller stopped talking. Only the agent is judged.

On this page