in 0.x version, it seems like there is event on fu...
# ask-ai
p
in 0.x version, it seems like there is event on function_calls_finished, does it exist in 1.x version?
t
Thanks for reaching out, Harshad. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! I wanted to let you know that the
function_calls_finished
event from LiveKit 0.x isn’t available in version 1.x anymore. Instead, it’s been replaced by the
function_tools_executed
event, which works in a similar way. This new event is triggered after all function tools have been executed for a user input. If you’re moving from 0.x to 1.x, I’d recommend updating your listeners to use
function_tools_executed
and tweaking your code to fit its updated structure and properties. Please feel free to reach out if you’d like more details or any help with this migration—I’m here to support you! Sources: Events and error handling | LiveKit Docs | agents/src/voice/agent_activity.ts | VoicePipelineAgent | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_activity.py | Agents 0.x migration guide | LiveKit Docs
p
give me some examples and use case of function_tools_executed
t
I'd love to share some helpful examples and use cases of the
function_tools_executed
event in LiveKit 1.x to make things clearer for you: • Preventing Automatic Tool Replies: Imagine a smart light control scenario where you want to turn off the light without the agent giving a verbal reply. Here's how you can do that:
Copy code
@session.on("function_tools_executed")
def on_function_tools_executed(ev: FunctionToolsExecutedEvent):
    tools = (fnc.name for fnc in ev.function_calls)
    if "turn_off_light" in tools:
        ev.cancel_tool_reply()
• Performing Silent Function Calls: Sometimes, a tool like
turn_on_light
doesn’t return a value, so it won’t generate a reply unless you handle it explicitly. Here's an example:
Copy code
@function_tool()
async def turn_on_light(self):
    """Called when user asks to turn on the light."""
    self.light_on = True
    logger.info("Light is now on")
• Handling Multiple Tools in Parallel: If you have several tools running at once, you can choose to suppress replies no matter what their outputs are. • Accessing Function Call Outputs: The
zipped()
method is super handy to pair function calls with their outputs for easier processing. • Agent Handoff Control: You can smoothly manage task transitions or even cancel agent handoffs by adding your logic right inside the event handler. Please feel free to reach out if you'd like me to walk you through any part of this or if you want more examples. I’m here to help! Sources: Events and error handling | LiveKit Docs | livekit-agents/livekit/agents/voice/events.py
p
how does cancel_tool_reply works, I thought if the function tool return None, agent won't generate reply
t
I'd love to help you understand the
cancel_tool_reply
method a bit better! This method is designed to gently stop the agent from sending an automatic reply after function tools have done their job. Usually, tools that return
None
won’t trigger any reply, but when you have several tools running at the same time and at least one gives back a value (like a string), this method comes in handy to keep things quiet. Here’s a simple example from a smart home setup:
Copy code
@session.on("function_tools_executed")
def on_function_tools_executed(ev: FunctionToolsExecutedEvent):
    tools = [fnc.name for fnc in ev.function_calls]
    if "turn_off_light" in tools:
        ev.cancel_tool_reply()  # Suppress verbal feedback
With this, even if one tool sends back a value, no reply will pop up. This is especially useful when you want things to run smoothly and silently, like in batch operations or certain workflows. If anything’s unclear or you’d like me to walk you through more examples, just let me know—I’m here to help! Sources: livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/llm.py
p
how does will_synthesize_assistant_reply work in v0.x, how should I do the same in v1.x
t
Thank you for bringing up the term
will_synthesize_assistant_reply
. I wanted to let you know that it’s not documented in LiveKit 0.x or 1.x. Could you please share where you came across this term? For example, was it in some code, documentation, or maybe a custom implementation you’re working with? Also, it would be really helpful to understand if you’re trying to intercept the assistant’s reply before the TTS synthesis happens, or if you’re aiming to change how the assistant responds altogether. This way, I can guide you more accurately on the best approach in LiveKit 1.x. Sources: Voice activity detection (VAD) parameters | LiveKit Docs | Agents 0.x migration guide | LiveKit Docs | Agents v0.x migration guide - Node.js | LiveKit Docs | Agent speech and audio | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_activity.py
p
in v0.x, the VoicePipelineAgent has a property called will_synthesize_assistant_reply
t
Thank you for reaching out! I noticed that the property
will_synthesize_assistant_reply
isn’t documented in the LiveKit 0.x or 1.x knowledge base. Could you please share a bit more about how you were using it in 0.x? For instance, are you trying to control when the assistant starts synthesizing a response, or is it something related to callback handling before TTS or LLM processing in a voice pipeline? Understanding this will really help us find the right equivalent feature in 1.x for you. Sources: Agents 0.x migration guide | LiveKit Docs
p
to control how the LLM should reply after retrieve data from RAG
t
In LiveKit 1.x, you have some great options to guide how the LLM responds after pulling in data from RAG. Let me walk you through a few helpful methods: • Using `on_user_turn_completed`: This handy lifecycle hook lets you add the retrieved RAG data into the chat context right before the LLM crafts its reply. Here’s an example to illustrate:
Copy code
async def on_user_turn_completed(self, turn_ctx, new_message):
    rag_content = await my_rag_lookup(new_message.text_content())
    turn_ctx.add_message(role="assistant", content=f"Relevant info: {rag_content}")
    await self.update_chat_ctx(turn_ctx)
