dsh-experience

dsh-experience

Provides a cross-session experience knowledge base for AI agents, enabling retrieval of past problem-solution experiences via MCP tools. It helps agents reuse solutions without retraining, with zero-LLM runtime retrieval.

Category
Visit Server

README

dsh-experience

CI license MCP

一个跨会话经验知识库(自主进化)。它把 agent 在任务中踩过的坑、探索出的解决方案, 沉淀成可复用的"问题 → 解决方案"经验,让模型在新会话遇到类似问题时检索并复用—— 不重新训练,越用越强。

对应前沿:WebCoach(arXiv 2511.12997)的跨会话记忆三组件;Evo-Memory 的 test-time evolution 思想。数据源是 DSH 已有的 session 日志。

三组件(对应 WebCoach)

组件 文件 作用
Condenser(压缩) extract.mjs 把会话轨迹压缩成"问题→解决方案"经验(离线,用 flash)
Memory Store(存储) store.mjs + experience.jsonl 持久化经验库
Coach(检索) index.mjs(MCP 工具) 新会话遇到问题,检索相关经验(零 LLM)

核心原则

  • 运行时零 LLM:检索默认是纯词法(IDF 加权 + 中文 bigram),查询时不花任何 token;
  • 可选本地语义检索:启动本地 embedding 服务(见下)后,检索升级为语义匹配 (bge-large-zh,本地 GPU/CPU,零云端成本),解决同义词/表述差异;服务未启动时 自动降级词法;
  • 离线才用大模型:只有 extract.mjs 提取经验时调 flash(批量、事后);
  • 自主进化:extract.mjs + add_experience 持续沉淀,库随任务增长;重复经验自动去重。

语义检索(可选,本地 embedding)

缓存里若已有 BAAI/bge-large-zh-v1.5(或联网可下载),启动本地服务:

python embed-server.py          # 默认 127.0.0.1:8001,需 transformers+torch

store.mjs 检测到该服务后,检索从"词法"自动升级为"语义"(bge 中文 embedding + query/doc 分离 + 余弦相似度,阈值 0.45 过滤无关,recency 微调);服务挂了则回退词法。

用法

1. 离线提取经验(唯一用大模型的地方)

node extract.mjs --latest    # 从最新会话提取
node extract.mjs --all       # 从所有会话提取
node extract.mjs <sessionDir> # 指定会话目录

2. 运行时检索(MCP 工具)

index.mjs 挂进 DSH(见下方),agent 遇到问题时可调:

mcp__experience__search_experience("git push GitHub TLS 超时怎么办")
  → 返回过去会话里解决过这个问题的经验

其余工具:add_experience(手动沉淀)、list_experiences(浏览)。

挂进 DSH

cordis.patch.ymlinsert: 里加:

- id: mcp-experience
  name: '@deepseek-ai/dsh-mcp-client'
  config:
    serverName: experience
    transport: stdio
    command: '<node 路径>'
    args:
      - '<本目录>/index.mjs'

经验条目结构

{
  "id": "…",
  "problem": "问题一句话",
  "solution": "解决方案(含命令/文件/配置细节)",
  "keywords": ["关键词"],
  "sourceSession": "session-…",
  "createdAt": "ISO"
}

诚实局限

  • "Coach mode" 自动注入尚未实现:当前是"工具触发"检索——agent 遇到问题时主动search_experience。完整闭环("工具失败 → 自动检索 → 注入短暂建议 → 成功后提取")需要 harness hook(execute.after / PostToolUseFailure),尚未接入;
  • 并发:写入已用进程内锁 + 原子改名 + 唯一临时名,单进程安全;但多进程共享同一份 experience.jsonl 仍可能丢更新,生产级应换成 SQLite + WAL;
  • 语义检索依赖本地 Python 服务:embed-server.py(bge-large-zh)未启动时自动降级为词法, 但词法对同义改写、跨语言召回弱;本地 embedding 服务有部署门槛;
  • 提取用 flash:extract.mjs 离线批量提取时调 DeepSeek flash,提取质量受模型能力限制; 且只在成功恢复后提取才有意义——失败的尝试不该污染经验库。

测试

node test.mjs(分词 / 检索 / 持久化 / 并发写不丢更新)。

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured