Skip to content

fix: 修复 #3182 和 #3828,新增 MemoryHook 长期记忆增强#4007

Open
gvaiis wants to merge 1 commit intoagentscope-ai:mainfrom
gvaiis:fix/memory-hooks
Open

fix: 修复 #3182 和 #3828,新增 MemoryHook 长期记忆增强#4007
gvaiis wants to merge 1 commit intoagentscope-ai:mainfrom
gvaiis:fix/memory-hooks

Conversation

@gvaiis
Copy link
Copy Markdown

@gvaiis gvaiis commented May 2, 2026

修复内容

Bug 修复

  1. [Bug] memory_search 向量索引从未构建 - rebuild_memory_index_on_start 未生效 #3182 - ReMeLightMemoryManager.start() 未被调用,导致向量索引从未构建,memory_search 始终返回空结果
  2. config.json 中 agents.running 与 agent.json 配置不同步,导致 Web UI 配置“丢失” #3828 - Web UI 的 embedding 配置写入 config.json 后未同步到 agent.json,导致配置不生效

新功能:MemoryHook

在 QwenPaw 的 Hook 机制基础上新增 MemoryHook,实现类似 OpenClaw memory-lancedb-pro 插件的核心功能:

功能 说明
自动检索注入 pre_reasoning 钩子,每次推理前自动搜索 LanceDB 相关记忆并注入上下文
自动存储 post_reply 钩子,每次回复后自动处理对话内容
LLM 智能提取 调用 LLM 分析对话,按 profile/preference/entity/event/case/pattern 6类提取
智能遗忘 Weibull 衰减模型,超过阈值自动清理低分老旧记忆
多范围隔离 按 scope_type/scope_id 隔离不同 Agent/用户/项目的记忆
混合检索 向量搜索 + BM25 关键词融合排序

文件改动

配置方式

用户通过 Web UI(运行配置 → 长期记忆)填写 embedding API 信息即可启用,无需手动修改配置文件。


变更类型

受影响的组件

  • ⚙️ Core / Backend

检查清单

  • 已运行 pre-commit run --all-files(本地环境不支持 pre-commit)
  • 已运行相关测试(本地功能验证通过)
  • 已更新文档(README 已更新)

测试方法

  1. 在 Web UI「运行配置 → 长期记忆」填写 embedding 配置
  2. 重启 QwenPaw
  3. 验证 LanceDB 数据自动存储(projects/Yunding_EA/vector_memory/memories.lance
  4. 验证 memory_search 能返回结果(修复 [Bug] memory_search 向量索引从未构建 - rebuild_memory_index_on_start 未生效 #3182
  5. 验证 pre_reasoning 钩子自动检索并注入记忆
  6. 验证 post_reply 钩子自动提取并存储

本地验证证据


变更类型

受影响的组件

  • ⚙️ Core / Backend

检查清单

  • 已运行 pre-commit run --all-files(本地环境不支持 pre-commit)
  • 已运行相关测试(本地功能验证通过)
  • 已更新文档(README 已更新)

测试方法

  1. 在 Web UI「运行配置 → 长期记忆」填写 embedding 配置
  2. 重启 QwenPaw
  3. 验证 LanceDB 数据自动存储(projects/Yunding_EA/vector_memory/memories.lance
  4. 验证 memory_search 能返回结果(修复 [Bug] memory_search 向量索引从未构建 - rebuild_memory_index_on_start 未生效 #3182
  5. 验证 pre_reasoning 钩子自动检索并注入记忆
  6. 验证 post_reply 钩子自动提取并存储

本地验证证据

…- 修复 agentscope-ai#3182:ReMeLightMemoryManager.start() 未调用,向量索引不构建 - 修复 agentscope-ai#3828:UI 配置写入 config.json 后未同步到 agent.json - 新增 MemoryHook:pre_reasoning 自动检索 + post_reply 自动存储 - 新增 LLM 智能提取:用 LLM 分析对话,6分类存储 - 新增 Weibull 智能遗忘:自动清理低分老旧记忆 - 新增多范围隔离:按 scope_type/scope_id 隔离数据 - 新增混合检索:向量搜索 + BM25 关键词融合
@github-project-automation github-project-automation Bot moved this to Todo in QwenPaw May 2, 2026
@github-actions github-actions Bot added the first-time-contributor PR created by a first time contributor label May 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

欢迎来到 QwenPaw! 🐾 Welcome to QwenPaw!

你好 @gvaiis,感谢你提交的第一个 Pull Request!🎉
Hi @gvaiis, thank you for your first Pull Request! 🎉

📋 关于 Pull Request 模板 / About PR Template

为了帮助维护者更快地审查你的 PR,请确保包含以下信息:
To help maintainers review your PR faster, please make sure to include:

  • 描述 / Description - 说明这个 PR 做了什么以及为什么 / What this PR does and why
  • 变更类型 / Type of Change - Bug fix / Feature / Breaking change / Docs / Refactoring
  • 影响的组件 / Component(s) Affected - Core / Console / Channels / Skills / CLI / Docs / Tests / CI/CD
  • 检查清单 / Checklist:
    • 运行 pre-commit run --all-files 并通过 / Run and pass pre-commit run --all-files
    • 运行相关测试并通过 / Run and pass relevant tests
    • 更新文档(如需要)/ Update docs if needed
  • 测试方法 / Testing - 如何测试这些变更 / How to test these changes
  • 本地验证证据 / Local Verification Evidence:
    pre-commit run --all-files
    # paste summary result
    
    pytest
    # paste summary result

完整的 PR 信息可以加快审查速度。你可以编辑 PR 描述来补充这些内容。
Complete PR information helps speed up the review process. You can edit the PR description to add these details.

🙌 加入开发者社区 / Join Developer Community

非常感谢你的贡献!我们诚挚地邀请你加入 QwenPaw 官方开发者群!
Thanks so much for your contribution! We'd love to invite you to join the official QwenPaw developer group!

你可以在我们的文档页面的 "Developer Community" 部分找到 Discord 和钉钉群链接:
You can find the Discord and DingTalk group links under the "Developer Community" section on our docs page:
https://qwenpaw.agentscope.io/docs/community

我们真诚地感谢你的热情,也期待你未来的更多贡献!😊
We truly appreciate your enthusiasm—and look forward to your future contributions! 😊

我们会尽快审查你的 PR。
We'll review your PR soon.


Tip

⭐ 如果你觉得 QwenPaw 有帮助,请给我们一个 Star!

⭐ If you find QwenPaw useful, please give us a Star!

Star QwenPaw

掌握最新动态 / Staying ahead

在 GitHub 上 Star QwenPaw,第一时间收到新版本发布通知。

Star QwenPaw on GitHub and be instantly notified of new releases.

你的 star 将帮助更多开发者发现这个项目!🐾

Your star helps more developers discover this project! 🐾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time-contributor PR created by a first time contributor

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant