From 0eee0e9a5480a2e66f3636dc817c727a6554ae91 Mon Sep 17 00:00:00 2001 From: Chris Hunter Date: Fri, 20 Mar 2026 14:28:24 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20address=20review=20feedback=20=E2=80=94?= =?UTF-8?q?=20step=20numbering=20and=20regex=20anchor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Renumber steps: sanitization is now step 6, beta headers step 7 - Use \Z instead of $ in regex to avoid matching trailing newlines Co-Authored-By: Claude Opus 4.6 --- .../anthropic_claude3_transformation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py b/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py index e82e21582c9..25eec08a445 100644 --- a/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py +++ b/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py @@ -373,7 +373,7 @@ class AmazonAnthropicClaudeMessagesConfig( schema_text = {"type": "text", "text": json.dumps(schema)} content.append(schema_text) - _VALID_TOOL_ID_PATTERN = re.compile(r"^[a-zA-Z0-9_-]+$") + _VALID_TOOL_ID_PATTERN = re.compile(r"^[a-zA-Z0-9_-]+\Z") _INVALID_TOOL_ID_CHARS = re.compile(r"[^a-zA-Z0-9_-]") def _sanitize_tool_use_ids(self, anthropic_messages_request: Dict) -> None: @@ -476,13 +476,13 @@ class AmazonAnthropicClaudeMessagesConfig( # Ref: https://github.com/BerriAI/litellm/issues/22847 remove_custom_field_from_tools(anthropic_messages_request) - # 7. Sanitize tool_use IDs (Bedrock requires ^[a-zA-Z0-9_-]+$) + # 6. Sanitize tool_use IDs (Bedrock requires ^[a-zA-Z0-9_-]+$) # The Anthropic native API allows broader characters in tool_use IDs, # but Bedrock rejects them with 400 Bad Request. # Fixes: https://github.com/BerriAI/litellm/issues/21114 self._sanitize_tool_use_ids(anthropic_messages_request) - # 6. AUTO-INJECT beta headers based on features used + # 7. AUTO-INJECT beta headers based on features used anthropic_model_info = AnthropicModelInfo() tools = anthropic_messages_optional_request_params.get("tools") messages_typed = cast(List[AllMessageValues], messages)