diff --git a/homeassistant/helpers/llm.py b/homeassistant/helpers/llm.py index bf89e693870..a8a598c79f8 100644 --- a/homeassistant/helpers/llm.py +++ b/homeassistant/helpers/llm.py @@ -331,7 +331,7 @@ class NamespacedTool(Tool): def __init__(self, namespace: str, tool: Tool) -> None: """Init the class.""" self.namespace = namespace - self.name = f"{namespace}.{tool.name}" + self.name = f"{namespace}__{tool.name}" self.description = tool.description self.parameters = tool.parameters self.tool = tool @@ -915,7 +915,7 @@ class ActionTool(Tool): """Init the class.""" self._domain = domain self._action = action - self.name = f"{domain}.{action}" + self.name = f"{domain}__{action}" # Note: _get_cached_action_parameters only works for services which # add their description directly to the service description cache. # This is not the case for most services, but it is for scripts. diff --git a/tests/helpers/test_llm.py b/tests/helpers/test_llm.py index b978559130c..78ff675f0b6 100644 --- a/tests/helpers/test_llm.py +++ b/tests/helpers/test_llm.py @@ -1542,18 +1542,18 @@ This is prompt 2 """ ) assert [(tool.name, tool.description) for tool in instance.tools] == [ - ("api-1.Tool_1", "Description 1"), - ("api-2.Tool_2", "Description 2"), + ("api-1__Tool_1", "Description 1"), + ("api-2__Tool_2", "Description 2"), ] # The test tool returns back the provided arguments so we can verify # the original tool is invoked with the correct tool name and args. result = await instance.async_call_tool( - llm.ToolInput(tool_name="api-1.Tool_1", tool_args={"arg1": "value1"}) + llm.ToolInput(tool_name="api-1__Tool_1", tool_args={"arg1": "value1"}) ) assert result == {"result": {"Tool_1": {"arg1": "value1"}}} result = await instance.async_call_tool( - llm.ToolInput(tool_name="api-2.Tool_2", tool_args={"arg2": "value2"}) + llm.ToolInput(tool_name="api-2__Tool_2", tool_args={"arg2": "value2"}) ) assert result == {"result": {"Tool_2": {"arg2": "value2"}}}