Time to First Response
The time to first response metric checks whether your voice agent greets the caller promptly once the call connects, rather than leaving the line silent. It returns 1 when the first response came in time and 0 when it didn't.
Required Arguments
To use the TimeToFirstResponseMetric, 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 turns, each with astart_timein seconds since the call connected
* 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.
When the test case has full call audio, it's used and the turns' audio is ignored. See How Is It Calculated for how each is used.
Usage
The TimeToFirstResponseMetric() 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 TimeToFirstResponseMetric
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 = TimeToFirstResponseMetric(max_wait_seconds=3)
evaluate(test_cases=test_cases, metrics=[metric])There are TWO optional parameters specific to the TimeToFirstResponseMetric, on top of the common voice metric parameters:
- [Optional]
max_wait_seconds: an integer for the longest wait, in seconds, before the agent's first response. Must be greater than 0. Defaulted to3. - [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's first words. On the agent's side, any sound counts as the first response. Defaulted toTrue.
As a standalone
You can also run the TimeToFirstResponseMetric 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
A slow first response shows up in score_breakdown. Here is what the example call returns:
{
"eligible_turns": 1,
"turns_with_events": 1,
"events": [
{
"type": "slow_first_response",
"duration_seconds": 3.4,
"start_time": 1.6,
"mark": "range",
"timing_source": "call_recording",
"description": "Agent took 3.4s to first respond",
"reply_start": 5.0,
"first_response_seconds": 3.4,
}
],
"skipped": [],
"timing_source": "call_recording",
}| Field | What it means |
|---|---|
reply_start | When the agent first made sound, in seconds into the call |
first_response_seconds | How long the wait was |
start_time | Where the wait begins: the start of the call, or the end of the caller's first words. Always 0 with per-turn audio |
duration_seconds | How long the wait lasted, the same as first_response_seconds |
Every event also has the fields all voice events share, such as mark and description. With per-turn audio, the event carries turn, the index of the greeting's turn, instead of reply_start.
eligible_turns is always 1, the agent's first response, and turns_with_events is 1 when it was slow, which makes the score 0.
How Is It Calculated?
The TimeToFirstResponseMetric score is calculated according to the following equation:
With per-turn audio instead of full call audio, the first response is the agent's first sound in any of its clips, placed on the call's clock by its Audio.start_time. The wait always runs from 0 on that clock, which is taken as the moment the call connected, to that first sound, so an agent clip with start_time=4.0 that starts with sound is a 4-second wait. Who spoke first doesn't move the start of the wait: if the caller's speech starts before the agent's first sound, the metric is skipped instead. The event carries the greeting's turn, turn, instead of reply_start.
Finding the first response
With full call audio, the first response is the agent's first sound on its channel, and the wait depends on who spoke first:
- The agent speaks first: from the start of the full call audio to the agent's first sound.
- The caller speaks first, within
max_wait_seconds: from the end of the caller's first words to the agent's first sound, or 0 if the agent starts before those words end. Pauses under 0.5 seconds don't end the first words, as in the diagram above. - The caller speaks first, but only after more than
max_wait_seconds: the caller waited in silence for a greeting that never came. The wait runs from the start of the full call audio to the caller's first words, so it's always too long.
Wait criteria
| Check | Rule |
|---|---|
| Wait | More than max_wait_seconds, 3 seconds by default |
The metric is skipped when the agent makes no sound in the full call audio, or, with per-turn audio, when the call has no timed audio, an audio turn has no start_time, or the caller speaks first, since the agent then wasn't expected to greet.
Example call
A call with a slow start, where the caller says hello first.
| First response | Wait | Slow? |
|---|---|---|
| 5.0 s, after the caller's hello ended at 1.6 s | 3.4 s | Yes |
| 1 response | slow → 0 |
FAQs
Why is my call skipped when the caller speaks first?
max_wait_seconds of the call connecting.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.