Repository navigation
fix(agent): 修复兴趣图谱进化链路断裂(#422) - #425
Merged
Merged
Conversation
生产实测:interest-history 最后快照停在 09-08(#236 发布后 1 小时),此后 图谱零 persist。三条独立断点: 1. 反思输出截断:maxOutputTokens 3000 对推理模型(reasoning 计入上限, 实测单次 reasoning ~1.7k)必截断 JSON,parse 失败被当「零洞察」静默 吞掉(10-14 四次反思 outputTokens 全部恰好 =3000)。→ 上限提至 8000。 2. 反思 prompt 未规定字段名:模型输出 name/interest/reason,Zod schema 要 topic/reasoning,全量丢弃。→ prompt 写死精确 JSON 结构与示例,并把 图谱当前 top-10 兴趣注入 user prompt(existingInterestUpdates 只能从 清单选,否则 updateInterestGraph 静默跳过)。 3. 游荡回灌断粮:#176 话题准入(≤4 英文词/拒域名)把搜索长 query 与 URL 主机名 100% 滤掉,plausible 恒空且静默 return。→ 提取 record_knowledge 的 title(模型概括的干净话题)作为喂料;候选全滤时 warn 留痕。 4. worker 日志黑洞:run-one-wander 不初始化文件 logger,consola 输出全部 进 nullStream(「不是合法 JSON」等报错从未落盘)。→ 租户上下文就绪后 initFileLogger()。 验证:agent 包 634 测试 / lint / typecheck 全绿;新增反思调用契约测试与 extractRecentTopics 直测。
4 tasks
Owner
Author
|
Review(subagent)结论 APPROVE,5 条 P2 建议中采纳 3 条轻量改进:① callLLM 读图谱前补 isInitialized/load 防御(与 updateInterestGraph 同款);② 断粮 warn 区分「零候选」(纯 speak/rest 游荡,不告警)与「有候选全被拒」(warn);③ 注释措辞收敛(中文标题稳定通过,英文长标题仍会被拒)。其余 P2(loadConfig 前置错误仍进黑洞、loaded-graph prompt 测试)接受现状。CI 重新触发中。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
Closes #422。生产实测 admin 租户
interest-history.jsonl最后快照停在 2026-09-08 12:20(#236 发布后 1 小时),此后图谱零 persist、兴趣零进化,游荡 focusTopics 整个 10 月都在用 9 月的旧兴趣。根因(三条独立断点 + 一个观测黑洞)
maxOutputTokens: 3000对推理模型不够(reasoning tokens 计入同一上限,实测 v4-flash 单次 reasoning ~1.7k + 正文 ~1.5k)。生产 10-14 四次反思的 outputTokens 全部恰好 = 3000,JSON 全部截断、parse 全部失败,被当「零洞察」静默吞掉。name/interest/reason,Zod schema 要topic/reasoning→ 即使不截断也会全量丢弃。plausible.length === 0静默 return,一个多月无人知晓。run-one-wander不初始化文件 logger,consola 的 stdout/stderr 是 nullStream——「反思 LLM 输出不是合法 JSON」「兴趣回灌失败」等报错从未落盘,故障不可见。修复
engine.ts:输出上限 3000 → 8000(REFLECTION_MAX_OUTPUT_TOKENS常量 + 注释);system prompt 写死精确 JSON 结构(字段名一字不差 + 约束);user prompt 注入图谱当前 top-10 兴趣清单(existingInterestUpdates只能从清单选——否则updateInterestGraph静默跳过清单外话题)。wander-agent.ts:extractRecentTopics收集 record_knowledge 的 title(模型自己概括的干净话题,稳定通过 [bug] 兴趣图谱被污染:搜索 query 与 URL 域名成为兴趣节点(#147 同类) #176 准入)——提取函数提为模块级导出纯函数;候选全滤时logger.warn留痕,不再静默。run-one-wander.ts:租户上下文就绪后initFileLogger(),consola 日志落租户logs/目录。验证
pnpm --filter agent test:634 通过(新增反思调用契约测试 +extractRecentTopics直测 4 例)pnpm --filter agent lint/typecheck通过interest-history.jsonl出现新快照、游荡 query 不再是 "September 2026" 陈旧话题