From 121709104864f3d66a097c7ed681eb2bb4b5129d Mon Sep 17 00:00:00 2001 From: Daniel Yudelevich <4537920+yudelevi@users.noreply.github.com> Date: Fri, 26 Jun 2026 13:00:07 -0700 Subject: [PATCH] test(deepseek): cover the response_schema-key extraction branch Add coverage for the alternate top-level `response_schema` key path in _downgrade_json_schema_to_json_object (mirrors GroqChatConfig's extraction), bringing patch coverage on the change to 100%. --- .../chat/test_deepseek_chat_transformation.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_litellm/llms/deepseek/chat/test_deepseek_chat_transformation.py b/tests/test_litellm/llms/deepseek/chat/test_deepseek_chat_transformation.py index 22af0a66139..9b315096817 100644 --- a/tests/test_litellm/llms/deepseek/chat/test_deepseek_chat_transformation.py +++ b/tests/test_litellm/llms/deepseek/chat/test_deepseek_chat_transformation.py @@ -153,6 +153,30 @@ def test_downgrade_json_schema_without_schema_body_still_downgrades(): assert messages == original_messages +def test_downgrade_reads_response_schema_key(): + """Some callers pass the schema under a top-level `response_schema` key + (mirrors GroqChatConfig's extraction); it is downgraded and injected too.""" + config = DeepSeekChatConfig() + messages, optional_params = config._downgrade_json_schema_to_json_object( + model="deepseek-chat", + messages=[{"role": "user", "content": "Is the sky blue?"}], + optional_params={ + "response_format": { + "type": "json_schema", + "response_schema": { + "type": "object", + "properties": {"answer": {"type": "string"}}, + "required": ["answer"], + "additionalProperties": False, + }, + } + }, + ) + + assert optional_params["response_format"] == {"type": "json_object"} + assert "answer" in messages[-1]["content"] + + def test_downgrade_is_noop_for_json_object(): config = DeepSeekChatConfig() original_messages = [{"role": "user", "content": "Is the sky blue?"}]