How can I understand if `function_tool` is called ...
# ask-ai
g
How can I understand if
function_tool
is called in
conversation_item_added
Event?
t
Thanks for reaching out, Vaibhav. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To determine if
function_tool
is called when a
conversation_item_added
event occurs, examine the event's
item
type: • If
event.item.type == "function_call"
, a function tool has been invoked. You can then check which tool (
event.item.name
) and its arguments. • If
event.item.type == "function_call_output"
, this represents the result of a function tool call. Each function tool call in a conversation triggers a
conversation_item_added
event with
type == "function_call"
(and subsequently
function_call_output
). Inspect the event payloads to detect and track tool invocation contextualized to the conversation. If you want a consolidated event representing function tool executions, listen for the
function_tools_executed
event, which summarizes all the function calls executed in a turn. For detailed examples of handlers, review the Python code snippets and event flow described above. Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/llm.py | Events and error handling | LiveKit Docs