abundant-father-33863
05/22/2026, 8:14 AMtall-airline-16756
05/22/2026, 8:14 AMtall-airline-16756
05/22/2026, 8:15 AMToolError with the message you want the LLM to relay to the user.
• Example (Python):
from livekit.agents.llm import ToolError
@function_tool()
async def my_tool(context, ...):
try:
# call to LLM or external API
except SomeHttp429Error:
raise ToolError("I'm rate-limited right now — please try again in a moment.")
• Effect: the agent receives the ToolError and will respond to the user with that text, letting you present a friendly, controlled message.
2) Use FallbackAdapter + in-tool session messages for retries or backup LLMs
• Configure llm.FallbackAdapter with a primary LLM and one or more fallbacks so if the primary returns 429 the call can automatically route to the next provider.
• While retrying or when calls may take long, use context.session.say("Checking that now…") (from inside the tool) to provide immediate user feedback.
• This combination gives higher availability and better UX during transient errors.
When to use which:
• Use ToolError when you want the agent to explicitly tell the user a specific failure or instruction (e.g., “please try again in 30 seconds”).
• Use FallbackAdapter when you want automatic failover and fewer visible error messages; combine with context.session.say for progress updates.
If you want, tell me:
• Which SDK/language you’re using (Python, JS), and
• Whether you prefer automatic failover or explicit user-facing error messages —
and I’ll give a concrete code snippet tailored to your stack.
Sources: The ReAct Pattern for Voice Agents and How AI Agents Think, Act, and Respon... | Sequential Pipeline Architecture for Voice Agents | LiveKit | Function tool definition | LiveKit Documentation | Build Your First AI Voice Agent in Python: Complete Tutorial | LiveKit | Fallback strategies | LiveKit Documentation, with interactive elementsabundant-father-33863
05/22/2026, 8:16 AMtall-airline-16756
05/22/2026, 8:16 AMcontext.session.say(...)) or send a user-facing response from your session event handler when an error occurs.
Quick next steps so I can give a concrete example:
• Which SDK/language are you using (Python or JavaScript)?
• Do you want automatic failover (fallbacks) or explicit user-facing messages when a 429 occurs?
Tell me those and I’ll return a concise code snippet showing where to listen for session errors and how to wire an llm.FallbackAdapter (and optionally send a user message from the AgentSession).
Sources: Fallback strategies | LiveKit Documentation, with interactive elements