feat(hermes): MSLM Hermes MemoryProvider — 原生插件集成#7
Merged
Conversation
- 实现 is_available() 带优雅的 ImportError 处理 - 添加 get_config_schema() 暴露 4 个配置项 - 添加 _parse_bool() 类型安全的 YAML 布尔解析 - 添加 _load_hermes_config() 读取 Hermes 配置覆盖
- 添加 daemon thread + 30s 超时保护 engine.initialize() - 添加 _init_cancelled 标志用于超时后的优雅清理 - 添加 cron/flush 上下文跳过(_cron_skipped) - 添加 create_speaker_entities 非致命错误处理 - 添加 _ensure_engine() 健康检查方法 - 添加 shutdown() 资源清理等待后台线程
- Turn 1: 同步 engine.recall() 首次获取 - 后续 Turn: 消费 _prefetch_cache 来自上一轮 queue_prefetch - 添加 queue_prefetch() daemon thread 后台 recall - 添加 _prefetch_lock 线程安全保护缓存读写 - 添加 _format_recall_results() prompt 注入格式化 - 添加 _sync_recall() 异常安全包装
- 添加 sync_turn() 合并存储,语义过滤噪声回复,4000 字符截断 - 添加 _sync_turn_lock 防止 is_alive() 检查和 thread.start() 竞态 - 添加 _write_lock 共享锁保护所有写路径 - 添加 on_memory_write() 内置 memory 镜像到 MSLM - 添加 on_pre_compress() 存储最后 10 条消息,返回空字符串 - 添加 on_session_end() 调用 engine.close_session() - 添加 on_session_switch() 更新 session_id 并清空 prefetch 缓存
- 添加 get_tool_schemas() 返回 3 个工具的 OpenAI 格式 schema - 添加 handle_tool_call() 异常安全的路由处理 - 添加 _tool_recall() 带 limit 截断和 scope 支持 - 添加 _tool_remember() 带 scope 参数校验 (personal/global) - 添加 _tool_status() 查询 engine.db 的 v1 统计信息 - 添加 system_prompt_block() 含动态 profile/mode/fact_count
- 添加 plugin.yaml 含 hooks 和 pip_dependencies - 添加 register() 函数供 Hermes 插件发现 - 添加集成测试覆盖完整 session 生命周期 - 添加并发读写安全验证 - 添加 provider 禁用后的优雅降级验证
- _tool_remember 的 engine.store() 纳入 _write_lock 保护 - initialize() 每次启动前重置 _init_cancelled 标志
- register() 支持 register_memory_provider() 和 register_provider() 两种 ctx - 测试中 mock _load_hermes_config 防止读取真实配置
两处 SQL 查询使用 self._slm_config.active_profile(会被 MemoryEngine.initialize() 覆盖为 "default"),导致 DB 有数据但 返回 facts=0。 改为 self._mslm_profile(由 hermes config 明确设置,值正确)。 Closes #5
db.execute() 返回的是 list[Row] 而非 sqlite3 cursor,调用 .fetchone() 会抛出 AttributeError,被 except Exception: pass 静默吞掉,导致所有 指标返回 0。 改为直接使用 rows[0][0] 索引。 Closes #6
- getting-started-en.md / zh.md: version 输出改为 4.1.0+ - upstream-contribution-strategy.md: 发布状态更新为 4.1.0(基于 v3.6.16)
- getting-started: 加 4.5 Hermes MemoryProvider 插件方式(推荐) - configuration: 加 memory.provider 的 Hermes 配置节 - multi-scope-memory: 加 Hermes 中 scope 参数使用示例 - memory-import-guide: 加方式四:Hermes MemoryProvider 导入 - README: 功能列表加 Hermes MemoryProvider 插件特性 10 文件,中英文全覆盖。
Bug fixes (from PR #7 review): - _tool_remember: accept 'shared' scope (was silently downgraded to personal) - _tool_remember: extract and pass shared_with param to engine.store() - _REMEMBER_SCHEMA: add 'shared' to enum + shared_with property - system_prompt_block: document shared scope in tool description Version updates: - README-zh/en: v4.0.0 → v4.1.0 - plugin.yaml: mslm-memory>=4.0.0 → >=4.1.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
为 MSLM 添加 Hermes Agent 原生 MemoryProvider 插件,使 Hermes 无需 MCP 即可直接使用 MSLM 记忆系统。
变更
核心功能
src/superlocalmemory/integrations/hermes/__init__.py— SuperLocalMemoryProvider(~830 行)plugin.yaml— Hermes 插件声明register()— 兼容 Hermes_ProviderCollectorslm_recall/slm_remember/slm_statussync_turn自动预取相关记忆initialize()带超时保护与取消标志Bug 修复(来自 zhihui 线上使用反馈)
_tool_status/system_prompt_block使用正确的mslm_profiledb.execute()返回list[Row]而非 cursor,修复.fetchone()→ 直接索引文档
使用方式
测试