OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

fix(session): pass ctx/user/session_id into async commit memory extraction

Open dddgogogo opened this issue 8 months ago • 0 comments

Summary

Session.commit_async() calls extract_long_term_memories() without passing user, session_id, and ctx.

Because SessionCompressor.extract_long_term_memories() returns early when ctx is missing, async session commit can archive successfully but still produce memories_extracted = 0.

Affected code

Current code in openviking/session/session.py:

memories = await self._session_compressor.extract_long_term_memories(
    messages=messages_to_archive,
)

But openviking/session/compressor.py contains:

if not ctx:
    return []

So the async commit path can return zero extracted memories even when the archived messages clearly contain extractable long-term memory.

Expected behavior

Session.commit_async() should pass the same context information as the normal extraction flow:

memories = await self._session_compressor.extract_long_term_memories(
    messages=messages_to_archive,
    user=self.user,
    session_id=self.session_id,
    ctx=self.ctx,
)

Reproduction

  1. Create a session
  2. Add a clearly extractable preference or unique fact
  3. Call POST /api/v1/sessions/{id}/commit
  4. Observe memories_extracted = 0

Example message pair:

  • user: 以后所有回复都用中文,默认简洁直接。
  • assistant: 收到,后续我会默认用中文并保持简洁直接。

Evidence

I verified this locally in two ways:

  1. Directly calling MemoryExtractor.extract(...) on a minimal example returns valid candidates.
  2. Running the same content through the HTTP session commit path returned memories_extracted = 0 before restoring the missing arguments.

After restoring user=self.user, session_id=self.session_id, and ctx=self.ctx, the same HTTP commit path returned memories_extracted = 1, and the memory file was actually written to disk.

Regression source

This looks like a regression introduced after feat(sessions): add async commit support with wait parameter (#472).

  • The earlier async implementation in commit 9c4f419 passed user, session_id, and ctx.
  • The current broken call appears after commit 20b5dab (Revert "feat(resource): implement incremental update with COW pattern (#535)" (#584)), where those arguments are no longer passed.

Impact

This affects integrations that rely on OV session commit for long-term memory extraction, including OpenClaw / memory-openviking style flows.

dddgogogo avatar Mar 14 '26 16:03 dddgogogo