Skip to content

Feat/自进化(经验记忆)框架重构#2503

Merged
qin-ctx merged 194 commits into
mainfrom
feat/memory_train
Jul 3, 2026
Merged

Feat/自进化(经验记忆)框架重构#2503
qin-ctx merged 194 commits into
mainfrom
feat/memory_train

Conversation

@chenjw

@chenjw chenjw commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Description

  1. 记忆导入并行化,降低锁粒度(两阶段合并),locomo导入可降低到15分钟(locomo 80.78%)
  2. 自进化框架重构, 提供离线训练框架和rollout service的对接(参见:https://github.com/volcengine/OpenViking/discussions/2533)
  3. 按照新框架重构tau2的评测方案,参见:benchmark/tau2/train/README.md,
  4. 加入case定义(类似skillx里面的plan skill),提取记忆时先提取到case(任务意图),才会进一步提取traj和exp记忆。
  5. tau2的经验加载改成skill渐进方式(llm决策去检索case,返回case关联的exp的situation和链接,然后由模型决策去read exp原文)
  6. 训练框架加入进度条,并result目录提供完整的运行日志(结合debug_trace工具,可供llm来分析badcase原因)
  7. traj和exp记忆模板还在持续调整中,目前经验记忆的效果对齐还没有完全稳定,先提交一版后续继续对齐。

Related Issue

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

Additional Notes

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🏅 Score: 70
🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 Multiple PR themes

Sub-PR theme: Add streaming memory updater and compressor V3

Relevant files:

  • openviking/session/memory/streaming_memory_updater.py
  • openviking/session/compressor_v3.py
  • tests/session/memory/test_streaming_memory_updater.py
  • tests/session/test_compressor_v3.py
  • tests/integration/test_compressor_v3_case_extraction.py

Sub-PR theme: Add training framework and patch merge context provider

Relevant files:

  • openviking/session/train/**/*.py
  • tests/session/train/**/*.py
  • tests/session/memory/test_patch_merge_context_provider.py

⚡ Recommended focus areas for review

Missing VLM parameter for training components

The ExperienceGradientEstimator and PatchMergePolicyOptimizer are initialized without the required 'vlm' parameter, which will prevent them from functioning correctly (as seen in the test file where 'vlm' is explicitly provided).

gradient_estimator=ExperienceGradientEstimator(
    viking_fs=viking_fs,
),
policy_optimizer=PatchMergePolicyOptimizer(
    viking_fs=viking_fs,
    memory_type="experiences",
),
Silent exception handling without logging

The MemoryFileUtils.write call is wrapped in a broad exception handler that falls back to operation_after_content without logging the failure, which will make debugging issues difficult.

    )
except Exception:
    return operation_after_content(op)
Potential incorrect VLM instance retrieval

The code calls get_vlm_instance() on get_openviking_config().vlm, but test files use get_openviking_config().vlm directly as the VLM instance. This could cause an AttributeError if config.vlm is already the instance.

vlm = get_openviking_config().vlm.get_vlm_instance()

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Add missing VLM instance to policy gradient/optimizer

The ExperienceGradientEstimator and PatchMergePolicyOptimizer are likely missing a
required VLM instance (as seen in the test file). Retrieve the VLM from the
openviking config and pass it to both initializers.

openviking/session/compressor_v3.py [389-395]

+config = get_openviking_config()
+vlm = config.vlm.get_vlm_instance()
 gradient_estimator=ExperienceGradientEstimator(
     viking_fs=viking_fs,
+    vlm=vlm,
 ),
 policy_optimizer=PatchMergePolicyOptimizer(
     viking_fs=viking_fs,
+    vlm=vlm,
     memory_type="experiences",
 ),
Suggestion importance[1-10]: 7

__

Why: The test files show that ExperienceGradientEstimator and PatchMergePolicyOptimizer require a vlm parameter for proper operation, and the codebase already uses get_openviking_config().vlm.get_vlm_instance() to retrieve the VLM elsewhere, making this a likely missing initialization issue.

Medium
General
Remove unnecessary field() usage from non-dataclass

The SessionCompressorV3 class is using field() for class attributes but is not
decorated with @dataclass. This is misleading because field() only works with
dataclasses. Remove the field() usage since the init method properly initializes
these attributes.

