Skip to content

refactor(memory): 统一 V3 提取并提升会话提交与评测稳定性 - #3346

Merged
qin-ctx merged 23 commits into
mainfrom
fix/issue-3292-disable-tool-skill-memory
Aug 13, 2026
Merged

refactor(memory): 统一 V3 提取并提升会话提交与评测稳定性#3346
qin-ctx merged 23 commits into
mainfrom
fix/issue-3292-disable-tool-skill-memory

Conversation

@chenjw

@chenjw chenjw commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

背景

本 PR 最初用于处理 #3292:当前普通 Tool/Skill 记忆提取能力尚未完整支持,因此先关闭对应 schema,并统一使用 SessionCompressorV3 作为会话记忆提取实现。

在后续 LoCoMo 导入和评测过程中,又暴露出 SessionCommit 并发、Eval Cron 文件竞争、记忆链接写入锁范围不足,以及 patch 修复错误定位不准确等稳定性问题。本 PR 一并纳入这些修复。当前分支相对最新 main 共包含 22 个提交、64 个文件变更。

Fixes #3292

主要改动

1. 关闭普通 Tool/Skill 记忆提取

  • tools.yamlskills.yaml 的普通记忆 schema 设为 enabled: false
  • 保留禁用 schema 的注册和查询能力,避免配置及类型检查行为发生不必要变化。
  • 轨迹、经验和可执行 Session Skill 仍由 case 驱动;未生成 case 时不训练这些产物。

2. 统一到 SessionCompressorV3

  • 删除 SessionCompressorV2 及其专属配置、实现和测试。
  • Session 与 Service 层统一调用 SessionCompressorV3.extract_long_term_memories()
  • 将提取上下文准备、允许的记忆类型初始化、错误契约和 telemetry 收敛到 V3。
  • 更新中英文 API、概念、配置、设计及示例文档。

这是不兼容变更:外部代码如果直接导入 openviking.session.compressor_v2,升级后会导入失败。

3. 稳定记忆更新和链接写入的锁范围

  • 在申请锁前覆盖 upsert/delete 目标、替换映射、链接端点及对应目录的 .overview.md
  • 对删除文件中持久化的 links/backlinks 做二次发现;若发现锁范围扩大,则释放旧 lease 后以完整范围重新申请。
  • 最多进行 3 次范围稳定化,避免在持有旧锁时动态扩锁造成顺序反转和潜在死锁。
  • 链接过滤、URI 重映射及写入在同一受控区间内完成,并将同一 lease 传递给底层写入。
  • 补充 overview、删除替换、关系继承、重映射链接及稳定化失败等回归测试。

4. 改进 patch 修复失败诊断

  • 使用记忆文件的 plain_content() 校验 patch,避免 frontmatter 等序列化内容干扰匹配。
  • 按 block 顺序逐个应用并更新工作内容,准确报告第一个真实失败的 block。
  • 错误信息增加 block_indexreasonmatch_countfound_in_other_uris
  • 区分 not_foundnon_uniqueapply_errornot_applied,帮助模型定向修复。

5. 调整 SessionCommit 默认并发

  • 将代码默认值、配置模型、文档和 examples/ov.conf.example 中的 session_commit.max_concurrent 从 4 调整为 8。
  • 保留用户通过 ov.conf 显式覆盖该值的能力。

6. Eval 模式禁用 Cron

  • vikingbot chat --eval 不再初始化或启动 CronService
  • 避免多进程评测共同读写 jobs.json 时产生空文件和 JSONDecodeError
  • 普通单轮及交互聊天仍维持原有 Cron 行为。

7. 防止 Service 包导入环回归

  • 补充隔离进程下的 openviking.service 包导入测试。
  • 防止 QueueFS、Service 聚合导出及具体 Service 模块之间再次形成导入环。

评测结果

LoCoMo Judge 评测结果正常(排除 category=5):

Metric Value
Total rows 1,540
Graded rows 1,540
Correct 1,255
Wrong 285
Accuracy 81.49%
Avg time cost 24.42s
Avg iteration 1.24
Total prompt tokens 24,331,940
Total completion tokens 536,313
Total tokens 24,868,253
Avg prompt tokens 15,799.96
Avg completion tokens 348.26
Avg total tokens 16,148.22

变更类型

  • Bug 修复
  • 重构
  • 性能与并发调整
  • 文档更新
  • 测试更新
  • 包含不兼容变更

测试与验证

  • 为 V3 提取、禁用 Tool/Skill schema、记忆类型策略和 Session 路由补充或迁移测试。
  • 为记忆链接锁覆盖、overview 文件、删除替换及重映射关系补充回归测试。
  • 为 patch block 定位和错误原因分类补充回归测试。
  • 为 Eval 禁用 Cron、SessionCommit 默认并发和 Service 隔离导入补充测试。

本次更新 PR 说明时未在最新 rebase 后重新执行全量测试;各功能改动均包含对应的定向测试,合入前仍需以 CI 结果为准。

Human Involvement

  • 有人工参与实现、问题分析或评审过程
  • 完全由 AI Agent 生成且无人工参与

检查项

  • 已同步更新相关代码、配置示例和文档
  • 已为关键行为补充回归测试
  • 已说明 V2 删除带来的兼容性影响
  • 最新分支的完整测试套件已在本地通过

@chenjw
chenjw force-pushed the fix/issue-3292-disable-tool-skill-memory branch 2 times, most recently from d68b4e4 to 0f3e750 Compare July 18, 2026 17:07
@chenjw
chenjw marked this pull request as ready for review August 10, 2026 02:24
@chenjw
chenjw force-pushed the fix/issue-3292-disable-tool-skill-memory branch 2 times, most recently from 57c86e0 to 4bb1764 Compare August 10, 2026 12:34
@chenjw
chenjw force-pushed the fix/issue-3292-disable-tool-skill-memory branch from 74413d9 to 3633c7d Compare August 12, 2026 15:18
@chenjw chenjw changed the title refactor(memory): disable tool/skill extraction and retire compressor V2 refactor(memory): 统一 V3 提取并提升会话提交与评测稳定性 Aug 12, 2026
@qin-ctx
qin-ctx merged commit ed1bd4b into main Aug 13, 2026
5 checks passed
@qin-ctx
qin-ctx deleted the fix/issue-3292-disable-tool-skill-memory branch August 13, 2026 13:48
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: tools/skills memory extraction never produces results — design contradiction between YAML schema and context provider

2 participants