接入 Hindsight 长期记忆:每轮开始前自动注入相关记忆,回合结束后自动沉淀对话。需要 DSH ^0.2.0-rc.1(已在 0.2.0-rc.2 验证)。
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:jackyytche/dsh-hindsight-memory
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 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
验证
- 新会话告诉 agent 一个事实(如「我的服务器叫 atlas」),正常聊完一轮。
- 打开 Hindsight UI(部署机的 29999 端口)→ bank
dsh,应看到刚留存的User: … / Assistant: …记忆。 - 再开一个全新会话直接问「我的服务器叫什么」——回答应直接带上答案, 全程没有调用任何工具。
链接
同类插件
vectorize-io/hindsight#coding-agents★ 51291
Hindsight:会学习的 Agent 长期记忆系统,自动召回/保存、知识页、深度反思与按仓库隔离的记忆银行。
volcengine/OpenViking#examples/dsh-memory-plugin★ 40273
面向 DeepSeek Harness 的 OpenViking 记忆与上下文插件:pre-step 自动召回与画像注入、会话捕获、`viking://` URI 防护,以及对接 OpenViking 服务端的 recall/write 记忆工具。
agentscope-ai/ReMe#dsh★ 3646
将 DeepSeek Harness 接入 ReMe 本地优先、自进化的个人知识库:自动把已完成的主 Agent 对话沉淀为用户掌控的 Markdown 记忆,通过 reme_search 结合 BM25、可选向量检索和 wikilink 展开搜索对话与资料,并按日整理长期记忆。
zilliztech/memsearch#MemSearch★ 2759
供 DSH 与其他编程 Agent 共享的 Markdown 记忆,支持自动捕获、步骤前上下文注入、搜索召回,以及通过审阅面板实现 memory-to-skill 自进化。
vshulcz/deja-vu#extensions/dsh★ 1244
读取本机上其他三十三个编程智能体已经写下的会话文件——Claude Code、Codex、Cursor、VS Code Copilot Chat、opencode、OpenClaw、Hermes、Kimi、Cline、Zed 等,包括安装之前的历史:提供 deja_recall、deja_session、deja_blame、deja_fix、deja_how、deja_remember 六个工具与 /deja 命令,并可选地把召回结果加入运行时上下文。本地 BM25 索引,不用大模型,不用向量嵌入,不联网(dsh plugin --profile web add dsh-deja)。
adoresever/graph-memory★ 655
DeepSeek Harness 的可追溯、可检索跨会话记忆:把对话知识沉淀为带类型的图节点(任务/技能/事件)与关系边。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。