If the error provides a provider retry-delay hint (e.g. RateLimitError.retryDelay, ServiceError.retryDelay) and it is present and positive, that value is used so we do not retry before the server is ready.
Otherwise we fall back to local exponential backoff (baseDelay * 2^attempt) to avoid tight retry loops.
The chosen delay is always capped at 30 seconds so waits remain bounded.
Calls client.streamComplete with retries only when failure occurs before any chunk is emitted. Once streaming has started (at least one chunk delivered), any error is returned immediately without retry.
Calls client.streamComplete with retries only when failure occurs before any chunk is emitted. Once streaming has started (at least one chunk delivered), any error is returned immediately without retry.
Value parameters
baseDelay
base delay for backoff when provider retry-delay hints are absent (default: 1 second); must be positive
client
LLM client
conversation
conversation to complete
maxAttempts
maximum attempts including the first (default: 3); must be positive
onChunk
callback for each streamed chunk
options
completion options (default: CompletionOptions())
Attributes
Returns
Right(Completion) on success, Left(error) when retries exhausted, non-recoverable error, invalid input, or interrupted