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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(anthropic): remove explicit cache_control null in tool_result content
lizhene4cb28aa0784
diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.pyindex 30263543fc6..034089080f7 100644--- a/litellm/litellm_core_utils/prompt_templates/factory.py+++ b/litellm/litellm_core_utils/prompt_templates/factory.py@@ -1677,13 +1677,16 @@ def convert_to_anthropic_tool_result(] = []for content in content_list:if content["type"] == "text":- anthropic_content_list.append(- AnthropicMessagesToolResultContent(- type="text",- text=content["text"],- cache_control=content.get("cache_control", None),- )- )+ # Only include cache_control if explicitly set and not None+ # to avoid sending "cache_control": null which breaks some API channels+ text_content: AnthropicMessagesToolResultContent = {+ "type": "text",+ "text": content["text"],+ }+ cache_control_value = content.get("cache_control")+ if cache_control_value is not None:+ text_content["cache_control"] = cache_control_value+ anthropic_content_list.append(text_content)elif content["type"] == "image_url":format = (content["image_url"].get("format")