steep-balloon-41261
09/12/2025, 5:12 PMtall-airline-16756
09/12/2025, 5:12 PMtall-airline-16756
09/12/2025, 5:13 PMon_user_turn_completed
lifecycle hook in LiveKit. This handy feature lets you quickly acknowledge the user (for example, saying "Let me think about that...") before delivering the full response.
Here's a simple example to help you get started:
import asyncio
from livekit.agents import Agent, AgentSession, ChatContext, ChatMessage
class PreResponseAgent(Agent):
async def on_user_turn_completed(self, turn_ctx: ChatContext, new_message: ChatMessage):
# Generate filler response
filler_response = "Let me think about that..."
self.session.say(filler_response, add_to_chat_ctx=False)
# Continue with the main response
main_response = await self.llm.generate_response(turn_ctx)
self.session.say(main_response)
This way, your filler words come through right away, making the conversation feel more engaging, while the main response is being prepared behind the scenes. If you'd like, I'm here to help you dive deeper or clarify anything else—just let me know!
Sources: Agent speech and audio | LiveKit Docs | Agent speech and audio | LiveKit Docs | Docs::Agents | livekit-plugins/livekit-plugins-assemblyai/livekit/plugins/assemblyai/stt.p... | Deepgram integration guide | LiveKit Docs