future-umbrella-45124
08/25/2025, 9:57 AMtall-airline-16756
08/25/2025, 9:57 AMtall-airline-16756
08/25/2025, 9:57 AMon_conversation_item_added event fires for the user before the agent—is totally expected. Here’s why: the system quickly processes and adds the user’s transcript to the conversation history as soon as the STT system finalizes it. Then, the agent’s response gets generated and added right after, based on the user’s input.
When using manual VAD, the system doesn’t automatically rely on end-of-utterance signals to decide when to respond, but it still processes audio and commits the user’s transcripts immediately once finalized. This helps keep the conversation flowing smoothly.
If you’d prefer the agent’s transcript to show up first in these cases, you might want to add some custom logic to reorder or delay how these events are handled in your app. Just let me know if you’d like a hand with that—I’m happy to help!
Sources: Turn detection and interruptions | LiveKit Docs | Events and error handling | LiveKit Docs | tests/test_agent_session.pyfuture-umbrella-45124
08/25/2025, 10:06 AMon_conversation_item_added for the agent as soon as we have received a response from the llm instead of waiting for the tts?tall-airline-16756
08/25/2025, 10:08 AMon_conversation_item_added event for the agent currently fires after the TTS (Text-to-Speech) processing finishes. This happens because the system commits conversation items to the chat history when they're being presented to users via TTS. Unfortunately, there isn’t a built-in way to change this so the event triggers right after receiving the LLM response.
But don’t worry! Here are a few alternative ideas you might find helpful:
• Use the speech_created event: This one happens earlier in the process when new agent speech is generated. It comes with a speech_handle property you can use to keep track.
• Listen to LLM completion events: If your setup supports it, you could listen for events that signal the LLM response is done and use those to trigger what you need.
• Custom implementation: You might consider extending the agent session or building custom event handling to emit your own events right when the LLM response arrives.
It would be great to know more about what you’re aiming to do! Are you trying to update a UI, log responses, or maybe trigger other actions? The more details you share, the better I can help suggest the perfect approach for you.
Sources: examples/other/text_only.py | Events and error handling | LiveKit Docs