From 1356309ee9cdc7e8fd0b5597ca2585a129e9138e Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2026 14:51:01 +0000 Subject: [PATCH] fix(logging): keep logging empty string system prompts Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/litellm_core_utils/litellm_logging.py | 2 +- .../test_litellm/litellm_core_utils/test_litellm_logging.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index 5357da7543b..d0dcd3e696e 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -4549,7 +4549,7 @@ class StandardLoggingPayloadSetup: if kwargs is None: return messages system: Final = kwargs.get("system") - if not system or not isinstance(system, (str, list)): + if not isinstance(system, (str, list)) or (isinstance(system, list) and not system): return messages system_message: Final = {"role": "system", "content": system} if messages is None: diff --git a/tests/test_litellm/litellm_core_utils/test_litellm_logging.py b/tests/test_litellm/litellm_core_utils/test_litellm_logging.py index cf65c20d74b..2e1263a7114 100644 --- a/tests/test_litellm/litellm_core_utils/test_litellm_logging.py +++ b/tests/test_litellm/litellm_core_utils/test_litellm_logging.py @@ -2261,16 +2261,18 @@ def test_append_system_prompt_messages_content_blocks(): ) assert result == [{"role": "system", "content": system_blocks}, *messages] - # already-prepended system blocks are not duplicated result = StandardLoggingPayloadSetup.append_system_prompt_messages( kwargs={"system": system_blocks}, messages=result ) assert len(result) == 2 - # empty system is not logged as an empty system turn assert ( StandardLoggingPayloadSetup.append_system_prompt_messages(kwargs={"system": []}, messages=messages) == messages ) + assert StandardLoggingPayloadSetup.append_system_prompt_messages(kwargs={"system": ""}, messages=messages) == [ + {"role": "system", "content": ""}, + *messages, + ] @pytest.mark.asyncio