aloof-scooter-47164
05/07/2026, 3:16 AMtall-airline-16756
05/07/2026, 3:16 AMtall-airline-16756
05/07/2026, 3:16 AM@function_tool in Python or llm.tool() in Node.js).
• LiveKit also provides xAI provider tools (e.g., XSearch, WebSearch, FileSearch), but those provider tools are currently available only in Python.
• You can mix custom tools with xAI provider tools when building agents.
If you want, tell me which runtime you’re using (Python or Node.js) and an example tool you need — I’ll give a short code example for wiring it into a Grok voice agent.
Sources: Function tool definition | LiveKit Documentation | xAI LLM | LiveKit Documentation | https://docs.livekit.io/agents/models/realtime/plugins/xai.md|, with interactive elementsaloof-scooter-47164
05/07/2026, 3:28 AMtall-airline-16756
05/07/2026, 3:29 AMfrom livekit.agents import Agent, AgentSession, function_tool, RunContext
from livekit.plugins import xai
class SupportAgent(Agent):
def __init__(self):
super().__init__(instructions="You are a technical support specialist.")
class BillingAgent(Agent):
def __init__(self):
super().__init__(instructions="You are a billing specialist.")
class TriageAgent(Agent):
def __init__(self):
super().__init__(instructions="You are a triage agent using Grok voice. Route callers to the right team.")
@function_tool()
async def handoff_to_support(self, context: RunContext):
"""Return an Agent instance to trigger a handoff to Support."""
return SupportAgent(), "Handoff: connecting you to technical support."
@function_tool()
async def handoff_to_billing(self, context: RunContext):
"""Return an Agent instance to trigger a handoff to Billing."""
return BillingAgent(), "Handoff: connecting you to billing."
# Create the session with the Grok realtime voice model
session = AgentSession(
llm=xai.realtime.RealtimeModel(voice="Ara"), # Grok voice model via xai plugin
agent=TriageAgent()
)
# Run the session according to your app's realtime/telephony wiring
# e.g., await session.run(connection)
Notes:
• The handoff tool returns a new Agent instance (and an optional message) — returning an Agent triggers the handoff pattern.
• Use xai.realtime.RealtimeModel() to wire Grok voice into the AgentSession.
If you’d like, tell me whether you want a Node.js example or a sample decision flow that triggers which handoff to call.
Sources: Introducing the Grok Voice Agent API in partnership with xAI | LiveKit | xAI Grok Voice Agent API plugin | LiveKit Documentation | The Handoff Pattern for Voice Agents That Replaces IVR Menus | LiveKit | Agents and handoffs | LiveKit Documentation, with interactive elements