refactor(langchain): unify the transient is-retryable-error notion#1270
Merged
Conversation
Three divergent retryable-error checks existed: errorHandler.isNetworkError (connection failures), summarize's local isRetryableError (429/5xx + rate-limit/ timeout), and retry.defaultShouldRetry (broad deny-list). They overlapped inconsistently. Add one shared `isRetryableError` in errorHandler (network failure ∪ transient HTTP status ∪ rate-limit/timeout code/message), built on isNetworkError, and have the summarize backoff use it (dropping its private copy — now also retries connection blips, a small improvement). Leave retry.defaultShouldRetry as the intentionally-broader schema-retry predicate, documented as a superset (transient ⊂ defaultShouldRetry) so the distinction is explicit rather than accidental. (#1242)
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.
Fixes #1242.
Three divergent retryable-error checks existed:
errorHandler.isNetworkError— connection-failure string patternssummarize's localisRetryableError— 429/502/503/504 + rate-limit/timeout code/messageutils/retry.defaultShouldRetry— broad deny-list (retry unless validation/config/auth)Change
isRetryableErrorinerrorHandler= network failure (isNetworkError) ∪ transient HTTP status (429/502/503/504) ∪ rate-limit/timeout code/message. It's the single canonical transient predicate.summarizenow imports it (drops its private copy). Behavior is the same set plus connection blips (ECONNREFUSED/fetch failed), which are exactly what backoff should retry — a small improvement, not a regression.retry.defaultShouldRetryis kept (it must stay broader so schema-output retries re-roll on unparseable model output) and now documents the relationship: transient ⊂ defaultShouldRetry. Callers wanting transient-only retries can passshouldRetry: isRetryableError.Validation
eslint(0 errors),tsc --noEmitclean,jesterrorHandler + summarize suites (30 tests, incl. newisRetryableErrorcases), fullyarn buildgreen.