From e2033586a4ce2f29ea26f14d78c93745cea23b8a Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 28 Oct 2026 02:28:17 +0000 Subject: [PATCH] fix(hidden_params): read private attributes only off a real pydantic class A spec'd test double passes isinstance(obj, BaseModel) through __class__ while its type has no __private_attributes__, which raised on every hidden params read Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/litellm_core_utils/hidden_params.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/litellm/litellm_core_utils/hidden_params.py b/litellm/litellm_core_utils/hidden_params.py index a74337d2549..202226fa9ad 100644 --- a/litellm/litellm_core_utils/hidden_params.py +++ b/litellm/litellm_core_utils/hidden_params.py @@ -63,7 +63,8 @@ def stored_attribute(obj: object, name: str) -> object: def _get_hidden_params_storage(obj: object) -> object | None: if isinstance(obj, dict): return obj.get(_HIDDEN_PARAMS_ATTR) - if isinstance(obj, BaseModel) and _HIDDEN_PARAMS_ATTR in type(obj).__private_attributes__: + model_type: Final = type(obj) + if issubclass(model_type, BaseModel) and _HIDDEN_PARAMS_ATTR in model_type.__private_attributes__: return getattr(obj, _HIDDEN_PARAMS_ATTR, None) return stored_attribute(obj, _HIDDEN_PARAMS_ATTR)