write_file:null内容双层拒防静默清空;目录目标中文预检;返回值区分新建/覆盖(原N字节);checkToolArgs缺参判定改为null判缺/空串放行;描述补覆盖与UTF-8边界

This commit is contained in:
2026-09-22 22:31:49 +08:00
parent 8d73f4cc55
commit 572107ac2b
3 changed files with 19 additions and 6 deletions
+3 -1
View File
@@ -851,8 +851,10 @@ function checkToolArgs(tools, name, raw) {
}
const def = (tools || []).find(t => t && t.function && t.function.name === name);
const required = def && def.function.parameters && def.function.parameters.required;
// null/undefined 都算缺;空串放行(如 write_file content:"" 写空文件合法),
// 必填串参传空的场景由各工具自己的中文校验兑底(path 空→「路径不能为空」,url 空→「缺少参数 url」…)。
const missing = required && required.length
? required.filter(k => args[k] === undefined || args[k] === '') : [];
? required.filter(k => args[k] == null) : [];
if (missing.length) return { args: null, error: 'Error: ToolCall Missing Params: ' + missing.join('、') };
return { args, error: null };
}