Response Delay Consistency
The response delay consistency metric checks whether your voice agent takes about the same time to answer every time, rather than replying instantly once and making the caller wait seconds the next. It returns the share of agent replies whose wait stays close to the agent's typical wait, between 0 and 1.
Required Arguments
To use the ResponseDelayConsistencyMetric, you'll have to provide a ConversationalTestCase with at least one of:
audioon the test case, a 16-bit stereo WAV recording of the whole call*audioon the caller's and agent's turns, each with astart_time
Agent turns can also carry latency_ms, used with per-turn audio the same way as in Response Latency.
* 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 ResponseDelayConsistencyMetric() 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 ResponseDelayConsistencyMetric
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 = ResponseDelayConsistencyMetric(threshold=0.8, max_shift_seconds=2)
evaluate(test_cases=test_cases, metrics=[metric])There are TWO optional parameters specific to the ResponseDelayConsistencyMetric, on top of the common voice metric parameters:
- [Optional]
max_shift_seconds: an integer for how far, in seconds, a reply's wait may be from the agent's typical wait, slower or faster. Must be greater than 0. Defaulted to2. - [Optional]
use_speech_detection: a boolean which, when set toTrue, 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 toTrue.
As a standalone
You can also run the ResponseDelayConsistencyMetric 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 reply whose wait broke from the usual shows up in score_breakdown. Here is what the example call returns:
{
"eligible_turns": 4,
"turns_with_events": 1,
"events": [
{
"type": "delay_shift",
"duration_seconds": 4.0,
"start_time": 12.6,
"mark": "range",
"timing_source": "call_recording",
"description": "Reply came 2.9s slower than usual",
"reply_start": 16.6,
"response_delay_seconds": 4.0,
"shift_seconds": 2.9,
}
],
"skipped": [],
"timing_source": "call_recording",
}| Field | What it means |
|---|---|
reply_start | When the reply started, in seconds into the call |
response_delay_seconds | How long the caller waited for it |
shift_seconds | How far that wait is from the typical wait. Negative when faster |
start_time | Where the wait begins: when the caller stopped talking |
duration_seconds | How 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 broke from the usual wait. The score is the share that didn't.
How Is It Calculated?
The ResponseDelayConsistencyMetric score is calculated according to the following equation:
With per-turn audio instead of full call audio, events carry the agent turn's index, turn, instead of reply_start.
Counting agent replies
Replies are found and their waits measured exactly as in Response Latency, for both audio formats, and the same replies are listed under skipped.
Consistency criteria
The typical wait is the median of all the replies' waits, so one odd reply is flagged on its own instead of pulling the typical wait towards it. Above, the typical wait is 1.15 seconds, and only reply 3 is far from it.
| Check | Rule |
|---|---|
| Shift | More than max_shift_seconds from the typical wait, 2 seconds by default, slower or faster |
| Replies needed | At least 3 timed replies. With fewer, there's no telling which one is off |
With fewer, or nothing to count, the metric is skipped.
Example call
A call where the agent answers in about a second, except once. Each row is one agent reply, its wait, and how far that is from the typical wait.
| Agent reply | Wait | Shift from 1.1 s | Flagged? |
|---|---|---|---|
| 3.2 s | 0.8 s | −0.3 s | No |
| 8.4 s | 1.0 s | −0.1 s | No |
| 16.6 s | 4.0 s | +2.9 s | Yes |
| 22.0 s | 1.2 s | +0.1 s | No |
| 4 replies | 1 flagged → 3/4 = 0.75 |
FAQs
Why is a fast reply flagged?
How is this different from turn-taking naturalness?
Does this metric call an LLM or an external speech model?
use_speech_detection on, it runs the small Silero VAD model locally.