WithFallbackModel adds a fallback model to try if the primary model fails. For retryable errors (5xx, timeouts), the same model is retried with backoff. For non-retryable errors (429), we immediately move to the next model in the chain.
(model provider.Provider)
| 63 | // For retryable errors (5xx, timeouts), the same model is retried with backoff. |
| 64 | // For non-retryable errors (429), we immediately move to the next model in the chain. |
| 65 | func WithFallbackModel(model provider.Provider) Opt { |
| 66 | return func(a *Agent) { |
| 67 | a.fallbackModels = append(a.fallbackModels, model) |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | // WithFallbackRetries sets the number of retries per fallback model with exponential backoff. |
| 72 | func WithFallbackRetries(retries int) Opt { |
no outgoing calls