Set tool metadata in script (#182713)

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Simon Lamon <32477463+silamon@users.noreply.github.com>
This commit is contained in:
Paulus Schoutsen
2026-09-24 21:42:55 +02:00
committed by GitHub
co-authored by Claude Simon Lamon
parent a9f7c8f7b7
commit 313a3a4bc6
2 changed files with 12 additions and 0 deletions
+4
View File
@@ -31,6 +31,10 @@ class ScriptTool(ActionTool):
super().__init__(hass, DOMAIN, action)
self.name = f"{DOMAIN}__{script_name}"
# The script is named by the user, so its name is already in their
# language.
if state := hass.states.get(script_entity_id):
self.title = state.name
if entity_entry and (
aliases := er.async_get_entity_aliases(hass, entity_entry)
+8
View File
@@ -54,6 +54,14 @@ def _llm_context() -> llm.LLMContext:
)
async def test_script_tool_title(hass: HomeAssistant) -> None:
"""Test the script tool is titled with the name the user gave the script."""
result = await llm_component.async_get_tools(hass, _llm_context(), "assist")
tool = next(tool for tool in result.tools if tool.name == "script__test_script")
assert tool.title == "test script"
assert tool.integration == "script"
async def test_script_tool_only_exposed(hass: HomeAssistant) -> None:
"""Test only exposed scripts get a tool."""
result = await llm_component.async_get_tools(hass, _llm_context(), "assist")