From 011e087939fa14bd0cd7e2b9ea16fb292a0cb889 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Sat, 11 Apr 2026 11:33:29 -0700 Subject: [PATCH] fix(anthropic): guard against non-dict messages in strip_advisor_blocks_from_messages --- litellm/llms/anthropic/common_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/llms/anthropic/common_utils.py b/litellm/llms/anthropic/common_utils.py index 1205d1afbc..1a003727e9 100644 --- a/litellm/llms/anthropic/common_utils.py +++ b/litellm/llms/anthropic/common_utils.py @@ -650,7 +650,7 @@ def strip_advisor_blocks_from_messages(messages: List[Any]) -> List[Any]: control or on a follow-up turn. """ for message in messages: - if message.get("role") != "assistant": + if not isinstance(message, dict) or message.get("role") != "assistant": continue content = message.get("content") if not isinstance(content, list):