From 13403b4fdad35225ac0f7b33e63246631017c019 Mon Sep 17 00:00:00 2001 From: shivani kumar Date: Mon, 29 Jun 2026 17:03:56 -0400 Subject: [PATCH] Revert "fix: auto-normalize array of strings in message content to openai spec" --- litellm/utils.py | 10 ---------- tests/test_litellm/test_utils.py | 32 -------------------------------- 2 files changed, 42 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index 0b131fbcf9ec..5c3ab3e14904 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -8224,16 +8224,6 @@ def validate_and_fix_openai_messages(messages: List): if message.get("tool_calls"): message["tool_calls"] = jsonify_tools(tools=message["tool_calls"]) - content = message.get("content") - if isinstance(content, list): - normalized_content = [] - for item in content: - if isinstance(item, str): - normalized_content.append({"type": "text", "text": item}) - else: - normalized_content.append(item) - message["content"] = normalized_content - convert_msg_to_dict = cast(AllMessageValues, convert_to_dict(message)) cleaned_message = cleanup_none_field_in_message(message=convert_msg_to_dict) new_messages.append(cleaned_message) diff --git a/tests/test_litellm/test_utils.py b/tests/test_litellm/test_utils.py index 3c94ddb1666d..d94a86d8e551 100644 --- a/tests/test_litellm/test_utils.py +++ b/tests/test_litellm/test_utils.py @@ -27,7 +27,6 @@ get_llm_provider, get_optional_params_image_gen, is_cached_message, - validate_and_fix_openai_messages, ) # Adds the parent directory to the system path @@ -3323,37 +3322,6 @@ def test_message_level_cache_control_non_dict_returns_false(self): assert is_cached_message(message) is False -def test_normalize_array_of_strings_in_content(): - """String items in list content become OpenAI multimodal text parts; dict parts unchanged.""" - only_strings = validate_and_fix_openai_messages( - [ - { - "role": "user", - "content": ["what is the capital of France?"], - } - ] - ) - assert only_strings[0]["content"] == [ - {"type": "text", "text": "what is the capital of France?"} - ] - - mixed = validate_and_fix_openai_messages( - [ - { - "role": "user", - "content": [ - "some text", - {"type": "image_url", "image_url": {"url": "https://example.com/x.png"}}, - ], - } - ] - ) - assert mixed[0]["content"] == [ - {"type": "text", "text": "some text"}, - {"type": "image_url", "image_url": {"url": "https://example.com/x.png"}}, - ] - - @pytest.mark.asyncio class TestProxyLoggingBudgetAlerts: """Test budget_alerts method in ProxyLogging class."""