Skip to content

refactor(langchain): unify the transient is-retryable-error notion#1270

Merged
gfargo merged 1 commit into
mainfrom
refactor/unify-retryable-error
Jun 15, 2026
Merged

refactor(langchain): unify the transient is-retryable-error notion#1270
gfargo merged 1 commit into
mainfrom
refactor/unify-retryable-error

Conversation

@gfargo

@gfargo gfargo commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Fixes #1242.

Three divergent retryable-error checks existed:

  • errorHandler.isNetworkError — connection-failure string patterns
  • summarize's local isRetryableError — 429/502/503/504 + rate-limit/timeout code/message
  • utils/retry.defaultShouldRetry — broad deny-list (retry unless validation/config/auth)

Change

  • Add one shared isRetryableError in errorHandler = network failure (isNetworkError) ∪ transient HTTP status (429/502/503/504) ∪ rate-limit/timeout code/message. It's the single canonical transient predicate.
  • summarize now 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.defaultShouldRetry is 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 pass shouldRetry: isRetryableError.

Validation

eslint (0 errors), tsc --noEmit clean, jest errorHandler + summarize suites (30 tests, incl. new isRetryableError cases), full yarn build green.

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)
@gfargo gfargo merged commit e0cead7 into main Jun 15, 2026
16 checks passed
@gfargo gfargo deleted the refactor/unify-retryable-error branch June 15, 2026 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unify the three "is-retryable-error" notions

1 participant