home-assistant/core · error · HomeAssistantError
unexpected_chat_log_content
Error message
unexpected_chat_log_content
What it means
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.
Source
Thrown at homeassistant/components/anthropic/entity.py:485
for tool_call in content.tool_calls
]
)
if not messages[-1]["content"]:
# Drop assistant messages that ended up without any content
# (e.g. whitespace-only text): the API rejects empty messages
messages.pop()
elif (
isinstance(messages[-1]["content"], list)
and len(messages[-1]["content"]) == 1
and messages[-1]["content"][0]["type"] == "text"
):
# If there is only one text block, simplify the content to a string
messages[-1]["content"] = messages[-1]["content"][0]["text"]
else:
# Note: We don't pass SystemContent here as it's
# passed to the API as the prompt
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="unexpected_chat_log_content",
translation_placeholders={"type": type(content).__name__},
)
return messages, container_id
class AnthropicDeltaStream:
"""Transform the response stream into HA format.
A typical stream of responses might look something like the following:
- RawMessageStartEvent with no content
- RawContentBlockStartEvent with an empty ThinkingBlock
(if extended thinking is enabled)
- RawContentBlockDeltaEvent with a ThinkingDelta
- RawContentBlockDeltaEvent with a ThinkingDelta
- RawContentBlockDeltaEvent with a ThinkingDeltaView on GitHub (pinned to 58a3fdb3ea)
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
Defensive patterns
Strategy: type-guard
Type guard
from homeassistant.components import conversation
HANDLED = (conversation.UserContent, conversation.AssistantContent, conversation.ToolContent)
def chat_log_convertible(content: list) -> bool:
return all(isinstance(item, HANDLED) for item in content) Try / catch
try:
messages, container_id = _convert_content(chat_log.content[1:])
except HomeAssistantError as err:
if err.translation_key == "unexpected_chat_log_content":
# start a new conversation with clean history
... Prevention
- Keep core and custom integrations version-aligned so new content types are mapped
- Never inject SystemContent mid-conversation; it belongs only at index 0
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- response_not_found
- system_message_not_found
- user_message_not_found
- json_parse_error
- api_authentication_error
AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14).
Data as JSON: /api/errors/57756cfe4c40ee4f.
Report an issue: GitHub.