late-businessperson-58140
08/19/2025, 12:39 PMtall-airline-16756
08/19/2025, 12:39 PMlate-businessperson-58140
08/19/2025, 12:39 PMlate-businessperson-58140
08/19/2025, 12:40 PMtall-airline-16756
08/19/2025, 12:40 PM@session.on("error")
decorator to catch errors right in your agent code. For instance, you might log the error and gently notify the user with a custom message or some audio.
• Monitor Connection State: Keep an eye on the room.connectionState
property and listen for the Disconnected
event to spot any connection hiccups. When that happens, let the user know and offer some retry options.
• Frontend Error Display: Use UI components like EmbedAgentClient
to show errors to your users in a clear way. These components can display error messages and let users dismiss them or try again.
• Implement Fallback Strategies: Consider using a FallbackAdapter
to handle provider issues by automatically switching to backup providers and retrying requests, so the experience stays smooth.
• Recovery Patterns: It helps to tell apart recoverable errors from the ones that aren’t. For example, errors from TTS or LLM can be recoverable, while for STT errors, you might want to reset the agent if needed.
Following these steps will help keep things running smoothly even if the connection acts up. If you want me to walk you through any part or share some examples, just let me know—I’m here to help!
Sources: livekit-agents/livekit/agents/_exceptions.py | Web Embed Example | livekit/livekit_composite | DeepWiki | Web and mobile frontends | LiveKit Docs | Events and error handling | LiveKit Docslate-businessperson-58140
08/19/2025, 12:40 PMtall-airline-16756
08/19/2025, 12:41 PM