dsh-plugin-memos-code-retrospect:AI 编码对话复盘蒸馏插件

前言

DSH(DeepSeek Harness)在处理编码任务时,常面临 AI 遗忘之前被否决的实现方案、重复踩坑以及丢失项目工程约束的问题。dsh-plugin-memos-code-retrospect 插件复刻了 mneme 的编码对话复盘蒸馏业务逻辑,通过提取被否决方案、踩坑记录和工程约束,解决上述问题。它不引入 mneme 二进制或创建独立数据库,而是完全复用 MemOS 记忆底座进行数据持久化。

是什么

该插件由 ai-fu-cn 维护,是一个 MIT 许可的开源插件。它通过在对话结束时(turn/end)提取被否决方案、踩坑记录和工程约束,并将其打上 type:rejected_solution 标签写入 MemOS;在编码任务推理前(agent/pre-step),对这些记忆进行加权召回并注入上下文,从而让 AI 避开历史陷阱。

核心功能

  • turn/end 蒸馏:一轮交互结束后,插件从 session.events 组装完整对话上下文(可配置截断长度),调用 LLM 提取三类实体:rejected_solution(被否决方案)、pitfall(踩坑记录)、constraint(工程约束)。
  • agent/pre-step 加权召回:Agent 推理前判断任务类型,仅对编码类任务检索 type:rejected_solution 记忆,提升权重(默认 2 倍)后注入提示词。
  • v2 健壮版:包含 LLM JSON 解析降级重试(≤1 次)、写入前相似度去重(阈值 0.82)、低价值内容过滤以及 14/14 单元测试通过。

安装与启用

  1. 前置条件:确保已安装 DSH(web profile)和 MemOS 本地插件(@memtensor/memos-local-plugin),且 Node.js 版本 >= 18。
  2. 安装插件:
    dsh plugin --profile web install https://github.com/<your-github-name>/dsh-plugin-memos-code-retrospect
  1. 注册到 DSH:将以下配置追加到 <profile>/cordis.patch.yml:
    - insert:
        - id: dsh-plugin-memos-code-retrospect
          name: './plugins/dsh-plugin-memos-code-retrospect/dist/index.js'
          config:
            enabled: true
            profileId: default
            recallEnabled: true
            captureEnabled: true
            boostFactor: 2
            recallTopK: 6
            contextMaxChars: 3000
            maxDistillContextChars: 8192
            distillMaxTokens: 2048
            distillRetries: 1
            dedupeEnabled: true
            dedupeThreshold: 0.82
            valueFilterEnabled: true
            sync_to_tencentdb: false
  1. 重启服务:
    Stop-Process -Name dsh -Force
    dsh web --port 3080
启动后日志中出现 `[retrospect]` 前缀即加载成功。

典型用法

  1. 编码任务中报错或否决方案,turn/end 后日志出现 [retrospect] distilled trace=...。
  2. 在 MemOS viewer 中检索 tags: type:rejected_solution 查看新 trace。
  3. 下一轮发起相关编码任务,pre-step 日志出现 injected rejected_solution recall,模型上下文包含 <retrospect_context>。

注意事项

  • 蒸馏质量:蒸馏质量依赖 LLM 指令跟随能力,建议 distillMaxTokens >= 2048。
  • 记忆延迟:记忆写入发生在 turn/end,本轮写入的记忆下一轮才可被召回。
  • 任务过滤:非编码任务默认不注入 type:rejected_solution 记忆,防止噪声污染(codingKeywords 可配)。
  • 扩展预留:sync_to_tencentdb 为预留扩展,本次未实现。
  • MemOS 依赖:MemOS 不可用时插件 fail-open(可加载但记忆读写失效)。
  • 数据隔离:插件只做逻辑处理,所有持久化操作全部调用 MemOS 接口,内部不保存数据;禁止拉起 mneme 子进程。
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