Set tool metadata in assist_satellite (#182708)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Paulus Schoutsen
2026-09-24 21:26:40 +02:00
committed by GitHub
co-authored by Claude
parent c5a82be26e
commit 6f9bda36c3
2 changed files with 26 additions and 3 deletions
@@ -3,10 +3,20 @@
from homeassistant.components.llm import LLMTools
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import intent
from homeassistant.helpers.llm import LLM_API_ASSIST, IntentTool, LLMContext, Tool
from homeassistant.helpers.llm import (
LLM_API_ASSIST,
IntentTool,
LLMContext,
Tool,
ToolAnnotations,
)
from .const import DOMAIN
# A broadcast announces something every time it is called and takes nothing
# away, and it only reaches the user's own satellites.
LLM_ANNOTATIONS = ToolAnnotations(destructive=False, open_world=False)
@callback
def async_get_tools(
@@ -19,7 +29,13 @@ def async_get_tools(
# assist_satellite registers the broadcast intent when it is set up, and
# this platform is only queried once that has happened.
tools: list[Tool] = [
IntentTool(f"{DOMAIN}__{handler.intent_type}", handler)
IntentTool(
f"{DOMAIN}__{handler.intent_type}",
handler,
title="Broadcast message",
integration=DOMAIN,
annotations=LLM_ANNOTATIONS,
)
for handler in intent.async_get(hass)
if handler.intent_type == intent.INTENT_BROADCAST
]
@@ -31,4 +31,11 @@ def _llm_context() -> llm.LLMContext:
async def test_broadcast_tool_offered(hass: HomeAssistant) -> None:
"""Test the broadcast intent is exposed as an LLM tool."""
result = await llm_component.async_get_tools(hass, _llm_context(), "assist")
assert "assist_satellite__HassBroadcast" in [tool.name for tool in result.tools]
tools = {tool.name: tool for tool in result.tools}
assert "assist_satellite__HassBroadcast" in tools
tool = tools["assist_satellite__HassBroadcast"]
assert tool.title == "Broadcast message"
assert tool.integration == "assist_satellite"
# A broadcast announces again on every call and takes nothing away.
assert tool.annotations == llm.ToolAnnotations(destructive=False, open_world=False)