• Using `llm_node`: You can override this method to gently filter or tweak the LLM’s output stream before it reaches the TTS engine. Here’s how you might do that: Sources: Pipeline nodes and hooks | LiveKit Docs | Modifying LLM output before TTS | LiveKit Docs | delay-handling/README.mdoc | External data and RAG | LiveKit Docs
p
on on_user_turn_completed, if I add assistant role message to turn_ctx, is it temporary message to hint llm to use the context for responding? and it won't be added as part of the conversion history?
t
Absolutely! When you add an assistant role message to
turn_ctx
in
on_user_turn_completed
, it creates a temporary message that helps provide context for the LLM's response. This message won’t be added to the permanent conversation history unless you specifically call
update_chat_ctx
. This approach lets you add relevant context for just the current turn without changing the overall chat history. If you'd like, I’m here to offer more details or examples to make things clearer! Sources: External data and RAG | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_activity.py | agents/src/llm/provider_format/google.test.ts | Pipeline nodes and hooks | LiveKit Docs | Pipeline nodes and hooks | LiveKit Docs
p
how to use EOM in the agent to improve the user end turn detection accuracy
t
Hi there! I wanted to share some helpful info about LiveKit’s approach to detecting when a user finishes speaking. While it doesn’t have a specific "End of Message (EOM)" feature, it uses something called "End of Utterance (EOU)" detection to make turn-taking more accurate. This combines silence detection (VAD) with understanding the meaning of speech to predict when someone has wrapped up. If you’d like to add EOU to your agent, here’s a simple way to get started: 1. First, install the EOU plugin by running:
pip install livekit-plugins-turn-detector
. 2. Next, initialize the EOU model, choosing either English or multilingual:
Copy code
from livekit.plugins.turn_detector.english import EnglishModel
turn_detector = EnglishModel()
1. Then, set up your agent session like this:
Copy code
session = AgentSession(
    turn_detection=turn_detector,
    min_endpointing_delay=0.5,  # This helps the agent respond faster when confident
    max_endpointing_delay=6.0   # Allows waiting longer if unsure
)
This approach helps the system adjust silence detection based on the meaning of what’s said, so turn detection feels natural and precise. If you’d like, I’m here to help you get this up and running or to clarify anything further—just let me know! Sources: Improving voice AI's turn detection with transformers | livekit-plugins/livekit-plugins-turn-detector/livekit/plugins/turn_detector... | How does end-of-utterance detection work in conversations? | complex-agents/turn-taking/agent.py
p
cann't I have "livekit-agents[openai,turn-detector,silero,cartesia,deepgram, groq, google]~=1.2",?
t
Absolutely, you can install and use multiple plugins like OpenAI, turn-detector, Silero, Cartesia, Deepgram, Groq, and Google all within a single LiveKit agent installation. To make this happen, just use the following command:
Copy code
pip install "livekit-agents[openai,turn-detector,silero,cartesia,deepgram,groq,google]~=1.2"
This will set you up with support for all those plugins, so you can easily combine features like STT, TTS, LLM, and turn detection from different providers. If you run into any hiccups or have questions along the way, please don’t hesitate to reach out—I’m here to help! Sources: LiveKit Agents integrations | LiveKit Docs | README.md | requirements.txt | examples/src/cartersia_tts.ts
p
how does livekit agent access cloudflare d1 database
t
Hi there! I’d love to help you with accessing Cloudflare D1 databases through LiveKit agents using the HTTP API. To make sure I guide you in the best way, could you let me know if you’re looking for a specific code example for integrating D1, or if you’d prefer some general advice on setting up the connection? Also, do you already have the D1 API endpoint and authentication details ready, or would you like me to walk you through the entire setup process? I’m here to support you every step of the way! Sources: External data and RAG | LiveKit Docs | Tool definition and use | LiveKit Docs | complex-agents/nutrition-assistant/agent.py | Secrets management | LiveKit Docs
p
walk me through the entire setup