few-analyst-46
09/19/2025, 6:42 AMtall-airline-16756
09/19/2025, 6:42 AMtall-airline-16756
09/19/2025, 6:42 AMNone from the tool function: When your tool doesn’t return anything, it simply finishes quietly without prompting a reply from the LLM. For example:
@function_tool()
async def turn_on_light(self):
"""Called when user asks to turn on the light."""
self.light_on = True
<http://logger.info|logger.info>("Light is now on")
# No return value means no automatic LLM reply
1. Use ev.cancel_tool_reply() in the function_tools_executed event handler: This is a great way to explicitly stop the LLM from replying, even if your tool does return something. Here’s how you can do it:
@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() # Explicitly cancel the LLM reply
Using these methods, your tool will run smoothly without triggering any extra response from the LLM. If you have any questions or need more help, feel free to ask—I’m here to support you!
Sources: Tool definition and use | LiveKit Docs | Tool definition and use | LiveKit Docs | tests/test_agent_session.py