Description
RetryingHttpClient.executeAsync() calls the delegate before it has a CompletableFuture to attach its retry policy to:
val responseFuture = httpClient.executeAsync(requestWithRetryCount, requestOptions)
A custom HttpClient implementation is allowed by the SDK surface and can throw synchronously from executeAsync() instead of returning an exceptionally completed future.
When that happens, the exception escapes RetryingHttpClient.executeAsync() immediately. The existing handleAsync branch never sees it, so even retryable synchronous failures such as IOException, OpenAIIoException, or OpenAIRetryableException bypass the configured retry policy.
Expected behavior
Synchronous failures from the async delegate should enter the same retry decision path as exceptionally completed futures. Retryable failures should retry up to maxRetries; non-retryable failures should surface through the returned future.
Suggested fix
Wrap the delegate call and convert a synchronous throwable into an exceptionally completed CompletableFuture<HttpResponse> before applying the existing retry handler.
Add regression coverage for:
- a synchronous
OpenAIRetryableException followed by a successful async response;
- a synchronous non-retryable exception completing the returned future exceptionally without a retry;
- retry-count headers remaining correct across the synchronous-failure retry.
Description
RetryingHttpClient.executeAsync()calls the delegate before it has aCompletableFutureto attach its retry policy to:A custom
HttpClientimplementation is allowed by the SDK surface and can throw synchronously fromexecuteAsync()instead of returning an exceptionally completed future.When that happens, the exception escapes
RetryingHttpClient.executeAsync()immediately. The existinghandleAsyncbranch never sees it, so even retryable synchronous failures such asIOException,OpenAIIoException, orOpenAIRetryableExceptionbypass the configured retry policy.Expected behavior
Synchronous failures from the async delegate should enter the same retry decision path as exceptionally completed futures. Retryable failures should retry up to
maxRetries; non-retryable failures should surface through the returned future.Suggested fix
Wrap the delegate call and convert a synchronous throwable into an exceptionally completed
CompletableFuture<HttpResponse>before applying the existing retry handler.Add regression coverage for:
OpenAIRetryableExceptionfollowed by a successful async response;