openviking/session/compressor_v3.py [74-80]

 class SessionCompressorV3:
     """Session compressor with lock-free patch-merge user memory extraction."""
 
     rollout_analyzer: TrajectoryRolloutAnalyzer | Any
-    streaming_trainer_config: StreamingPolicyTrainerConfig = field(
-        default_factory=StreamingPolicyTrainerConfig
-    )
-    streaming_memory_updater_config: StreamingMemoryUpdaterConfig = field(
-        default_factory=StreamingMemoryUpdaterConfig
-    )
+    streaming_trainer_config: StreamingPolicyTrainerConfig
+    streaming_memory_updater_config: StreamingMemoryUpdaterConfig
Suggestion importance[1-10]: 5

__

Why: The SessionCompressorV3 class is not a dataclass, so using field() for class attributes is misleading and unnecessary, as __init__ properly initializes them. Removing the field()` usage improves code clarity.

Low

@chenjw chenjw changed the title Feat/memory train Feat/自进化(经验记忆)框架重构 Jun 30, 2026
@chenjw chenjw marked this pull request as ready for review June 30, 2026 04:28

@qin-ctx qin-ctx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这次 review 只发布 inline findings。结论:REQUEST_CHANGES。前三条是 blocking,后面三条是 non-blocking,但都建议在这个大 PR 合入前处理或明确取舍。

Comment thread benchmark/locomo/vikingbot/import_to_ov.py
Comment thread openviking/session/memory/patch_merge_context_provider.py Outdated
Comment thread openviking_cli/utils/config/memory_config.py
Comment thread openviking/session/memory/utils/streaming_batcher.py
Comment thread openviking/session/compressor_v3.py Outdated
Comment thread openviking/session/memory/streaming_memory_updater.py Outdated
Comment thread openviking/session/compressor_v3.py
Comment thread openviking/message/message.py Outdated

@qin-ctx qin-ctx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这次 review 结论是 REQUEST_CHANGES。

整体方向是合理的:V3 把抽取、patch merge、训练和 rollout 拆开,并通过 streaming batch 降低锁粒度;之前几条历史 blocking 评论我也重新核过,大多已经修掉。

历史评论追踪:

  • locomo import 的 canonical sample id 问题已修,并补了覆盖 peer wiring 的测试。
  • patch merge hidden fields 已补 last_update_trace_id
  • case 到 experience 的 root uri fallback 已改为显式报错。
  • no-op merge fast path 已改为比较 render 后内容。
  • memory.version 现在代码和文档都说明已废弃且强制 v3;建议 PR 模板里补上变更类型和测试说明。

我在 PR 快照上跑了 python -m compileall -q openviking benchmark/locomo/vikingbot benchmark/tau2 bot/vikingbot tests/session tests/unit tests/integration,没有语法错误。

需要先修已发出的两条 inline 问题,尤其是 batch result 泄漏到单个 session archive 的阻塞问题。

@qin-ctx qin-ctx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本次只发布必须修复项:

  1. streaming memory updater 的 batch aggregate result 仍未按 submitter/session 隔离,可能导致跨 session 的 memory diff/context/case 串写。
  2. remote rollout 的 policy_set metadata 会携带 OpenViking API key,存在凭证外泄风险。

建议修复后再合入。

Comment thread openviking/session/compressor_v3.py
Comment thread openviking/session/train/batch_runner.py

@qin-ctx qin-ctx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

发现 1 个 blocking 问题:case 训练输入在 patch merge 前固定,可能和最终落库的 canonical case 不一致。

Comment thread openviking/session/compressor_v3.py Outdated
@qin-ctx qin-ctx merged commit fd73dcf into main Jul 3, 2026
10 checks passed
@qin-ctx qin-ctx deleted the feat/memory_train branch July 3, 2026 03:27
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Jul 3, 2026
ZaynJarvis pushed a commit that referenced this pull request Jul 3, 2026
* fix(server): restore identity resolution in /health endpoint

The /health endpoint was refactored in #2503 which removed the identity
resolution logic. This caused the frontend dashboard to show 'Usage/Audit
未初始化' because the role field was missing from the response.

Restored the identity resolution so that /health returns account_id,
user_id, and role when an API key is provided.

Co-Authored-By: Claude <noreply@anthropic.com>

* test(server): update health endpoint tests for identity resolution

- Test that /health returns identity info when API key is provided
- Test that /health omits identity info when no API key is provided

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: wugj <wugj@g-bits.com>
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants