diff --git a/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py b/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py index 8806c297db6..da7836d80de 100644 --- a/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py +++ b/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py @@ -6565,3 +6565,26 @@ def test_eager_input_streaming_reaches_anthropic_request_tools(): assert result["tools"][0]["eager_input_streaming"] is True assert result["tools"][0]["name"] == "write_file" + + +def test_messages_request_strips_identity_only_system_for_minimax(): + """Identity-only system drops the whole system param (pop path).""" + from litellm.llms.minimax.messages.transformation import MinimaxMessagesConfig + from litellm.types.router import GenericLiteLLMParams + + config = MinimaxMessagesConfig() + optional_params = { + "max_tokens": 16, + "system": [ + {"type": "text", "text": "You are Claude Code, Anthropic's official CLI for Claude."}, + ], + } + result = config.transform_anthropic_messages_request( + model="MiniMax-M2", + messages=[{"role": "user", "content": "hi"}], + anthropic_messages_optional_request_params=optional_params, + litellm_params=GenericLiteLLMParams(), + headers={}, + ) + + assert "system" not in result diff --git a/tests/test_litellm/llms/anthropic/test_anthropic_common_utils.py b/tests/test_litellm/llms/anthropic/test_anthropic_common_utils.py index 5d1f92773e5..0e30c4c868c 100644 --- a/tests/test_litellm/llms/anthropic/test_anthropic_common_utils.py +++ b/tests/test_litellm/llms/anthropic/test_anthropic_common_utils.py @@ -108,6 +108,20 @@ CLAUDE_CODE_IDENTITY = "You are Claude Code, Anthropic's official CLI for Claude ], [{"type": "text", "text": "real system prompt", "cache_control": {"type": "ephemeral"}}], ), + # List form: identity + real content in the same block -> rewritten block. + ( + [{"type": "text", "text": f"{CLAUDE_CODE_IDENTITY}\nreal system prompt"}], + [{"type": "text", "text": "real system prompt"}], + ), + # List form: a non-text block (type "other") is kept as-is. + ( + [{"type": "text", "text": CLAUDE_CODE_IDENTITY}, {"type": "other", "foo": "bar"}], + [{"type": "other", "foo": "bar"}], + ), + # List form: non-dict items are kept as-is. + ([{"type": "text", "text": CLAUDE_CODE_IDENTITY}, "loose item"], ["loose item"]), + # Non-string, non-list system payload is passed through untouched. + (None, None), ], ) def test_strip_claude_code_identity_from_system(system_param, expected):