how do I get the agent to intentionally be silent ...
# ask-ai
r
how do I get the agent to intentionally be silent for a turn? I used to send <break time="1000ms"/> but now this throws the error: livekit.agents._exceptions.APIError: no audio frames were pushed for text: <break time=\"1000ms\"/> (body=None, retryable=True)
t
Thanks for reaching out, Trevor. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
If you'd like the agent to stay silent for a turn without causing an APIError, here are a couple of friendly ways to do that: 1. Use a Function Tool Without a Return Value: When a function tool doesn’t return anything, the agent won’t generate a Text-to-Speech (TTS) response. Here’s a simple example:
Copy code
@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:
Copy code
@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 docs
r
the LLMs are not good at calling tools sometimes, it's not consistent enough
t
To help improve the consistency of your LLM when calling tools, here are some friendly strategies you might find useful: 1. Use the
tool_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