Skip to content

fix: 修复记忆模块误写入与错误分类问题#55

Merged
minorcell merged 3 commits into1024XEngineer:mainfrom
Yumiue:main
Mar 25, 2026
Merged

fix: 修复记忆模块误写入与错误分类问题#55
minorcell merged 3 commits into1024XEngineer:mainfrom
Yumiue:main

Conversation

@Yumiue
Copy link
Copy Markdown
Collaborator

@Yumiue Yumiue commented Mar 25, 2026

背景

当前记忆模块存在两类问题,导致“记忆似乎失效”:

  1. 用户偏好类内容会被误判为 project_rule,造成长期记忆污染。
  2. 模型输出的工具调用 JSON 也会被当成正常记忆写入,导致 session/persistent memory 混入噪音。

这会影响后续记忆召回质量,让记忆统计和实际行为看起来不一致。

变更内容

  • 为记忆提取增加跳过逻辑,避免将工具调用 JSON 写入记忆
  • 收紧 project_rule 的判定条件,避免把普通用户偏好误存为项目规则
  • 保留原始 userInputassistantReply,避免只写入摘要,提升后续召回质量
  • 新增记忆模块测试,覆盖:
    • 中文偏好正确持久化与召回
    • 工具调用 JSON 不应写入记忆

影响范围

  • 长期记忆提取与持久化
  • session memory 写入逻辑
  • 记忆召回上下文质量
  • 记忆相关回归测试

测试

已执行:

  • go test ./internal/server/service -run TestMemoryService -v
  • go test ./...

备注

本次修复会阻止后续继续写入错误记忆,但不会自动清理历史脏数据。
如本地已有错误记忆,建议手动执行:

  • /clear-memory confirm

Copy link
Copy Markdown
Collaborator

@minorcell minorcell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yumiue 这部分的设计感觉很奇怪,你们再设计一下吧。

Comment on lines 493 to 497
hasQuestionIntent := containsAnyFold(trimmedUser,
"什么", "干嘛", "作用", "怎么", "如何", "why", "where", "which", "负责", "在哪", "含义", "区别")
hasExplanation := containsAnyFold(trimmedReply,
"用于", "负责", "位于", "表示", "通过", "调用", "读取", "写入", "返回", "实现", "处理", "对应", "配置", "路径", "字段", "参数")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

永远不要尝试穷举生产数据。

这部分是在干嘛?

Comment on lines 506 to 509
if !containsAnyFold(trimmed, "默认", "始终", "以后", "统一", "不要自动", "回答中文", "只用", "只使用", "只需要", "不要再", "固定", "长期") {
return false
}
return containsAnyFold(trimmed, "config.yaml", ".env", "中文", "提交", "命令", "风格", "配置")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同理

Comment on lines +546 to +559

func hasProjectRuleAnchor(text string) bool {
return containsAnyFold(text,
"config.yaml", "readme", "go test", "go build",
"cmd/", "internal/", "configs/", "services/", "memory/", "main.go",
"data/", "workspace", "工作区", "根目录", "主配置文件", "文件", "路径")
}

func hasProjectRuleSignal(text string) bool {
return containsAnyFold(text,
"项目", "仓库", "约定", "配置", "结构", "目录", "命令",
"默认", "统一", "必须", "需要", "测试命令", "构建命令")
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些也是在??

@minorcell
Copy link
Copy Markdown
Collaborator

@Yumiue 先合并了,记忆模块的设计你可以看看我给你们发的。这里的问题可以在后续的PR解决,你们可以先记录一个 issue。

@minorcell minorcell merged commit 4b051a7 into 1024XEngineer:main Mar 25, 2026
2 checks passed
phantom5099 added a commit that referenced this pull request Apr 23, 2026
fix(runtime): reconcile partial usage observation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants