alert-continent-21953
10/14/2025, 4:44 PMtall-airline-16756
10/14/2025, 4:45 PMtall-airline-16756
10/14/2025, 4:45 PMalert-continent-21953
10/14/2025, 4:45 PMtall-airline-16756
10/14/2025, 4:46 PMtotal_latency = eou.end_of_utterance_delay + llm.ttft + tts.ttfb! This is a great way to capture the end-to-end latency in a LiveKit agent conversation by combining the delays from end-of-utterance detection, LLM response, and TTS generation. Let me walk you through how you can implement this in your agent.py code:
1. First, keep track of the metrics for each part: eou.end_of_utterance_delay, llm.ttft, and tts.ttfb.
2. Make sure to store these metrics with a unique identifier like speech_id so you can easily correlate them.
3. Once you have all the metrics, calculate the total latency using the formula.
4. If you want, you can also log this latency or send it to a monitoring system to keep an eye on performance.
If you'd like, I’d be happy to provide a detailed code example or help clarify any part of this process. Just let me know!
Sources: How can I reduce latency in voice agents using STT, TTS and LLM? | Operational Guidance & Best Practices | livekit/livekit_composite | DeepWik... | tests/test_agent_session.py | metrics/send-metrics-to-3p/send_metrics_to_3p.py