From ae34a6b375e2266333892c61e33b58c3e0828739 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 27 Nov 2024 12:04:08 -0500 Subject: [PATCH] Do not double expose scripts in LLM tools (#131726) --- homeassistant/helpers/llm.py | 12 ++++-------- tests/helpers/test_llm.py | 4 ---- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/homeassistant/helpers/llm.py b/homeassistant/helpers/llm.py index 49ae1455006..38d80d5649d 100644 --- a/homeassistant/helpers/llm.py +++ b/homeassistant/helpers/llm.py @@ -445,17 +445,13 @@ def _get_exposed_entities( entities = {} for state in hass.states.async_all(): - if not async_should_expose(hass, assistant, state.entity_id): + if ( + not async_should_expose(hass, assistant, state.entity_id) + or state.domain == SCRIPT_DOMAIN + ): continue description: str | None = None - if state.domain == SCRIPT_DOMAIN: - description, parameters = _get_cached_script_parameters( - hass, state.entity_id - ) - if parameters.schema: # Only list scripts without input fields here - continue - entity_entry = entity_registry.async_get(state.entity_id) names = [state.name] area_names = [] diff --git a/tests/helpers/test_llm.py b/tests/helpers/test_llm.py index 4b2fc9e5fc1..3787526c433 100644 --- a/tests/helpers/test_llm.py +++ b/tests/helpers/test_llm.py @@ -517,10 +517,6 @@ async def test_assist_api_prompt( ) ) exposed_entities_prompt = """An overview of the areas and the devices in this smart home: -- names: script_with_no_fields - domain: script - state: 'off' - description: This is another test script - names: Kitchen domain: light state: 'on'