early-restaurant-74591
11/16/2025, 3:32 PMtall-airline-16756
11/16/2025, 3:32 PMtall-airline-16756
11/16/2025, 3:33 PMauto_tool_reply_generation feature is enabled in your LLM configuration to take advantage of this.
2. Skip TTS for Empty or Non-Verbal Responses: You can customize the tts_node to prevent empty or whitespace-only text from being sent to the TTS engine. Here’s a helpful example you might find useful:
def tts_node(self, text: str, **kwargs: Any) -> AsyncIterable[tts.SynthesizedAudio]:
if not text.strip():
raise StopResponse() # Prevents empty text from being sent to TTS
return Agent.default.tts_node(self, text, **kwargs)
3. Stop TTS Generation via Hooks: Another great way is to use the on_user_turn_completed hook to check incoming messages and stop speech generation when appropriate. For example:
async def on_user_turn_completed(self, turn_ctx: ChatContext, new_message: ChatMessage) -> None:
if not new_message.text_content:
raise StopResponse() # Prevents agent from generating any response
These approaches will help ensure that function calls happen right away, empty text is gracefully ignored, and only meaningful content gets sent to TTS. If you’d like, I’m here to help you implement these or answer any questions you have along the way!
Sources: Pipeline nodes and hooks | LiveKit docs | agents/src/voice/agent_activity.ts | livekit-agents/livekit/agents/voice/agent_activity.py | Tool definition and use | LiveKit docsearly-restaurant-74591
11/16/2025, 3:36 PMtall-airline-16756
11/16/2025, 3:37 PMauto_tool_reply_generation isn’t actually part of LiveKit Agents. But no worries—tool reply generation is managed through a few other helpful ways:
1. Tool Return Values: When a tool returns a value, the agent will automatically create a verbal reply. If nothing is returned, then no reply is generated.
2. Tool Choice Parameter: You can customize how the LLM uses tools with the tool_choice parameter. For instance:
from livekit.plugins import openai
llm = openai.LLM(
model="gpt-4o-mini",
tool_choice="auto" # This lets the model decide when to use tools
)
3. Manual Control: If you want to take charge, you can use the function_tools_executed event to manually override reply generation. Here’s an example:
@session.on("function_tools_executed")
def on_function_tools_executed(ev):
ev.cancel_tool_reply() # This stops automatic reply generation
These options give you great flexibility in deciding when and how replies are created after tools run. If anything’s unclear or you’d like a hand setting this up, just let me know—I’m here to help!
Sources: examples/voice_agents/silent_function_call.py | OpenAI LLM plugin guide | LiveKit Docs