Skip to content

Commit e990fb0

Browse files
author
延枚
committed
修复在启用特定工具集时基础工具无法处理的问题
Change-Id: I2da73f98a4a30bb72d26d9a5a876d4808dfc09fc Co-developed-by: iFlow <[email protected]>
1 parent 2cfc722 commit e990fb0

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

tool-handlers/index.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,30 @@ export const handleToolRequestByToolset = async (request: any, toolsetName: Tool
7979

8080
// 新增处理启用工具集的接口
8181
export const handleEnabledToolRequest = async (request: any, enabledToolsets: Toolset[]) => {
82-
// 如果没有指定启用的工具集,则处理所有工具集
83-
const toolsets = enabledToolsets.length > 0 ? enabledToolsets : Object.values(Toolset);
82+
// 总是先尝试处理基础工具集
83+
try {
84+
const baseResult = await handleToolRequestByToolset(request, Toolset.BASE);
85+
if (baseResult !== null) {
86+
return baseResult;
87+
}
88+
} catch (error) {
89+
// 如果工具不在基础工具集中,继续尝试其他工具集
90+
// 如果是其他错误,重新抛出
91+
if (!(error instanceof Error && error.message.includes("Unknown tool"))) {
92+
throw error;
93+
}
94+
}
95+
96+
// 如果没有指定启用的工具集,则处理所有工具集(除了基础工具集,因为已经处理过了)
97+
const toolsets = enabledToolsets.length > 0 ? enabledToolsets : Object.values(Toolset).filter(t => t !== Toolset.BASE);
8498

8599
// 按顺序尝试每个启用的工具集
86100
for (const toolset of toolsets) {
101+
// 跳过基础工具集,因为我们已经处理过了
102+
if (toolset === Toolset.BASE) {
103+
continue;
104+
}
105+
87106
try {
88107
const result = await handleToolRequestByToolset(request, toolset);
89108
if (result !== null) {

0 commit comments

Comments
 (0)