跳到正文
dsh-market 浏览插件 GitHub EN

jackyytche/dsh-hindsight-memory

接入 Hindsight 长期记忆:每轮开始前自动注入相关记忆,回合结束后自动沉淀对话。

Star 数 ★ 0 分类 记忆 收录于 2026-09-03

安装

在 DeepSeek Harness 里通过 dsh-market 安装

dsh plugin --profile web add dshmarket

或使用命令行

dsh plugin --profile web add github:jackyytche/dsh-hindsight-memory

装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络。请先审阅源码,并尽量锁定 commit(github:owner/repo#sha)。

README

把 Hindsight 变成 DeepSeek Harness 的 管线级长期记忆:不暴露任何 agent 工具,模型调用前后自动完成记忆的注入与留存 (即 Hermes Agent 的 pre_llm_call / post_llm_call 钩子模式)。

运行时要求:DeepSeek Harness 0.2.0-rc.1。 插件在 package.json 中把这些 @deepseek-ai/dsh-* 包声明为 peer,profile 的兼容性 闸门会在不匹配的 dsh 上直接拒载,而不是运行期静默失灵。

工作原理

钩子 DSH 事件 行为
Auto-Recall agent/pre-step(waterfall) 每轮一次(对齐 Hermes 的 prologue 语义):仅在 turn 的第一个 LLM 调用(step 1)前,取最新用户消息(≤800 字符)作 query 调 Hindsight recall,把相关记忆作为一条 user 消息追加进步骤批次(source kind: "hindsight-memory"、form: "snapshot")。后续 step 不再召回——turn 级 WeakMap 认领(防重放),工具循环内复用 step 1 已持久化的那一块。琐碎输入跳过(对齐 Hermes is_trivial_prompt):“好的/嗯/ok/谢谢/继续”等寒暄确认及 / 斜杠命令不发起召回。
Auto-Retain session/event(observer) 每次 append 都投递一次(0.2.0-rc.1 起事件带 (session, event) 参数):按 turn/start → user/message / assistant/message → turn/end 增量累积该轮 User/Assistant 文本,turn/end 时异步 retain 入库(fire-and-forget,绝不阻塞循环),aborted 轮次跳过。
  • 标题生成、会话摘要等内务 LLM 调用不经过 agent loop,天然不受记忆注入污染。
  • 留存是 append 驱动的:被播种(resume/restore)的历史事件不会重新发布,因此 不会重复留存旧轮次。
  • 只有 source.kind === "user" 的消息被当作「人类输入」;harness 注入的上下文 (时间上下文、技能目录、system-reminder)既不作为召回 query,也不进入留存正文。
  • Hindsight 任何故障都被隔离:recall 失败 → 本步无注入;retain 失败 → 仅记日志,聊天永不中断。
  • 子 agent / fork 会话默认同样参与(includeSubagents 可关)。

设置界面

插件带浏览器半:重启后设置侧边栏会出现独立分节 设置 → Hindsight 记忆插件 (顶级条目,注册于 settings.section slot,id 为本插件的 entry id hindsight-memory),可就地编辑并保存:

控件 字段 说明
启用开关 enabled 关闭后立即停止注入与留存
API URL apiUrl Hindsight API 地址
API KEY apiKey Bearer Token,留空不认证(schema 标记 role("secret"),不会回传给浏览器)
BANK ID bankId 记忆库名,多端指向同一 bank 即可共享记忆
Recall Budget recallBudget low / mid / high 三档

每字段支持「重置」(清除用户层覆盖,回退到组合层配置值);保存失败时保留草稿可修正重试。 页面无条件注册:宿主未提供该命名空间(或插件未激活)时显示明确提示,而不是整页消失。

配置分层遵循 DSH 0.2.0-rc.1 语义:schema 默认值 ← 组合层 entry config(bundle patch / profile patch)← 用户层。本插件没有单独的设置文档,所谓「用户层」就是 profile 文档里那条 hindsight-memory entry 的 config;因为字段都声明了 volatile(),保存后下一轮即可生效,无需重启。

配置(全部可省略)

- insert:
    - id: hindsight-memory
      name: dsh-hindsight-memory
      config:
        apiUrl: http://127.0.0.1:28888       # Hindsight API
        apiKey: ""                            # 可选 Bearer token
        bankId: dsh                           # 记忆 bank
        autoRecall: true
        autoRetain: true
        recallBudget: low                     # low / mid / high
        recallTypes: [observation]            # 只注入蒸馏后的观察层
        maxQueryChars: 800
        recallTimeoutMs: 8000                 # 服务端冷启动首个 recall 可能偏慢
        maxMemories: 8
        maxBlockChars: 4000
        retainContext: conversation between the DSH agent and the user
        retainTags: [source:dsh]
        includeSubagents: true
        retainEveryNTurns: 1
        verbose: false

bundle 自带的 cordis.patch.yml 已写入 apiUrl / bankId 默认值;在 profile 的 cordis.patch.yml 里再插一条同 id 的 insert 即可覆盖任意键。

安装

dsh plugin --profile web add dsh-hindsight-memory   # 或本地路径

安装器会把包写进 profile 依赖与 dsh.profile.bundles,bundle patch 随之生效。 重启 dsh web 后,宿主日志应出现:

hindsight-memory: active (api=… bank=… enabled=true)

启动时不应再出现 warning: … plugins did not activate 或 Plugin dsh-hindsight-memory@… is incompatible with dsh …。

测试

node tests/plugin.test.mjs    # 宿主半侧:25 项(config 引用、召回、留存、节流…)
node tests/client.test.mjs    # 浏览器半侧:按 __ModuleLoader__ 契约加载并驱动 slot 注册

卸载 / 回滚

dsh plugin --profile web remove dsh-hindsight-memory

验证

  1. 新会话告诉 agent 一个事实(如「我的服务器叫 atlas」),正常聊完一轮。
  2. 打开 Hindsight UI(部署机的 29999 端口)→ bank dsh,应看到刚留存的 User: … / Assistant: … 记忆。
  3. 再开一个全新会话直接问「我的服务器叫什么」——回答应直接带上答案, 全程没有调用任何工具。

内容来自项目 README(GitHub)↗

评论

评论存放在 GitHub Discussions。用 GitHub 账号登录后可发表评论或点表情。