feat(#4560): default transient-network retry in shared HTTP transport#230
Merged
Conversation
… (sendBounded) Network blips deserve a retry policy by default, not opt-in. The shared non-streaming transport (used by Claude, OpenAI + DeepSeek/Kimi/OpenRouter/Perplexity, Gemini, Ollama) now retries transient failures: - connection-level IOException (reset, refused, no-route, unexpected EOF), and - transient HTTP statuses (408/429/500/502/503/504). 3 attempts, exponential backoff (250ms->500ms). Matches OpenAI-SDK default behavior. Two deliberate exclusions: - HttpTimeoutException is NOT retried — the per-request timeout is the caller's TOTAL budget; retrying would silently multiply it (kept OllamaClientTimeoutTest's ~250ms elapsed bound intact). - the ORIGINAL exception type is preserved on exhaustion (rethrown, not wrapped) so onLLMError can still match `e is ConnectException`, etc. Sits below onLLMError/LlmErrorDecision (transport rides out blips; handler sees what survives). Streaming not retried (mid-stream re-issue would duplicate tokens). 6 tests (scripted fake HttpClient). docs/error-recovery.md + CHANGELOG updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Transient network failures now retry by default across all HTTP providers — addressing the live-LLM review (the OpenRouter blip) and the principle that a dropped connection / 503 is the textbook retryable case. The shared non-streaming transport
HttpModelClientSupport.sendBounded(used by Claude, OpenAI + DeepSeek/Kimi/OpenRouter/Perplexity, Gemini, Ollama) retries:IOException(reset, refused, no-route, unexpected EOF), and3 attempts, exponential backoff (250ms→500ms) — matches the OpenAI SDK default. Previously only Ollama retried.
Two deliberate exclusions
HttpTimeoutExceptionis not retried — the per-requesttimeoutis the caller's total budget; retrying would silently 3× it (keepsOllamaClientTimeoutTest's ~250ms elapsed bound intact).onLLMErrorcan still matche is ConnectException.Sits below
onLLMError/LlmErrorDecision; streaming is not retried (mid-stream re-issue would duplicate tokens).Gates
6 tests (scripted fake
HttpClient: conn-exception retry, transient-status retry, exhaustion rethrows original, no-retry-on-timeout, no-retry-on-4xx, final-body-preserved). Full./gradlew buildgreen.docs/error-recovery.md+ CHANGELOG updated. Closes #4560.🤖 Generated with Claude Code