future-dream-79030
11/15/2025, 4:05 AMtall-airline-16756
11/15/2025, 4:05 AMtall-airline-16756
11/15/2025, 4:06 AMllm_node within the pipeline node system. The llm_node manages tool invocations and their responses, giving you the flexibility to customize how these are handled.
For instance, you might want to tweak the chat context or adjust the tool responses before they get sent to the LLM. Here's a friendly example to guide you:
async def llm_node(self, chat_ctx, tools, model_settings):
"""Override the llm_node to say a message when a tool call is detected."""
activity = self._activity
tool_call_detected = False
# Get the original response from the parent class
async for chunk in super().llm_node(chat_ctx, tools, model_settings):
# Check if this chunk contains a tool call
if isinstance(chunk, ChatChunk) and chunk.delta and chunk.delta.tool_calls and not tool_call_detected:
# Say the checking message only once when we detect the first tool call
tool_call_detected = True
activity.agent.say("Sure, I'll check that for you.")
yield chunk
This method really puts you in the driver’s seat to manage how tools are executed and how their responses flow through. If you’d like, I’m here to help you step through the implementation or answer any questions you might have!
Sources: agent.py | agents/src/inference/llm.ts | Tool definition and use | LiveKit docs | livekit-agents/livekit/agents/voice/agent_activity.py | Pipeline nodes and hooks | LiveKit docs