From 208e37cb044e7ace0a78e0444ad0fb5ec2d1d2a8 Mon Sep 17 00:00:00 2001 From: jesus Date: Mon, 7 Sep 2026 09:55:48 +0000 Subject: [PATCH] refactor(http_handler): only follow __cause__ when unwrapping streamed body errors Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/llms/custom_httpx/llm_http_handler.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/litellm/llms/custom_httpx/llm_http_handler.py b/litellm/llms/custom_httpx/llm_http_handler.py index e1142a6e4a1..f84d4d7c85f 100644 --- a/litellm/llms/custom_httpx/llm_http_handler.py +++ b/litellm/llms/custom_httpx/llm_http_handler.py @@ -318,15 +318,9 @@ def _find_base_llm_exception(error: BaseException, depth: int = 0) -> BaseLLMExc return error cause: Final = error.__cause__ - if cause is not None: - provider_exception: Final = _find_base_llm_exception(cause, depth + 1) - if provider_exception is not None: - return provider_exception - - context: Final = error.__context__ - if context is not None: - return _find_base_llm_exception(context, depth + 1) - return None + if cause is None: + return None + return _find_base_llm_exception(cause, depth + 1) class BaseLLMHTTPHandler: