home-assistant/core · error · HomeAssistantError
system_message_not_found
Error message
system_message_not_found
What it means
A HomeAssistantError with translation key 'system_message_not_found' raised when chat_log.content[0] is not a conversation.SystemContent instance. The Anthropic entity requires the first chat log item to be the system prompt, which it passes separately as the 'system' parameter of MessageCreateParamsStreaming.
Source
Thrown at homeassistant/components/anthropic/entity.py:946
chat_log: conversation.ChatLog,
structure_name: str | None = None,
structure: vol.Schema | None = None,
) -> tuple[MessageCreateParamsStreaming, str | None]:
"""Get the model arguments."""
options: dict[str, Any] = DEFAULT | self.subentry.data
preloaded_tools = [
"HassTurnOn",
"HassTurnOff",
"GetLiveContext",
"code_execution",
"web_search",
"web_fetch",
]
system = chat_log.content[0]
if not isinstance(system, conversation.SystemContent):
raise HomeAssistantError(
translation_domain=DOMAIN, translation_key="system_message_not_found"
)
messages, container_id = _convert_content(chat_log.content[1:])
model = options[CONF_CHAT_MODEL]
model_args = MessageCreateParamsStreaming(
model=model,
messages=messages,
max_tokens=options[CONF_MAX_TOKENS],
system=system.content,
stream=True,
container=container_id,
)
if options[CONF_PROMPT_CACHING] == PromptCaching.PROMPT:
model_args["system"] = [View on GitHub (pinned to 58a3fdb3ea)
Solutions
- Ensure chat_log.async_add_content is first called with SystemContent (agent's instructions) before user turns
- Start a fresh conversation rather than resuming one whose stored history is missing the system block
- Update to the matching core version if the ChatLog construction API changed
Defensive patterns
Strategy: validation
Validate before calling
from homeassistant.components import conversation
def starts_with_system(chat_log: conversation.ChatLog) -> bool:
return bool(chat_log.content) and isinstance(chat_log.content[0], conversation.SystemContent) Try / catch
system = chat_log.content[0]
if not isinstance(system, conversation.SystemContent):
raise HomeAssistantError(translation_domain=DOMAIN, translation_key="system_message_not_found") Prevention
- Add SystemContent as the first chat log item when constructing a ChatLog
- Do not resume conversations whose persisted history lost the leading system block
When it happens
Trigger: Invoking _async_handle_chat_log with a chat log whose first element is a user or assistant message — e.g. a caller built the ChatLog without async_add_content sequencing a system prompt first, or the system prompt was stripped.
Common situations: Custom scripts or integrations constructing a conversation.ChatLog manually and forgetting the system message; resuming a conversation_id whose stored history lacks the leading SystemContent.
Related errors
- response_not_found
- unexpected_chat_log_content
- 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/e68758aeb6ca00c9.
Report an issue: GitHub.