Skip to content

Commit e5f31af

Browse files
claude-code-bestglm-5-turbo
andcommitted
fix: ExecuteExtraTool 委托执行前增加 validateInput 校验,优化工具显示样式
- 在 call() 中 checkPermissions 之前调用目标工具的 validateInput(),防止模型传入不完整参数导致崩溃(如 TeamCreate 缺少 team_name → sanitizeName(undefined).replace() TypeError) - renderToolUseMessage 从 "Executing TeamCreate..." 简化为 "TeamCreate",与其他工具样式一致 Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
1 parent fc8d531 commit e5f31af

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

packages/builtin-tools/src/tools/ExecuteTool/ExecuteTool.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,29 @@ export const ExecuteTool = buildTool({
121121
}
122122
}
123123

124+
// Validate input before delegating — prevents crashes when the model
125+
// omits required params (e.g. TeamCreate without team_name →
126+
// sanitizeName(undefined).replace() TypeError).
127+
if (targetTool.validateInput) {
128+
const validation = await targetTool.validateInput(
129+
input.params as Record<string, unknown>,
130+
context,
131+
)
132+
if (!validation.result) {
133+
return {
134+
data: {
135+
result: null,
136+
tool_name: input.tool_name,
137+
},
138+
newMessages: [
139+
createUserMessage({
140+
content: `Invalid parameters for tool "${input.tool_name}": ${validation.message}`,
141+
}),
142+
],
143+
}
144+
}
145+
}
146+
124147
// Check permissions on the target tool
125148
const permResult = await targetTool.checkPermissions?.(
126149
input.params as Record<string, unknown>,
@@ -164,7 +187,7 @@ export const ExecuteTool = buildTool({
164187
}
165188
},
166189
renderToolUseMessage(input) {
167-
return `Executing ${input.tool_name}...`
190+
return `${input.tool_name}`
168191
},
169192
userFacingName() {
170193
return 'ExecuteExtraTool'

0 commit comments

Comments
 (0)