File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 1
1
# Copyright (c) Alibaba, Inc. and its affiliates.
2
2
import asyncio
3
+ import os
3
4
from copy import copy
4
5
from typing import Any , Dict , List , Optional
5
6
10
11
from ms_agent .tools .mcp_client import MCPClient
11
12
from ms_agent .tools .split_task import SplitTask
12
13
14
+ MAX_TOOL_NAME_LEN = os .getenv ('MAX_TOOL_NAME_LEN' , 64 )
15
+
13
16
14
17
class ToolManager :
15
18
"""Interacting with Agent class, hold all tools
@@ -45,7 +48,12 @@ async def reindex_tool(self):
45
48
def extend_tool (tool_ins : ToolBase , server_name : str ,
46
49
tool_list : List [Tool ]):
47
50
for tool in tool_list :
48
- key = server_name + ':' + tool ['tool_name' ]
51
+ max_server_len = MAX_TOOL_NAME_LEN - len (
52
+ tool ['tool_name' ]) - 1 # 减去 ':' 的 1 个字符
53
+ if len (server_name ) > max_server_len :
54
+ key = f"{ server_name [:max_server_len ]} :{ tool ['tool_name' ]} "
55
+ else :
56
+ key = f"{ server_name } :{ tool ['tool_name' ]} "
49
57
assert key not in self ._tool_index , f'Tool name duplicated { tool ["tool_name" ]} '
50
58
tool = copy (tool )
51
59
tool ['tool_name' ] = key
You can’t perform that action at this time.
0 commit comments