From e780a7c1dc624259a55da019dfb5e6896413e4d8 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Sun, 3 May 2026 03:39:36 -0700 Subject: [PATCH] fix(base_llm): filter all _-prefixed class attrs from get_config The drop_params strip work added `AnthropicConfig._EFFORT_SUPPORTING_MODEL_PATTERNS` as a private class-level lookup tuple. `BaseConfig.get_config()` only filtered the `__`-prefixed names plus `_abc` / `_is_base_class`, so `_EFFORT_SUPPORTING_MODEL_PATTERNS` would have leaked into the request body the same way `REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT` did before the previous commit. Generalize the existing `_abc` / `_is_base_class` carve-outs to skip every `_`-prefixed name. `AmazonConverseConfig.get_config()` overrides the base method, so apply the same change there. Also unblocks future internal helpers from accidentally serialising into the wire body. --- litellm/llms/base_llm/chat/transformation.py | 10 +++++++--- litellm/llms/bedrock/chat/converse_transformation.py | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/litellm/llms/base_llm/chat/transformation.py b/litellm/llms/base_llm/chat/transformation.py index b71ae0fddee..e36ba0c14a1 100644 --- a/litellm/llms/base_llm/chat/transformation.py +++ b/litellm/llms/base_llm/chat/transformation.py @@ -84,12 +84,16 @@ class BaseConfig(ABC): @classmethod def get_config(cls): + # Subclasses lean on this to surface their public default settings + # (e.g. ``max_tokens``) as request params. Anything ``_``-prefixed is + # treated as private (lookup tables, ABC machinery, internal flags) + # and must not leak into the wire body — a tuple/dict/frozenset class + # attribute would otherwise serialise into the request as an extra + # top-level key and the provider would 400 it. return { k: v for k, v in cls.__dict__.items() - if not k.startswith("__") - and not k.startswith("_abc") - and not k.startswith("_is_base_class") + if not k.startswith("_") and not isinstance( v, ( diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.py index 7fd6a87d9d9..f711e88df6e 100644 --- a/litellm/llms/bedrock/chat/converse_transformation.py +++ b/litellm/llms/bedrock/chat/converse_transformation.py @@ -189,10 +189,12 @@ class AmazonConverseConfig(BaseConfig): @classmethod def get_config(cls): + # ``_``-prefixed names are private (lookup tables, ABC machinery, + # internal flags) and must not leak into the wire body. return { k: v for k, v in cls.__dict__.items() - if not k.startswith("__") + if not k.startswith("_") and not isinstance( v, (