how to retry when LLM respond with or how do we ca...
# ask-ai
j
how to retry when LLM respond with or how do we capture this and retry it? so it desont seem like the agent just failed "no candidates in the response"
t
Thanks for reaching out, Tyler. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
When an LLM responds with "no candidates in the response," there are several mechanisms to handle and retry this scenario effectively: • Built-in Handling in Google LLM Plugin: The system automatically logs a warning and continues processing the stream without failing immediately. This ensures the process doesn't halt unnecessarily. • Automatic Retry with LLMStream: The
LLMStream
class includes built-in retry logic with exponential backoff for recoverable errors. You can configure the number of retry attempts using the
max_retry
option in the connection settings. • FallbackAdapter for Multiple LLM Providers: Use the
FallbackAdapter
to switch between multiple LLM providers automatically when one fails. This provides: ◦ Automatic failover to backup LLMs ◦ Background recovery for failed providers ◦ Customizable retry attempts and timeouts • Error Event Handling: The
AgentSession
emits
ErrorEvent
when errors occur. If the error is recoverable, the session will retry automatically. If not, intervention may be required after retries are exhausted. • Configuration Options: You can adjust retry behavior using
APIConnectOptions
, including: ◦ `max_retry`: Number of retry attempts ◦ `timeout`: Request timeout duration ◦ `retry_interval`: Interval between retries These mechanisms ensure that the "no candidates in the response" scenario is handled gracefully, minimizing the risk of perceived failure. Sources: livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py | Agents Core Architecture | livekit/livekit_composite | DeepWiki | Events and error handling | LiveKit Docs | Events and error handling | LiveKit Docs