{"record":{"id":"f156cb6b62fc5970","repo":"home-assistant/core","slug":"ai-task-entity-entity-id-does-not-support-attach","errorCode":null,"errorMessage":"AI Task entity {entity_id} does not support attachments","messagePattern":"AI Task entity (.+?) does not support attachments","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/ai_task/task.py","lineNumber":143,"sourceCode":"        entity_id = hass.data[DATA_PREFERENCES].gen_data_entity_id\n\n    if entity_id is None:\n        raise HomeAssistantError(\"No entity_id provided and no preferred entity set\")\n\n    entity = hass.data[DATA_COMPONENT].get_entity(entity_id)\n    if entity is None:\n        raise HomeAssistantError(f\"AI Task entity {entity_id} not found\")\n\n    if AITaskEntityFeature.GENERATE_DATA not in entity.supported_features:\n        raise HomeAssistantError(\n            f\"AI Task entity {entity_id} does not support generating data\"\n        )\n\n    if (\n        attachments\n        and AITaskEntityFeature.SUPPORT_ATTACHMENTS not in entity.supported_features\n    ):\n        raise HomeAssistantError(\n            f\"AI Task entity {entity_id} does not support attachments\"\n        )\n\n    with async_get_chat_session(hass) as session:\n        resolved_attachments = await _resolve_attachments(hass, session, attachments)\n\n        return await entity.internal_async_generate_data(\n            session,\n            GenDataTask(\n                name=task_name,\n                instructions=instructions,\n                structure=structure,\n                attachments=resolved_attachments or None,\n                llm_api=llm_api,\n            ),\n        )\n\n","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/ai_task/task.py#L125-L161","documentation":"HomeAssistantError from ai_task.async_generate_data when attachments were supplied but the entity's supported_features lacks AITaskEntityFeature.SUPPORT_ATTACHMENTS. The guard runs after existence and GENERATE_DATA checks, immediately before resolving attachments in the chat session — an entity that cannot ingest files would otherwise silently ignore them.","triggerScenarios":"Calling ai_task.generate_data (or generate_image) with a non-empty attachments list against an agent whose provider/integration does not support file attachments (feature flag not advertised).","commonSituations":"Using a local or older LLM integration (e.g. Ollama before attachment support) with image/file attachments; mixing attachments into prompts for agents that only accept plain text.","solutions":["Drop the attachments argument for this entity, or inline the needed context as text in instructions.","Switch to an agent that advertises attachment support (feature flag visible on current OpenAI/Google/Anthropic conversation integrations).","Update the conversation integration so SUPPORT_ATTACHMENTS is implemented.","For images, pre-process to a description using an agent that does support attachments, then feed the text forward."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"def attachments_ok(entity, attachments) -> bool:\n    \"\"\"Attachments require the SUPPORT_ATTACHMENTS flag.\"\"\"\n    return not attachments or AITaskEntityFeature.SUPPORT_ATTACHMENTS in entity.supported_features","typeGuard":"def entity_accepts_attachments(entity) -> bool:\n    \"\"\"Narrowing guard for attachment-capable AI Task entities.\"\"\"\n    return AITaskEntityFeature.SUPPORT_ATTACHMENTS in entity.supported_features","tryCatchPattern":"from homeassistant.exceptions import HomeAssistantError\n\ntry:\n    result = await async_generate_data(\n        hass, entity_id=eid, task_name=\"t\", instructions=\"...\", attachments=atts\n    )\nexcept HomeAssistantError as err:\n    if \"does not support attachments\" in str(err):\n        atts = None  # degrade to text-only and retry\n        result = await async_generate_data(hass, entity_id=eid, task_name=\"t\", instructions=\"...\")\n    else:\n        raise","preventionTips":["Check supported_features before sending attachments; fall back to text context.","Use attachment-capable agents (current major-provider integrations) for multimodal tasks.","Keep local LLM integrations updated as attachment support lands."],"tags":["homeassistant","ai-task","attachments","feature-flags"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}