From c8c9ef2690e57c5747b8578afcb7b242b3d7dcd3 Mon Sep 17 00:00:00 2001 From: Mihidum Hettiyahandi <55163074+mihidumh@users.noreply.github.com> Date: Thu, 17 Sep 2026 09:21:32 +1000 Subject: [PATCH] refactor(batch): read the row body without a mutable fallback literal `(entry.get("body") or {})` counts as mutable-collection construction (LIT002), and main has since lowered that ceiling. Check the body is a dict instead; behaviour is unchanged. --- litellm/proxy/hooks/batch_rate_limiter.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/hooks/batch_rate_limiter.py b/litellm/proxy/hooks/batch_rate_limiter.py index 140783a4a4d..12585916e16 100644 --- a/litellm/proxy/hooks/batch_rate_limiter.py +++ b/litellm/proxy/hooks/batch_rate_limiter.py @@ -981,7 +981,10 @@ class _PROXY_BatchRateLimiter(CustomLogger): # estimate; floor it there again so a row carrying a # large base64 audio payload cannot slide the batch # under the TPM limit. - if messages_contain_input_audio_content_blocks((entry.get("body") or {}).get("messages")): + entry_body = entry.get("body") if isinstance(entry, dict) else None + if isinstance(entry_body, dict) and messages_contain_input_audio_content_blocks( + entry_body.get("messages") + ): entry_total_tokens = max(entry_total_tokens, _estimate_batch_entry_tokens(raw_line)) except Exception: entry_total_tokens = _estimate_batch_entry_tokens(raw_line)