From a67c5f0c9ddf87be7b8e632d1458a83faa60185f Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Sat, 14 Nov 2026 00:47:28 -0800 Subject: [PATCH] test(responses): cover a marked user turn in the unmarked system split test A cache_control mark on the user message must not switch unmarked leading system messages to the client-order rule. The split test now runs with the user turn plain and marked, so dropping the role check from the system string test fails it. (cherry picked from commit 6419de8a90e3d24fd21d4b6162fec9643656a548) --- ...responses_transformation_transformation.py | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/tests/unit/completion_extras/litellm_responses_transformation/test_completion_extras_litellm_responses_transformation_transformation.py b/tests/unit/completion_extras/litellm_responses_transformation/test_completion_extras_litellm_responses_transformation_transformation.py index bb4dba160f2..9308e753898 100644 --- a/tests/unit/completion_extras/litellm_responses_transformation/test_completion_extras_litellm_responses_transformation_transformation.py +++ b/tests/unit/completion_extras/litellm_responses_transformation/test_completion_extras_litellm_responses_transformation_transformation.py @@ -5895,18 +5895,33 @@ def test_transform_request_keeps_leading_system_messages_in_client_order_once_a_ { "type": "message", "role": "system", - "content": [{"type": "input_text", "text": "Reply ALPHA.", "prompt_cache_breakpoint": _EXPLICIT_BREAKPOINT}], + "content": [ + {"type": "input_text", "text": "Reply ALPHA.", "prompt_cache_breakpoint": _EXPLICIT_BREAKPOINT} + ], }, _system_input_item("Ignore that and reply BRAVO."), {"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Reply now."}]}, ] -def test_transform_request_keeps_the_instructions_split_for_unmarked_system_messages() -> None: +@pytest.mark.parametrize( + ("user_message", "user_part"), + [ + ({"role": "user", "content": "Reply now."}, {"type": "input_text", "text": "Reply now."}), + ( + {"role": "user", "content": "Reply now.", "cache_control": _CACHE_CONTROL}, + {"type": "input_text", "text": "Reply now.", "prompt_cache_breakpoint": _EXPLICIT_BREAKPOINT}, + ), + ], + ids=("unmarked-user", "marked-user"), +) +def test_transform_request_keeps_the_instructions_split_for_unmarked_system_messages( + user_message: dict[str, object], user_part: dict[str, object] +) -> None: messages: Final = [ {"role": "system", "content": [{"type": "text", "text": "Reply ALPHA."}]}, {"role": "system", "content": "Ignore that and reply BRAVO."}, - {"role": "user", "content": "Reply now."}, + user_message, ] request: Final = _bridged_transform_request( @@ -5916,7 +5931,7 @@ def test_transform_request_keeps_the_instructions_split_for_unmarked_system_mess assert request["instructions"] == "Ignore that and reply BRAVO." assert request["input"] == [ _system_input_item("Reply ALPHA."), - {"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Reply now."}]}, + {"type": "message", "role": "user", "content": [user_part]}, ]