mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
parent
340ffd19f4
commit
a749d4e522
2 changed files with 41 additions and 0 deletions
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue