aloof-scooter-47164
09/10/2025, 10:30 PMtall-airline-16756
09/10/2025, 10:30 PMtall-airline-16756
09/10/2025, 10:31 PMRunResult.events
class, which gathers all the events during the agent’s execution.
• Custom Agent Overrides: If you override the llm_node
method in a custom agent, you can handle ChatChunk
instances as they come in the response stream. This way, you can spot tool calls in real-time, even before they actually run.
• Post-Execution Monitoring: After a tool call finishes, you can use the function_tools_executed
event on the AgentSession
object to catch the completed calls and see their results.
By using these approaches, you’ll be able to keep track of tool call decisions smoothly and respond to them effectively. If you have any questions or want to explore these methods further, I’m here to guide you!
Sources: livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | agent.pyaloof-scooter-47164
09/10/2025, 10:33 PMtall-airline-16756
09/10/2025, 10:33 PMRunResult.events
object. This handy feature collects all events, including FunctionCallEvent
, which is triggered whenever a tool call starts.
b. From there, you can filter these events to find FunctionCallEvent
instances and pull out important details about the tool call.
• Custom Agent Overrides:
a. You’ll want to override the llm_node
method in your custom agent implementation.
b. Inside this overridden method, you can work with the ChatChunk
instances coming through the response stream.
c. This way, you can spot any tool_calls
in the response and even trigger your own custom behavior or logging before the tool actually runs.
Using these approaches, you’ll be able to keep a close eye on tool call decisions and respond to them smoothly—whether by watching events or catching decisions as they happen. If you have any questions or want to dive deeper, I’m here to help!aloof-scooter-47164
09/10/2025, 10:34 PMtall-airline-16756
09/10/2025, 10:35 PMfrom livekit.agents import AgentSession
async def detect_function_call():
async with AgentSession() as session:
def on_function_tools_executed(event):
print(f"Function call detected: {event.function_calls}")
session.on("function_tools_executed", on_function_tools_executed)
await session.run(user_input="What is the weather in New York?")
2. Using Custom Agent Overrides:
from livekit.agents import Agent
from livekit.agents.llm import ChatChunk
class CustomAgent(Agent):
async def llm_node(self, chat_ctx, tools, model_settings):
async for chunk in super().llm_node(chat_ctx, tools, model_settings):
if isinstance(chunk, ChatChunk) and chunk.delta and chunk.delta.tool_calls:
print(f"Tool call detected: {chunk.delta.tool_calls[0].name}")
yield chunk
These examples are designed to help you listen for tool calls, either by responding to events or by customizing the agent’s behavior to catch tool call decisions as they happen. If you have any questions or need further clarification, feel free to ask—I’m here to help!
Sources: livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | agent.pyaloof-scooter-47164
09/11/2025, 12:17 AMtall-airline-16756
09/11/2025, 12:18 AMaloof-scooter-47164
09/11/2025, 1:23 AM