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.
This commit is contained in:
Rob Sherman 2026-02-28 20:57:41 -08:00
parent 0b65e0a2b2
commit 19e85ea067
No known key found for this signature in database

View file

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