// 看工具模式下两边的消息条数/字数,以及"工具说明/字段说明"有没有既进消息又进 tools 描述(重复)。 import { readFileSync } from "node:fs"; for (const file of process.argv.slice(2)) { const body = JSON.parse(JSON.parse(readFileSync(file, "utf8")).body); const msgs = body.messages || []; const total = msgs.reduce((n, m) => n + String(m.content ?? "").length, 0); const desc = (body.tools || []).map((t) => String(t.function?.description ?? "").length); const paramDesc = (body.tools || []).flatMap((t) => Object.values(t.function?.parameters?.properties ?? {}).map((p) => String(p.description ?? "").length)); const hitDesc = msgs.some((m) => String(m.content ?? "").includes("POSIX Terminal Screen Kernel Configuration")); const hitParam = msgs.some((m) => String(m.content ?? "").includes("terminal_payload_contract")); console.log(file.split("/").pop()); console.log(" messages=" + msgs.length + " 正文合计=" + total + " 字; tools=" + (body.tools || []).length + " 工具描述=" + desc.join(",") + " 参数描述=" + paramDesc.join(",")); console.log(" 工具说明也在 messages 里? " + hitDesc + "; 字段说明也在 messages 里? " + hitParam); }