From c99355d44118be21179ab60bccc29f30e1aa710d Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 28 Jul 2026 16:01:43 +0000 Subject: [PATCH] test(sap): cover content validator shapes for cache_control passthrough --- .../llms/sap/chat/test_sap_transformation.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_litellm/llms/sap/chat/test_sap_transformation.py b/tests/test_litellm/llms/sap/chat/test_sap_transformation.py index 2631fe5c392..df44df2e7bc 100644 --- a/tests/test_litellm/llms/sap/chat/test_sap_transformation.py +++ b/tests/test_litellm/llms/sap/chat/test_sap_transformation.py @@ -776,3 +776,23 @@ class TestSAPPromptCaching: assert template[0]["content"] == "part one\npart two" assert template[1]["content"] == "answer" assert template[2]["content"] == "tool result" + + def test_content_shapes_accepted_by_the_content_validator(self): + from litellm.llms.sap.chat.models import SAPMessage + + assert SAPMessage(role="system", content=[]).content == "" + assert SAPMessage(role="system", content={"type": "text", "text": "hi"}).content == "hi" + cached = SAPMessage( + role="system", + content={"type": "text", "text": "hi", "cache_control": {"type": "ephemeral"}}, + ) + assert [block.model_dump(by_alias=True, exclude_unset=True) for block in cached.content] == [ + {"type": "text", "text": "hi", "cache_control": {"type": "ephemeral"}} + ] + assert SAPMessage( + role="system", + content=["plain", {"type": "text", "text": ""}, {"type": "text", "text": "block"}], + ).content == "plain\nblock" + + with pytest.raises(ValidationError): + SAPMessage(role="system", content=7)