feat(session): 返回 memory diff URI#2789
Merged
Merged
Conversation
0c560bc to
8a80b2b
Compare
8a80b2b to
a744eae
Compare
chenjw
approved these changes
Jun 23, 2026
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.
Description
本 PR 调整 session commit 的
memory_diff_uri暴露时机:POST /sessions/{id}/commit的即时响应仍只表示任务已 accepted,不返回memory_diff_uri;后台 Phase 2 中长记忆抽取完成后,会先检查memory_diff.json是否实际存在,存在时才在 task result 返回memory_diff_uri,方便调用方确认本次归档对应的记忆 diff 文件。长记忆抽取阶段如果没有生成任何 memory operations,也会由
SessionCompressorV2写入空结构的memory_diff.json,避免“长记忆抽取已完成但没有 diff 文件”的状态。示例:
{ "status": "accepted", "task_id": "uuid-xxx", "archive_uri": "viking://user/alice/sessions/a1b2c3d4/history/archive_001", "archived": true }任务完成后:
{ "status": "completed", "result": { "session_id": "a1b2c3d4", "archive_uri": "viking://user/alice/sessions/a1b2c3d4/history/archive_001", "memory_diff_uri": "viking://user/alice/sessions/a1b2c3d4/history/archive_001/memory_diff.json", "memories_extracted": { "memory_write": 1 } } }Related Issue
无
Type of Change
Changes Made
session.commit即时响应:不再提前返回memory_diff_uri。VikingFS.exists()确认memory_diff.json存在,再将memory_diff_uri写入 task result;execution-only、跳过长记忆抽取或文件未产出时不返回该字段。memory_diff.json生成收敛到SessionCompressorV2.extract_long_term_memories内部,并同步中英文文档与测试。Testing
已运行:
python -m py_compile openviking/session/session.py openviking/session/compressor_v2.pygit diff --check -- openviking/session/session.py openviking/session/compressor_v2.py tests/session/test_session_commit.py tests/server/test_api_sessions.py docs/en/api/05-sessions.md docs/zh/api/05-sessions.mdenv UV_CACHE_DIR=/private/tmp/openviking-uv-cache uv run python -m pytest tests/server/test_api_sessions.py::test_compress_sessionChecklist
Screenshots (if applicable)
不适用
Additional Notes
memory_diff_uri现在表示“长记忆抽取阶段已完成,并且对应 diff 文件已经实际存在”。该字段不会出现在 commit accepted 响应中,也不会在没有调度长记忆抽取或未产出 diff 文件的 task result 中返回。