From fa4fa17c2ec778dc978f9c62cea984061ca5fee8 Mon Sep 17 00:00:00 2001 From: Daniel Cherubini Date: Mon, 6 Jul 2026 13:27:05 +0200 Subject: [PATCH] docs: clarify _as_system_content_blocks fallback behavior Addresses Greptile review comment on PR #31452: document that non-str/ list/dict values falling through to a bare wrap is intentional, since callers are expected to validate content against the Anthropic message schema before this normalization step runs. --- .../messages/transformation.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py b/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py index c6335e05708..eb2fa0b2ce2 100644 --- a/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py +++ b/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py @@ -100,7 +100,15 @@ class AnthropicMessagesConfig(BaseAnthropicMessagesConfig): @staticmethod def _as_system_content_blocks(value: Any) -> list: - """Convert system content to a list of content blocks.""" + """Convert system content to a list of content blocks. + + A bare ``dict`` (e.g. ``{"type": "text", "text": "..."}``) is treated as + a single content block shorthand and wrapped as-is — Anthropic's API + accepts this shape directly. Any other non-``None``/``str``/``list``/ + ``dict`` value (e.g. an int) is also passed through unchanged; callers + are expected to have already validated ``content`` against the + Anthropic message schema upstream of this normalization step. + """ if value is None: return [] if isinstance(value, list):