when an errorEvent has occured will it call "close...
# ask-ai
l
when an errorEvent has occured will it call "close" event?
t
Thanks for reaching out, Dileep. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
ErrorEvent and CloseEvent are separate event types in LiveKit. While a CloseEvent can include an error property, there is no direct indication that an ErrorEvent will automatically trigger a 'close' event. If you need further clarification or have a specific scenario in mind, feel free to share more details. Sources: GitHub::livekit::agents | livekit-agents/livekit/agents/voice/agent_session...
l
so when an unrecoverable error has occured how can i handle it?
t
To handle an unrecoverable error in LiveKit, I've got some friendly tips that'll help you keep things smooth and user-friendly! 😊Use FallbackAdapter: Think of this like having a backup plan for your components. If something goes wrong with STT, LLM, or TTS, the
FallbackAdapter
is like your trusty sidekick that automatically switches to a backup provider. It's basically making sure your conversation keeps flowing, while also keeping track of any services that might be acting up. • Implement an error event handler: This is where you can create a really human-friendly way to handle unexpected hiccups. Check out this example:
Copy code
@session.on("error")
def on_error(ev: ErrorEvent):
    if ev.error.recoverable:
        return

    # Handle unrecoverable error
    session.say(
        "I'm having trouble connecting right now. Let me transfer your call.",
        audio=audio_frames_from_file(custom_error_audio),
        allow_interruptions=False,
    )
It's like having a warm, understanding friend who lets you know something's not quite right and is ready to help. • Optionally mark errors as recoverable: For some components like TTS and LLM, you can actually tell the system "Hey, this isn't a big deal" by setting
ev.error.recoverable = True
. It's like giving your system a little flexibility. Just a heads up - by default, the system will close the session after too many unrecoverable errors. But don't worry, I'm here if you need any more guidance or want to walk through some examples together! 🤝 Sources: Events and error handling | LiveKit Docs | GitHub::livekit::agents | examples/voice_agents/error_callback.py