From a749d4e5224d9c9e8e23cbd17bc6289f0f6977d4 Mon Sep 17 00:00:00 2001 From: stevejaker Date: Tue, 10 Mar 2026 14:46:53 -0600 Subject: [PATCH] fix: add warning for empty function name and integration test - Warn when tool_call is found but function name is empty (consistency) - Add test_transform_request_with_tool_messages integration test to verify transform_request correctly wires _transform_messages Co-Authored-By: Claude Opus 4.6 --- litellm/llms/snowflake/chat/transformation.py | 5 +++ .../test_snowflake_chat_transformation.py | 36 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/litellm/llms/snowflake/chat/transformation.py b/litellm/llms/snowflake/chat/transformation.py index c4fc203a7f1..95e88f43abc 100644 --- a/litellm/llms/snowflake/chat/transformation.py +++ b/litellm/llms/snowflake/chat/transformation.py @@ -329,6 +329,11 @@ class SnowflakeConfig(SnowflakeBaseConfig, OpenAIGPTConfig): else: function = tool_call.get("function", {}) function_name = function.get("name", "") + if not function_name: + litellm.utils.verbose_logger.warning( + f"Snowflake: tool_call_id '{tool_call_id}' found but function name " + "is empty; tool_results block will have name=''." + ) # Get content - could be string, list, or None content = tool_msg.get("content") diff --git a/tests/test_litellm/llms/snowflake/chat/test_snowflake_chat_transformation.py b/tests/test_litellm/llms/snowflake/chat/test_snowflake_chat_transformation.py index b10cb27f6d9..7de396a17e8 100644 --- a/tests/test_litellm/llms/snowflake/chat/test_snowflake_chat_transformation.py +++ b/tests/test_litellm/llms/snowflake/chat/test_snowflake_chat_transformation.py @@ -439,6 +439,42 @@ class TestSnowflakeToolTransformation: assert tool_results[0]["tool_results"]["tool_use_id"] == "call_1" assert tool_results[1]["tool_results"]["tool_use_id"] == "call_2" + def test_transform_request_with_tool_messages(self): + """ + Test that transform_request correctly wires _transform_messages for tool results. + """ + config = SnowflakeConfig() + + messages = [ + {"role": "user", "content": "What's the weather?"}, + { + "role": "assistant", + "content": "", + "tool_calls": [ + { + "id": "call_1", + "type": "function", + "function": {"name": "get_weather", "arguments": '{"location": "Paris"}'}, + } + ], + }, + {"role": "tool", "tool_call_id": "call_1", "content": "72°F"}, + ] + + result = config.transform_request( + model="claude-3-5-sonnet", + messages=messages, + optional_params={}, + litellm_params={}, + headers={}, + ) + + transformed = result["messages"] + assert len(transformed) == 3 + assert transformed[2]["role"] == "user" + assert "content_list" in transformed[2] + assert transformed[2]["content_list"][0]["type"] == "tool_results" + class TestSnowFlakeCompletion: model_name = "mistral"