Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(anthropic): guard against non-dict messages in strip_advisor_blocks_from_messages

Ishaan Jaffer011e087939fa
diff --git a/litellm/llms/anthropic/common_utils.py b/litellm/llms/anthropic/common_utils.py
index 1205d1afbcf..1a003727e97 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):