lively-coat-10905
10/21/2025, 8:36 AM### Question 2: Alternative Approaches
If function calling isn't available in 1.2.15, what are the recommended alternatives for:
- Triggering custom Python functions based on user intent/conversation context
- Implementing ticket raising or email sending functionality
- Having the agent execute backend actions during conversation
Should I:
1. Parse the LLM responses and trigger functions manually?
2. Use a different callback mechanism?
3. Upgrade to a newer version? (If so, which version supports function calling?)
### Question 3: Event Handling
In livekit-agents 1.2.15, what events can I listen to on the Agent or AgentSession?
I need to detect when:
- User sends a message
- Agent generates a response
- Conversation reaches certain states
What's the proper event handling pattern for this version?
### Question 4: Version Clarification
What version of livekit-agents introduced function calling / tool use capabilities?
Is there documentation or migration guide for implementing custom function execution?tall-airline-16756
10/21/2025, 8:36 AMtall-airline-16756
10/21/2025, 8:41 AM@llm.ai_callable() decorator is still supported in this version to keep things smooth for you. That said, we recommend using the newer @function_tool decorator—it makes defining functions easier, supports automatic type inference, and fits better with the framework.
Here’s a quick example using `@function_tool`:
from livekit.agents.llm import function_tool
@function_tool(description="Send an email for ticket raising")
async def send_email(subject: str, body: str) -> str:
# Your implementation here
return "Email sent successfully"
If you’d like, I’m here to help you convert your existing functions to this new format—just let me know!
2. Alternatives for Triggering Custom Functions
If function calling doesn’t quite fit your needs, no worries! Here are some other options you might find useful:
• Manual Parsing: You can parse LLM responses yourself and trigger functions based on what you get.
• Event-Based Control: Use events like function_tools_executed to manage function behavior dynamically.
• Upgrade: Upgrading to a newer version can unlock enhanced function calling features—version 1.0 brought some great improvements!
Feel free to ask if you want guidance on any of these approaches—I’m here to support you.
3. Event Handling in Version 1.2.15
You can listen for these helpful events on the `AgentSession`:
• `user_input_transcribed`: To catch user messages as they come in.
• `conversation_item_added`: To keep track of messages from both users and agents.
• `agent_state_changed`: To monitor changes in agent state, like when it’s listening or thinking.
• `function_tools_executed`: To know when functions have been run.
Here’s a quick example:
@session.on("conversation_item_added")
def on_message(event):
print(f"New message: {event.item.text_content}")
4. Version Clarification
Just to clarify, function calling has been around since before version 0.4.0 and got a big boost in version 1.0. We also have migration guides ready to help you smoothly transition to the newer @function_tool style.
If you’d like assistance with upgrading or implementing any specific features, please don’t hesitate to reach out—I’m here to help every step of the way!
Sources: livekit-agents/livekit/agents/inference/llm.py | ivr-nagivator/README.mdoc | Agents v0.x migration guide - Python | LiveKit Docs | External data and RAG | LiveKit Docs | complex-agents/testing/agent_test.py