From 167e1b20e5ee9b3ca3785a785d33ec1e1504bed4 Mon Sep 17 00:00:00 2001 From: Jay Date: Fri, 8 May 2026 12:12:32 -0400 Subject: [PATCH] test: add async path coverage for ZAI content flattening Address Greptile feedback: the async code path in _transform_messages was untested. Add pytest.mark.asyncio test verifying list content is flattened in the async path. Signed-off-by: Jay --- .../zai/chat/test_zai_chat_transformation.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/litellm/llms/zai/chat/test_zai_chat_transformation.py b/tests/litellm/llms/zai/chat/test_zai_chat_transformation.py index 837851f5bc1..c024468c969 100644 --- a/tests/litellm/llms/zai/chat/test_zai_chat_transformation.py +++ b/tests/litellm/llms/zai/chat/test_zai_chat_transformation.py @@ -155,3 +155,22 @@ class TestZAITransformMessages: assert isinstance(result[0]["content"], str) assert "caption" in result[0]["content"] + + @pytest.mark.asyncio + async def test_tool_message_list_content_flattened_async(self): + """Async path: tool message with list content is flattened.""" + messages = [ + { + "role": "tool", + "tool_call_id": "call_1", + "content": [{"type": "text", "text": "async result"}], + }, + ] + + result = await self.config._transform_messages( + messages, model="glm-4.6", is_async=True + ) + + tool_msg = result[0] + assert isinstance(tool_msg["content"], str) + assert tool_msg["content"] == "async result"