From b048ce4cc118e498afb8e4da405208fa90fb7152 Mon Sep 17 00:00:00 2001 From: Marty Sullivan Date: Wed, 12 Aug 2026 04:15:33 -0400 Subject: [PATCH] refactor(logging): drop the type-gate commentary The comment restated what the gate does and carried incident detail that would drift, including a claim about downstream callbacks that the evidence does not support. The rationale belongs in the regression test, which fails if the copy is ever reintroduced ahead of the gate, rather than in prose that can rot silently Also corrects that test's docstring for the same overclaim: the raise aborts the handler body at the redaction call, and what that costs a given deployment was not established --- litellm/litellm_core_utils/redact_messages.py | 7 ------- .../litellm_core_utils/test_redact_messages.py | 6 +++--- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/litellm/litellm_core_utils/redact_messages.py b/litellm/litellm_core_utils/redact_messages.py index e91acaa97ca..0d590e1ceba 100644 --- a/litellm/litellm_core_utils/redact_messages.py +++ b/litellm/litellm_core_utils/redact_messages.py @@ -258,13 +258,6 @@ def perform_redaction(model_call_details: dict, result, redact_streaming_respons # For async objects, return a simple redacted response without deepcopy return {"text": "redacted-by-litellm"} - # Only the shapes handled below can be redacted; every other type falls through - # to the placeholder return at the end of this block, which discards the copy. - # Deciding that before copying keeps the deepcopy off objects it cannot help: - # binary/HTTP response bodies (batch output, file content) hold an unpicklable - # `_thread.lock` and raise TypeError here, which aborts success logging and every - # spend callback with it, and a large batch body would be copied only to be thrown - # away. if not ( isinstance(result, (litellm.ModelResponse, litellm.ResponsesAPIResponse, litellm.EmbeddingResponse)) or (isinstance(result, dict) and ("choices" in result or "output" in result)) 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 88d2a95dd4f..8fa6d44dd8a 100644 --- a/tests/test_litellm/litellm_core_utils/test_redact_messages.py +++ b/tests/test_litellm/litellm_core_utils/test_redact_messages.py @@ -688,9 +688,9 @@ class TestPerformRedaction: Binary/HTTP response bodies (batch output, file content, audio) hold an unpicklable ``_thread.lock``. Copying one raises TypeError inside - ``Logging.success_handler``, which aborts every success callback with it - so the - spend row for a completed batch is never written. The copy is also pointless: - an unrecognized shape returns the placeholder and the copy is discarded. + ``Logging.success_handler``, which aborts the handler body at the redaction call so + everything after it is skipped. The copy is also pointless: an unrecognized shape + returns the placeholder and the copy is discarded. The lock is the assertion. If a deepcopy is ever reintroduced ahead of the type check, this raises instead of returning.