mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 16:25:51 +00:00
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>
This commit is contained in:
@@ -121,6 +121,29 @@ export const ExecuteTool = buildTool({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate input before delegating — prevents crashes when the model
|
||||||
|
// omits required params (e.g. TeamCreate without team_name →
|
||||||
|
// sanitizeName(undefined).replace() TypeError).
|
||||||
|
if (targetTool.validateInput) {
|
||||||
|
const validation = await targetTool.validateInput(
|
||||||
|
input.params as Record<string, unknown>,
|
||||||
|
context,
|
||||||
|
)
|
||||||
|
if (!validation.result) {
|
||||||
|
return {
|
||||||
|
data: {
|
||||||
|
result: null,
|
||||||
|
tool_name: input.tool_name,
|
||||||
|
},
|
||||||
|
newMessages: [
|
||||||
|
createUserMessage({
|
||||||
|
content: `Invalid parameters for tool "${input.tool_name}": ${validation.message}`,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check permissions on the target tool
|
// Check permissions on the target tool
|
||||||
const permResult = await targetTool.checkPermissions?.(
|
const permResult = await targetTool.checkPermissions?.(
|
||||||
input.params as Record<string, unknown>,
|
input.params as Record<string, unknown>,
|
||||||
@@ -164,7 +187,7 @@ export const ExecuteTool = buildTool({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
renderToolUseMessage(input) {
|
renderToolUseMessage(input) {
|
||||||
return `Executing ${input.tool_name}...`
|
return `${input.tool_name}`
|
||||||
},
|
},
|
||||||
userFacingName() {
|
userFacingName() {
|
||||||
return 'ExecuteExtraTool'
|
return 'ExecuteExtraTool'
|
||||||
|
|||||||
Reference in New Issue
Block a user