is there any agent example of calling a tool, but ...
# ask-ai
f
is there any agent example of calling a tool, but not using the tool result to call llm again?
t
Thanks for reaching out, Deo. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! If you'd like to call a tool without getting a response from the LLM again, here are a couple of friendly ways to do that: 1. Return
None
from the tool function:
When your tool doesn’t return anything, it simply finishes quietly without prompting a reply from the LLM. For example:
Copy code
@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:
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()  # 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