From 7c562a3c40cf9d01a108b7f3e070a43c1c6335fd Mon Sep 17 00:00:00 2001 From: kicer Date: Wed, 2 Sep 2026 10:07:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=98=BE=E7=A4=BA=E5=85=B7?= =?UTF-8?q?=E4=BD=93=E8=B0=83=E7=94=A8=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/server/engine.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/server/engine.js b/app/server/engine.js index 3fbfc86..e47a30a 100644 --- a/app/server/engine.js +++ b/app/server/engine.js @@ -79,9 +79,18 @@ function saveMessage(sessionId, msg) { msg.tool_call_id || null, msg.name || null, now()); // 关键动作日志:AI 每轮回复落库(含纯工具调用轮) if (msg.role === 'assistant') { - const nTools = msg.tool_calls ? msg.tool_calls.length : 0; - log.info('[msg] ' + sessionId + ' AI 回复:文本 ' + String(msg.content || '').length + ' 字' + - (nTools ? ',工具调用 ×' + nTools : '')); + const calls = msg.tool_calls || []; + let toolDesc = ''; + if (calls.length) { + // 按出现顺序去重,同名多次调用追加 ×N + const counts = new Map(); + for (const c of calls) { + const name = (c && c.function && c.function.name) || '未知工具'; + counts.set(name, (counts.get(name) || 0) + 1); + } + toolDesc = ',工具调用:' + [...counts].map(([name, n]) => (n > 1 ? name + '×' + n : name)).join('、'); + } + log.info('[msg] ' + sessionId + ' AI 回复:文本 ' + String(msg.content || '').length + ' 字' + toolDesc); } return info.lastInsertRowid; }