AMD.execute() takes 7-16s on outbound human calls; first-utterance latency caused by VAD event ordering + 20s detection_timeout
Summary
AMD.execute() produced 7-16 seconds of first-utterance latency on outbound human calls in our setup. During that window speech-playout authorization is paused, so the agent's pre-synthesized response is held back even though TTS is ready in <2s.
Concrete trace
22:49:47.762 First user transcript received (lead spoke)
22:49:47.905 First EOU metrics (turn-end detected, +143ms)
22:49:48.658 First LLM metrics (LLM response ready, +0.9s)
22:49:50.920 First TTS metrics (TTS audio synthesized, +3.1s)
22:50:07.181 AMD result (verdict, +19.4s — hits 20s TIMEOUT)
22:50:08.318 First agent playout (audio finally plays, +20.5s)
AMDResult.delay was negative and speech_duration=0.00, suggesting the classifier never received clean on_user_speech_started/on_user_speech_ended signals from the audio recognition pipeline. We see WARNING: on_user_speech_ended called before on_user_speech_started in the same session — likely the cause of AMD falling through to the 20s detection timeout.
Observed across calls
- Run A: 7s — room_id
RM_pB6TAxzTeYQL, job_idAJ_EQ8R3ZT6twDj, room namesequence-ptl_PoMGHb6sdHsyWo, AMD result at 2026-04-30T22:45:47Z - Run B: 9.8s — room_id
RM_9F6ETQfMw4bv, job_idAJ_d3m2KaEEwiju, room namesequence-ptl_fXhUHDodxFc1Dj, AMD result at 2026-04-30T22:47:51Z - Run C: 16s — room_id
RM_LDuQeKsWt8rk, job_idAJ_T4Yk6Nrg2vbq, room namesequence-ptl_Wof1AJuPHsdsGZ, AMD result at 2026-04-30T22:50:07Z
LiveKit Cloud project slug: mav-development (DM if you need the full project URL).
Setup
livekit-agents 1.5.7AMD(session, llm="openai/gpt-4.1-mini")perexamples/telephony/amd.py, called from inside an outbound entrypoint after the SIP participant connects- STT:
deepgram/nova-2-phonecall(the canonical example usesnova-3language="multi"— could be the trigger for the ordering bug) - Turn detection:
MultilingualModel() - VAD: silero
preemptive_generation=True- Endpointing overrides:
min_endpointing_delay=0.1,max_endpointing_delay=0.6(we use shorter than defaults to lower hello-to-response time)
What would help users
- Document the speech-playout pause behavior of
async with AMD(...)somewhere reachable fromdocs.livekit.io/agents/start/telephony/. The class docstring is the only mention today and there's no quantification or trade-off discussion. Production users hit this and are surprised. - Quantify the expected first-utterance latency on the human path in the canonical example or its README. Even a "this typically adds ~Xs before the agent first speaks" note would help integrators decide whether AMD fits their UX budget.
- Investigate why
on_user_speech_endedcan fire beforeon_user_speech_startedwithnova-2-phonecallSTT — that ordering breaks AMD's classifier signals and pushes detection to the 20s timeout.
We're reverting AMD on our outbound flow for now and going back to a regex+silence-watcher approach. Happy to provide additional logs from any of the three runs above.
We see WARNING: on_user_speech_ended called before on_user_speech_started in the same session AMD(session, llm="openai/gpt-4.1-mini") per examples/telephony/amd.py, called from inside an outbound entrypoint after the SIP participant connects
If AMD is called after SIP connection, it might lose some user audio. We made some optimization to this in commit, which will be released soon with documentation. Our latest example code calls AMD before the SIP participant creation and connection and only triggers timeout timers when the user track is subscribe.
Happy to revisit this if the upcoming version doesn't solve the issue. Thanks for creating the ticket and sharing the feedback!
From this stack trace, this could be a ai api side timeout issue. You can run npx ai-doctor. It can fix missing timeout guards with safe request timeouts plus timeout and retry protection.