red-dentist-96118
11/07/2025, 11:12 PMtall-airline-16756
11/07/2025, 11:12 PMtall-airline-16756
11/07/2025, 11:13 PM@function_tool()
async def turn_on_light(self):
self.light_on = True
# No return value = no verbal response
1. Cancel Automatic Reply in the Event Handler: You can use ev.cancel_tool_reply() inside the function_tools_executed event handler to stop verbal responses after a tool runs. 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()
Both of these approaches help keep the agent quiet without any errors popping up. If you’d like me to walk you through this more or if you have any questions, just let me know—I’m here to help!
Sources: examples/voice_agents/README.md | Turn detection and interruptions | LiveKit Docs | Gemini Live API plugin | LiveKit docsred-dentist-96118
11/07/2025, 11:14 PMtall-airline-16756
11/07/2025, 11:15 PMtool_choice Parameter: Try setting tool_choice to 'required' to encourage the LLM to use a tool whenever it’s available, or even specify a particular function you want it to call.
2. Control Parallel Tool Calls: If the order of tool calls matters, you can use the parallel_tool_calls parameter to make sure they happen one after another, rather than all at once.
3. Enable Strict Tool Schema Validation: Setting strict_tool_schema=True is a great way to catch any invalid or malformed tool calls early on, saving you from headaches later.
4. Test Tool Call Behavior: LiveKit’s testing framework is super handy for systematically checking how your tools are used, what outputs they produce, and how the agent responds.
5. Handle Tool Call Streaming Properly: It’s important to fully accumulate streamed arguments before processing them to avoid any partial or malformed calls that could cause issues.
6. Customize LLM Output: You can also tweak the LLM’s output to clean up any unwanted tokens or make the responses clearer before moving forward.
Following these steps can really help make your tool invocations more reliable and predictable. If you’d like, I’d be happy to walk you through any of these strategies in more detail—just let me know!
Sources: livekit-agents/livekit/agents/voice/run_result.py | Testing and evaluation | LiveKit Docs | Modifying LLM output before TTS | LiveKit Docs | Groq LLM plugin guide | LiveKit Docs | Together AI LLM plugin guide | LiveKit docs