mcpField
C
continual-learning

continual-learning

github.com/microsoftAgent 工作流3.2k80 次安装1 天前更新
代码仓库

关于 continual-learning

continual-learning 帮助编码 Agent 在不同会话间保留有用经验。钩子自动捕捉工具结果,并以全局和仓库本地的 SQLite 存储区分经验,清理过期条目。

主要功能

  1. 01通过钩子自动捕捉经验
  2. 02全局与仓库本地记忆
  3. 03Agent 使用 SQL 写入经验
  4. 04可读的记忆文件
  5. 05按时间和使用情况清理

适用场景

  1. 01跨会话保留工具失败模式
  2. 02跨项目共享编码偏好
  3. 03记录仓库特定约定
  4. 04清理过期经验条目

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/microsoft/skills --skill continual-learning

安装后在 Claude Code 中输入/continual-learning确认已加载。

详细介绍

AI 编码 Agent 的持续学习

你的 Agent 会在会话之间忘记所有内容。持续学习可以解决这个问题。

循环

Experience → Capture → Reflect → Persist → Apply
     ↑                                       │
     └───────────────────────────────────────┘

快速开始

安装钩子(一步即可):

cp -r hooks/continual-learning .github/hooks/

首次会话时自动初始化。无需配置。

双层记忆

全局(~/.copilot/learnings.db)——在你的所有项目中通用:

  • 工具模式(哪些工具会失败,哪些能正常工作)
  • 跨项目约定
  • 通用编码偏好

本地(.copilot-memory/learnings.db)——仅在此仓库中保留:

  • 项目特定约定
  • 此代码库中的常见错误
  • 团队偏好

学习内容的存储方式

自动存储(通过钩子)

钩子会观察工具的执行结果并检测失败模式:

Session 1: bash tool fails 4 times → learning stored: "bash frequently fails"
Session 2: hook surfaces that learning at start → agent adjusts approach
Agent 原生存储(通过 store_memory / SQL)

Agent 可以直接写入学习内容:

INSERT INTO learnings (scope, category, content, source)
VALUES ('local', 'convention', 'This project uses Result<T> not exceptions', 'user_correction');

类别:pattern、mistake、preference、tool_insight

手动存储(记忆文件)

用于人类可读、受版本控制的知识:

# .copilot-memory/conventions.md
- Use DefaultAzureCredential for all Azure auth
- Parameter is semantic_configuration_name=, not semantic_configuration=

清理

学习内容会随时间衰减:

  • 删除超过 60 天且命中次数较少的条目
  • 高价值学习内容(频繁被引用)会永久保留
  • 工具日志会在 7 天后清理

这样可以防止内容无限增长,同时保留重要信息。

最佳实践

  1. 一步安装——如果安装过程比 cp -r 还复杂,就不会有人采用
  2. 正确设定范围——工具模式使用全局范围,项目约定使用本地范围
  3. 具体明确——"Use semantic_configuration_name=" 胜过 "use the right parameter"
  4. 让改进不断累积——每次会话的小幅改进,几周后就会带来指数级收益

评论

支持 Markdown