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.
This commit is contained in:
Daniel Cherubini 2026-07-06 13:27:05 +02:00
parent d62b001f2f
commit fa4fa17c2e

View file

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