Skip to content

fix: treat gateway-instant-408 responses as retryable timeouts - #35

Open
Michael J. Jabbour (michaeljabbour) wants to merge 1 commit into
microsoft:mainfrom
michaeljabbour:fix/retry-instant-408-timeouts
Open

fix: treat gateway-instant-408 responses as retryable timeouts#35
Michael J. Jabbour (michaeljabbour) wants to merge 1 commit into
microsoft:mainfrom
michaeljabbour:fix/retry-instant-408-timeouts

Conversation

@michaeljabbour

Copy link
Copy Markdown
Contributor

Summary

  • A gateway-fabricated HTTP 408 (LiteLLM emits 408 with time taken=0.0 seconds when its transport fails instantly) reaches this provider as a generic OpenAI APIStatusError; because the provider sets max_retries=0 and retries via its own wrapper, these user-invisible infrastructure hiccups surfaced to callers after ~0.2s instead of being retried.
  • The fix distinguishes on the body marker: instant 408 (time taken=0.0) → retryable LLMTimeoutError handled by the existing retry_with_backoff path; a genuine client-inactivity 408 (real elapsed time) → non-retryable LLMError, unchanged behavior.

Tests

  • Two new translated-error tests (instant 408 retryable, genuine 408 not); 19/19 in test_error_translation.py, 278/279 full suite — the one failure (test_behavioral.py::test_list_models_returns_list) pre-exists on main.

The vLLM provider pins max_retries=0 and retries via its own backoff
wrapper, but the OpenAI SDK maps a *received* HTTP 408 to a generic
APIStatusError, so a gateway-fabricated 408 bypassed retry entirely and
surfaced to the caller after ~0.2s.

The LiteLLM gateway emits 408s with 'time taken=0.0 seconds' in the
body when its own transport fails instantly; a genuine client
inactivity 408 carries real elapsed time. Distinguish on that marker:
instant 408 -> retryable LLMTimeoutError (handled by the existing
retry_with_backoff path); genuine 408 -> non-retryable LLMError.
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.

1 participant