Replace dot with underscores for NamespacedTool and ActionTool (#147764)

This commit is contained in:
Denis Shulyaka 2025-07-05 12:27:27 +03:00 committed by GitHub
parent 23773759ea
commit 3151713a34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -331,7 +331,7 @@ class NamespacedTool(Tool):
def __init__(self, namespace: str, tool: Tool) -> None: def __init__(self, namespace: str, tool: Tool) -> None:
"""Init the class.""" """Init the class."""
self.namespace = namespace self.namespace = namespace
self.name = f"{namespace}.{tool.name}" self.name = f"{namespace}__{tool.name}"
self.description = tool.description self.description = tool.description
self.parameters = tool.parameters self.parameters = tool.parameters
self.tool = tool self.tool = tool
@ -915,7 +915,7 @@ class ActionTool(Tool):
"""Init the class.""" """Init the class."""
self._domain = domain self._domain = domain
self._action = action self._action = action
self.name = f"{domain}.{action}" self.name = f"{domain}__{action}"
# Note: _get_cached_action_parameters only works for services which # Note: _get_cached_action_parameters only works for services which
# add their description directly to the service description cache. # add their description directly to the service description cache.
# This is not the case for most services, but it is for scripts. # This is not the case for most services, but it is for scripts.

View File

@ -1542,18 +1542,18 @@ This is prompt 2
""" """
) )
assert [(tool.name, tool.description) for tool in instance.tools] == [ assert [(tool.name, tool.description) for tool in instance.tools] == [
("api-1.Tool_1", "Description 1"), ("api-1__Tool_1", "Description 1"),
("api-2.Tool_2", "Description 2"), ("api-2__Tool_2", "Description 2"),
] ]
# The test tool returns back the provided arguments so we can verify # The test tool returns back the provided arguments so we can verify
# the original tool is invoked with the correct tool name and args. # the original tool is invoked with the correct tool name and args.
result = await instance.async_call_tool( 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"}}} assert result == {"result": {"Tool_1": {"arg1": "value1"}}}
result = await instance.async_call_tool( 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"}}} assert result == {"result": {"Tool_2": {"arg2": "value2"}}}