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
This commit is contained in:
Marty Sullivan 2026-08-12 04:15:33 -04:00
parent 132bee892a
commit b048ce4cc1
2 changed files with 3 additions and 10 deletions

View file

@ -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))

View file

@ -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.