lively-whale-54567
09/11/2025, 4:09 PMtall-airline-16756
09/11/2025, 4:09 PMtall-airline-16756
09/11/2025, 4:11 PMstore_booking_details
function only runs after the agent has confirmed the booking details. Here's a friendly guide to help you with that:
• Define the Tool Clearly: It’s helpful to clearly state in the tool’s description that it should only be used once the agent has confirmed the booking details. For example, you could say, "Use this tool only when the booking details are confirmed by the agent."
• Validate Preconditions: Try adding checks to make sure all important details (like date, time, customer name) are provided before the tool runs. If something’s missing, you can return a gentle error message asking the agent to gather that info.
• Use Conversation State: You can keep track of whether the necessary details have been confirmed by using the conversation state. The tool can check this before moving forward.
• Control Agent Responses: If you want, you can suppress the agent’s response after the tool runs by returning None
or handling events to cancel the reply.
By following these steps, you’ll have a smoother and more predictable process. If you’d like me to walk you through any part of this or provide examples, just let me know—I’m here to help!
Sources: Tool definition and use | LiveKit Docs | Tool definition and use | LiveKit Docs | agent.py | examples/voice_agents/silent_function_call.pylively-whale-54567
09/11/2025, 4:15 PMtall-airline-16756
09/11/2025, 4:16 PMlively-whale-54567
09/11/2025, 4:18 PMtall-airline-16756
09/11/2025, 4:20 PMfunction_tool
, here are a few friendly approaches you can try:
• Cancel Automatic Replies: You can add an event handler for the function_tools_executed
event and call ev.cancel_tool_reply()
to stop the automatic response that usually happens after the tool runs:
@session.on("function_tools_executed")
def on_function_tools_executed(ev):
ev.cancel_tool_reply()
• Return None
from the Tool: Make sure your tool doesn’t return any value, or explicitly returns None
, which helps prevent an automatic reply from being triggered.
• Disable Turn Detection: If you’re working with the OpenAI Realtime API, you can turn off turn_detection
and take charge of when the agent speaks by using generate_reply()
yourself:
model = openai.realtime.RealtimeModel(voice="alloy", turn_detection=None)
agent.generate_reply(on_duplicate="cancel_existing")
I hope these tips make things clearer and easier for you! Please feel free to reach out if you’d like me to walk you through any part of the implementation or if you have any other questions. I’m here to help!
Sources: livekit-agents/livekit/agents/voice/generation.py | Voice activity detection (VAD) parameters | LiveKit Docs