salmon-lighter-12882
02/19/2026, 12:40 PMtall-airline-16756
02/19/2026, 12:40 PMtall-airline-16756
02/19/2026, 12:40 PMsession.on("conversation_item_added") will add latency to the session, and whether logic inside the handler can slow things down.
Short answer
• Adding the listener itself does not add meaningful latency to the session. Event handlers are invoked asynchronously after the event occurs, so they do not block the core session flow (real‑time audio, transcription, LLM inference).
• Long‑running or blocking work inside a handler can introduce delays for other event processing in the same context. Use async patterns or background tasks to avoid that.
Recommendations
1. Keep handlers lightweight
◦ Do quick tasks (logging, small state updates) directly in the handler.
1. Offload heavy or blocking work
◦ For I/O, long computations, or calls to remote services, create background tasks with asyncio.create_task() so the handler returns immediately.
1. Use non‑blocking APIs
◦ Prefer async libraries for network and disk I/O so the event loop remains responsive.
1. Monitor if needed
◦ If you suspect handlers are causing issues, measure handler execution time and concurrency to find hotspots.
If you want, share a short example of the handler logic you're planning to run and I can suggest an async pattern or a refactor to keep it non‑blocking.
Sources: Agent session | LiveKit Documentation | VAD Metrics | LiveKit Documentation