m50 / ha-fallback-conversation

HomeAssistant Assist Fallback Conversation Agent
MIT License
69 stars 11 forks source link

Unexpected error during intent recognition HA2024.10.1 #36

Open thekiwismarthome opened 4 days ago

thekiwismarthome commented 4 days ago

I am using v1.0.4 Fallback Agent on HA2024.10.1, as soon as I upgraded to the latest HA version, Intents were not being recognised any longer. I am using StreamAssist for the ViewAssist project. FYI, I had to downgrade to v1.0.4 as on v2.0+ the python memory was rising to 100% over about 10 minutes and HA was no longer usable. A few of us had this issue and v1.0.4 stopped that from happening. The error we are now getting is ...

Logger: homeassistant.components.assist_pipeline.pipeline
Source: components/assist_pipeline/pipeline.py:1017
integration: Assist pipeline ([documentation](https://www.home-assistant.io/integrations/assist_pipeline), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+assist_pipeline%22))
First occurred: 10:27:26 (3 occurrences)
Last logged: 12:31:59

Unexpected error during intent recognition
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/assist_pipeline/pipeline.py", line 1017, in recognize_intent
    conversation_result = await conversation.async_converse(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/conversation/agent_manager.py", line 110, in async_converse
    result = await method(conversation_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/fallback_conversation/__init__.py", line 69, in async_process
    default_agent = conversation.default_agent.async_get_default_agent(self.hass)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'homeassistant.components.conversation.default_agent' has no attribute 'async_get_default_agent'. Did you mean: 'async_setup_default_agent'?
AshaiRey commented 3 days ago

I can can confirm this issue and have the same issue

Fallback Agent version 1.0.5

How I test this I have 2 assistants.

Each separately will work and give a expected reply. But when I place Fallback Agent Conversation in front of them things are failing Changing the order of primary and secondary has no effect

This started with the core update 10.0 Rolling back to core_2024.9.3 and the issue disappears

`2024-10-12 12:48:43.551 ERROR (MainThread) [homeassistant.components.assist_pipeline.pipeline] Unexpected error during intent recognition Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/assist_pipeline/pipeline.py", line 1017, in recognize_intent conversation_result = await conversation.async_converse( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/conversation/agent_manager.py", line 110, in async_converse result = await method(conversation_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/fallback_conversation/init.py", line 69, in async_process default_agent = conversation.default_agent.async_get_default_agent(self.hass) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'homeassistant.components.conversation.default_agent' has no attribute 'async_get_default_agent'. Did you mean: 'async_setup_default_agent'?


stage: done run: pipeline: 01gzjxzzrj300hsq06hqhd0zzk language: nl runner_data: stt_binary_handler_id: null timeout: 300 events:

AshaiRey commented 3 days ago

I did some investigation on my own and I think I was able to make a fix for this

Open the file _int_py Add at the top these lines as marked below

from __future__ import annotations

import logging

from homeassistant.components import conversation
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.util import ulid
from home_assistant_intents import get_languages

# ADD THIS LINE
from homeassistant.components.conversation.default_agent import (
    DATA_DEFAULT_ENTITY,
    DefaultAgent,
)

In the same file go down to async def async_process(

  async def async_process(
        self, user_input: conversation.ConversationInput
    ) -> conversation.ConversationResult:
        """Process a sentence."""
        agent_manager = conversation.get_agent_manager(self.hass)
        # COMMENT OUT THE LINE BELOW 
        # default_agent = conversation.default_agent.async_get_default_agent(self.hass)
        # ADD THIS LINE
        default_agent = self.hass.data[DATA_DEFAULT_ENTITY]

Now save the file and RESTART HA