diff --git a/litellm/llms/vertex_ai/common_utils.py b/litellm/llms/vertex_ai/common_utils.py index 5770832a10e..320d9acfdb3 100644 --- a/litellm/llms/vertex_ai/common_utils.py +++ b/litellm/llms/vertex_ai/common_utils.py @@ -854,7 +854,9 @@ def convert_anyof_null_to_nullable(schema, depth=0): anyof: Final = schema.get("anyOf", None) if anyof is not None: contains_null: Final = any(isinstance(atype, dict) and atype.get("type") == "null" for atype in anyof) - remaining: Final = [atype for atype in anyof if not (isinstance(atype, dict) and atype.get("type") == "null")] + remaining: Final = [ # mutable-ok: anyOf must stay a list for downstream schema consumers + atype for atype in anyof if not (isinstance(atype, dict) and atype.get("type") == "null") + ] if len(remaining) == 0: # Edge case: response schema with only null type present is invalid in Vertex AI