refactor: read include_cost_in_streaming_usage directly, type MaskedHTTPStatusError init, drop unused encrypted reasoning check (#50617)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Mateo Wang 2026-11-10 16:55:08 +00:00 • committed by GitHub
parent bece938ccc
commit 82ef50bacb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 10 deletions

View file

@ -123,7 +123,7 @@ def proxy_request_headers(container: Mapping[str, object] | None) -> Mapping[str
def stream_cost_injection_requested(request_headers: Mapping[str, object] | None) -> bool:
"""The global include_cost_in_streaming_usage flag or the per-request header asks for usage.cost on streams."""
if bool(getattr(litellm, "include_cost_in_streaming_usage", False)):
if litellm.include_cost_in_streaming_usage:
return True
if not request_headers:
return False

View file

@ -282,14 +282,6 @@ def anthropic_content_lists(messages: Sequence[object]) -> Iterator[object]:
)
def _content_carries_encrypted_reasoning(content: object) -> bool:
return any(is_encrypted_reasoning_block(block) for block in _object_sequence(content))
def messages_carry_encrypted_reasoning(messages: Sequence[object]) -> bool:
return any(_content_carries_encrypted_reasoning(content) for content in anthropic_content_lists(messages))
def _strip_encrypted_reasoning_from_blocks(
content: object,
*,

View file

@ -663,7 +663,9 @@ class HTTPResponseLimitError(ValueError):
class MaskedHTTPStatusError(httpx.HTTPStatusError):
def __init__(self, original_error: httpx.HTTPStatusError, message: str | None = None, text: str | None = None):
def __init__(
self, original_error: httpx.HTTPStatusError, message: str | None = None, text: str | None = None
) -> None:
# Create a new error with the masked URL
masked_url: Final = mask_sensitive_info(str(original_error.request.url))
# Mask the original exception message too (it contains the full URL)