From 19e85ea067c4b7c20cae46823781e0e56e0eb0f3 Mon Sep 17 00:00:00 2001 From: Rob Sherman Date: Sat, 28 Feb 2026 20:57:41 -0800 Subject: [PATCH] fix: add verbose_logger.debug when max_tokens is capped Emit a debug log when the adapter silently reduces max_tokens to the model's output limit, consistent with the get_modified_max_tokens pattern in token_counter.py. Aids debugging when users observe shorter completions than expected. --- .../experimental_pass_through/adapters/handler.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py b/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py index 5aad85dac60..2ffedbf154d 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py @@ -141,6 +141,14 @@ class LiteLLMMessagesToCompletionTransformationHandler: ) model_max_output = model_info.get("max_output_tokens") if model_max_output is not None and max_tokens > model_max_output: + from litellm._logging import verbose_logger + + verbose_logger.debug( + "Anthropic adapter: capping max_tokens from %d to %d for model=%s", + max_tokens, + model_max_output, + model, + ) max_tokens = model_max_output except Exception: pass