From 0055842d2d34af9c1446444d18538789d5dfc00a Mon Sep 17 00:00:00 2001 From: kicer Date: Fri, 2 Oct 2026 10:08:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(llm):=20=E6=A0=87=E9=A2=98=E7=94=9F?= =?UTF-8?q?=E6=88=90=E8=BE=93=E5=85=A5=E5=89=94=E9=99=A4=20[CTX]=20?= =?UTF-8?q?=E6=B3=A8=E5=85=A5=E8=A1=8C=E2=80=94=E2=80=94=E7=99=BD=E5=90=8D?= =?UTF-8?q?=E5=8D=95=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit titleMessages 原只排 archived,channel_note/memory_note(及 scheduler_note/ errAck/旧 summarize_request)等固定模板注入会喂进标题模型做「摘要」。 改白名单:null/summary/task_brief——后两者是会话主题的最佳凝缩,须保留; profile 快照不在 messages 表,天然不进。新增合成 type 默认被排除。 --- app/server/llm.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/server/llm.js b/app/server/llm.js index 38aae49..4599f7d 100644 --- a/app/server/llm.js +++ b/app/server/llm.js @@ -19,10 +19,15 @@ const TITLE_PROMPT_TEMPLATE = fs.readFileSync(path.join(__dirname, 'templates', // 拼标题回合的 messages:历史原样(只留 user/assistant 纯文本行)+ 末尾一条标题指令 user。 // 与 buildMessages 同取舍:archived 行不进;__blocks__ 哨兵 JSON 还原为文字,图片以 [图片] 占位; // 含 tool_calls 的 assistant 行无文本内容则跳过,tool 回执行整体跳过(只要对话主干)。 +// 注入行不进(白名单制,新合成 type 默认排除):[CTX] channel/memory 是固定模板文本, +// 喂给标题模型等于拿广告词做摘要;scheduler_note/errAck/旧 summarize_request 同类系统噪音。 +// 白名单里 summary 与 task_brief 例外保留:它们本身就是会话主题的最佳凝缩(阶段切换后 +// 旧历史全 archived,只剩 task_brief 可读);profile 快照不在 messages 表,天然不进。 +const TITLE_ROW_TYPES = new Set([null, undefined, 'summary', 'task_brief']); function titleMessages(history, language) { const messages = []; for (const row of history || []) { - if (row.type === 'archived') continue; + if (!TITLE_ROW_TYPES.has(row.type)) continue; if (row.role !== 'user' && row.role !== 'assistant') continue; let content = row.content || ''; const blocks = decodeBlocks(content);