From bbec40fb7251e56912dea09ab999b272e528c4f3 Mon Sep 17 00:00:00 2001 From: dharaneesh Date: Mon, 14 Sep 2026 10:47:34 +0530 Subject: [PATCH] test(logging): cover audio redaction via the custom logger entry path Adds the regression test that reproduces the reported flow end to end: a custom logger with message_logging off receives a response whose audio field is nulled while the original response stays intact. --- .../test_redact_messages.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/test_litellm/litellm_core_utils/test_redact_messages.py b/tests/test_litellm/litellm_core_utils/test_redact_messages.py index 38dff63e193..08d43d99d63 100644 --- a/tests/test_litellm/litellm_core_utils/test_redact_messages.py +++ b/tests/test_litellm/litellm_core_utils/test_redact_messages.py @@ -16,6 +16,7 @@ from litellm.integrations.custom_logger import CustomLogger from litellm.litellm_core_utils.redact_messages import ( _redact_responses_api_output, perform_redaction, + redact_message_input_output_from_custom_logger, redact_streaming_responses_for_custom_logger, redacted_standard_logging_payload, should_redact_message_logging, @@ -442,6 +443,33 @@ class TestPerformRedaction: assert result.choices[0].message.audio is not None assert result.choices[0].message.audio.transcript == "sensitive transcript" + def test_opted_out_logger_redacts_audio_on_custom_logger_entry(self): + logger = SimpleNamespace(message_logging=False) + logs = SimpleNamespace(model_call_details={}) + response = litellm.ModelResponse( + id="resp-3", + choices=[ + litellm.Choices( + message=litellm.Message( + content="message content", + role="assistant", + audio=ChatCompletionAudioResponse( + data="", + expires_at=1_752_000_000, + transcript="sensitive transcript", + ), + ) + ) + ], + model="gpt-4o-audio-preview", + ) + + redacted = redact_message_input_output_from_custom_logger(logs, response, logger) + + assert redacted.choices[0].message.audio is None + assert redacted.choices[0].message.content == "redacted-by-litellm" + assert response.choices[0].message.audio is not None + def test_redacts_audio_on_streaming_response_object(self): streaming_choice = litellm.utils.StreamingChoices( delta=litellm.utils.Delta(