{"record":{"id":"57756cfe4c40ee4f","repo":"home-assistant/core","slug":"unexpected-chat-log-content","errorCode":null,"errorMessage":"unexpected_chat_log_content","messagePattern":"unexpected_chat_log_content","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/anthropic/entity.py","lineNumber":485,"sourceCode":"                        for tool_call in content.tool_calls\n                    ]\n                )\n\n            if not messages[-1][\"content\"]:\n                # Drop assistant messages that ended up without any content\n                # (e.g. whitespace-only text): the API rejects empty messages\n                messages.pop()\n            elif (\n                isinstance(messages[-1][\"content\"], list)\n                and len(messages[-1][\"content\"]) == 1\n                and messages[-1][\"content\"][0][\"type\"] == \"text\"\n            ):\n                # If there is only one text block, simplify the content to a string\n                messages[-1][\"content\"] = messages[-1][\"content\"][0][\"text\"]\n        else:\n            # Note: We don't pass SystemContent here as it's\n            # passed to the API as the prompt\n            raise HomeAssistantError(\n                translation_domain=DOMAIN,\n                translation_key=\"unexpected_chat_log_content\",\n                translation_placeholders={\"type\": type(content).__name__},\n            )\n\n    return messages, container_id\n\n\nclass AnthropicDeltaStream:\n    \"\"\"Transform the response stream into HA format.\n\n    A typical stream of responses might look something like the following:\n    - RawMessageStartEvent with no content\n    - RawContentBlockStartEvent with an empty ThinkingBlock\n      (if extended thinking is enabled)\n    - RawContentBlockDeltaEvent with a ThinkingDelta\n    - RawContentBlockDeltaEvent with a ThinkingDelta\n    - RawContentBlockDeltaEvent with a ThinkingDelta","sourceCodeStart":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/anthropic/entity.py#L467-L503","documentation":"A HomeAssistantError with translation key 'unexpected_chat_log_content' raised by _convert_content in the Anthropic entity when it encounters a chat log content item whose Python type it does not handle. The placeholder 'type' carries the offending class name. Only UserContent, AssistantContent, and ToolContent branches are handled; everything else (e.g. SystemContent reaching this path) is rejected.","triggerScenarios":"chat_log.content[1:] containing an item that is not one of the handled content classes — for example a SystemContent injected mid-conversation, or a new content type introduced by a newer homeassistant conversation API that the Anthropic integration has not mapped.","commonSituations":"Version skew: running a custom/modified anthropic integration against a newer Home Assistant core that adds content block types; or another integration appending non-standard items to the shared conversation chat log.","solutions":["Read the 'type' placeholder in the error to identify the unsupported content class","Align versions: update Home Assistant core and the anthropic integration together so content types are handled","Start a new conversation (new conversation_id) to drop the malformed chat log history"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"from homeassistant.components import conversation\n\nHANDLED = (conversation.UserContent, conversation.AssistantContent, conversation.ToolContent)\n\ndef chat_log_convertible(content: list) -> bool:\n    return all(isinstance(item, HANDLED) for item in content)","tryCatchPattern":"try:\n    messages, container_id = _convert_content(chat_log.content[1:])\nexcept HomeAssistantError as err:\n    if err.translation_key == \"unexpected_chat_log_content\":\n        # start a new conversation with clean history\n        ...","preventionTips":["Keep core and custom integrations version-aligned so new content types are mapped","Never inject SystemContent mid-conversation; it belongs only at index 0"],"tags":["home-assistant","anthropic","chat-log","type-mismatch"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}