loud-apple-6481
10/15/2025, 7:05 AMtall-airline-16756
10/15/2025, 7:05 AMtall-airline-16756
10/15/2025, 7:07 AMon_user_turn_completed lifecycle hook. This handy hook triggers right after the user's turn ends and just before the agent starts crafting its full response. It’s a great spot to insert some friendly, pre-scripted verbal acknowledgments that can really help improve conversational flow and make the experience feel more natural.
Here’s a simple way to get started:
1. Create a list of predefined filler phrases like "Let me think about that" or "One moment please."
2. Use the session.say() method to immediately send these filler responses. To keep things tidy, set add_to_chat_ctx=False so these fillers don’t get added to the conversation history.
3. Mix it up by randomizing which filler phrase gets picked each time for a more dynamic feel.
Here’s a quick example to illustrate:
import random
class NonLLMFillerAgent(Agent):
def __init__(self):
super().__init__(instructions="You are a helpful assistant")
self._filler_phrases = [
"Let me think about that",
"One moment please",
"That's a good question",
"Hmm, let me see",
"Just a second",
"Got it",
"Okay"
]
async def on_user_turn_completed(self, turn_ctx: ChatContext, new_message: ChatMessage):
filler = random.choice(self._filler_phrases)
self.session.say(filler, add_to_chat_ctx=False)
If you want to add filler responses before tool calls, you can tap into tool execution callbacks like _tool_execution_started_cb and _tool_execution_completed_cb. While there isn’t a built-in feature that automatically generates filler responses before each tool call, you can certainly add your own custom logic inside your tool functions to emit filler responses using session.say().
Please don’t hesitate to reach out if you’d like me to walk you through any part of this or help with anything else. I’m here to support you!
Sources: Pipeline nodes and hooks | LiveKit Docs | livekit-agents/livekit/agents/beta/workflows/email_address.pyloud-apple-6481
10/15/2025, 7:09 AMtall-airline-16756
10/15/2025, 7:10 AMon_user_turn_completed gets called after every user response, which might not be exactly what you want if you're aiming to add filler responses only when a function call is triggered. To help you achieve this smoothly, you can set up filler responses to activate specifically just before function calls. Here's a friendly approach you can try:
Triggering Filler Responses Before Function Calls
1. Make use of the _tool_execution_started_cb callback or incorporate some custom logic within your tool functions to send out filler responses right before execution starts.
2. Use session.say() with a ready-made filler phrase like "Let me check that for you," and set add_to_chat_ctx=False so it doesn’t get added to the conversation context.
Here’s a simple example to illustrate this:
class FunctionCallFillerAgent(Agent):
def __init__(self):
super().__init__(instructions="You are a helpful assistant")
self._filler_phrases = [
"Let me check that for you",
"One moment, please",
"I'll look into that right away"
]
async def _tool_execution_started_cb(self, tool_name, tool_input):
# Emit a filler response before the tool execution starts
filler = random.choice(self._filler_phrases)
await self.session.say(filler, add_to_chat_ctx=False)
This way, your filler responses will only pop up when a tool is about to run, which fits perfectly with what you’re aiming for.
If anything is unclear or you’d like a hand setting this up, please don’t hesitate to ask—I’m here to help!
Sources: Pipeline nodes and hooks | LiveKit Docs | Agent speech and audio | LiveKit Docs | examples/warm-transfer/warm_transfer.py | delay-handling/README.mdocloud-apple-6481
10/15/2025, 7:11 AMtall-airline-16756
10/15/2025, 7:12 AMsession.say, the tool execution doesn’t wait for the TTS to finish speaking the filler. Instead, the tool call starts right after the TTS playout begins and once the text generation is fully completed. This helps keep the message and execution in the right order.
Here’s a simple breakdown of how it works:
• TTS Playout Initiation: When you call session.say, it kicks off speech generation asynchronously.
• Tool Execution Timing: The tool starts running after the very first audio frame of the TTS playout is processed. This means the audio playback has begun, but it doesn’t wait for the entire TTS to finish.
• No Blocking on Full Playout: The tool call moves forward independently from the full TTS playback, so your agent stays responsive.
This setup ensures that filler responses play smoothly while keeping everything responsive and in the right order. If you’d like me to explain anything further or have any questions, just let me know—I’m here to help!
Sources: livekit-agents/livekit/agents/voice/agent_session.pycool-lizard-26153
11/05/2025, 7:37 AMtall-airline-16756
11/05/2025, 7:37 AM