red-dentist-96118
11/13/2025, 7:40 PMtall-airline-16756
11/13/2025, 7:40 PMtall-airline-16756
11/13/2025, 7:41 PM@function_tool()
async def turn_on_light(self):
self.light_on = True
# No return value means no verbal response
1. Cancel the tool reply explicitly: You can call ev.cancel_tool_reply() inside the function_tools_executed event handler to keep the agent quiet after running tools. Here’s how you might do it:
@session.on("function_tools_executed")
def on_function_tools_executed(ev):
if "turn_off_light" in (fnc.name for fnc in ev.function_calls):
ev.cancel_tool_reply()
1. Manual turn control: Another option is to set turn_detection="manual" when creating your AgentSession, so you can decide exactly when the agent should speak or stay silent. For example:
session = AgentSession(turn_detection="manual")
@ctx.room.local_participant.register_rpc_method("start_turn")
async def start_turn(data):
session.interrupt()
session.clear_user_turn()
session.input.set_audio_enabled(True)
@ctx.room.local_participant.register_rpc_method("end_turn")
async def end_turn(data):
session.input.set_audio_enabled(False)
session.commit_user_turn()
These approaches give you great control over when your agent talks or stays quiet. If you have any questions or want to explore these options further, I’m here to help!
Sources: examples/voice_agents/README.md | Turn detection and interruptions | LiveKit Docs