OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Feature]: Avoid unused experience snapshot loads when reusing streaming trainers

Open loading2332 opened this issue 1 month ago • 0 comments

Issue Origin

Observed or reproduced in a real environment

Problem Statement

Area: memory / session training. On main at 1455cb1282e1b84c1e6b8af2be955c959014cd01, SessionCompressorV3.train_from_extracted_cases() loads every existing experience before looking up the process-global streaming trainer:

  1. compressor_v3.py awaits ExperienceSetLoader.load().
  2. The loader lists the experience directory and reads/parses each eligible file.
  3. get_streaming_policy_trainer() returns an existing trainer immediately when its key is already registered. The newly loaded snapshot is not used.

For repeated training calls with the same account, user and experience root, this adds one directory listing and N file reads/parses for N experiences before reusing the same trainer. This is unnecessary storage work, not a claim of incorrect extracted memories.

Reproduced locally on macOS / Python 3.12.14 through the real SessionCompressorV3.train_from_extracted_cases() and registry, using temporary Markdown files, a counting local storage adapter, and a stub analyzer returning no trajectories. Two successive calls with each directory size produced:

Experience files First call: listings / reads Reused trainer: listings / reads
10 1 / 10 1 / 10
100 1 / 100 1 / 100
1,000 1 / 1,000 1 / 1,000

This measures the redundant calls in the production Python path. It is not a server/RAGFS or real-model end-to-end benchmark, and does not establish a latency improvement.

Proposed Solution

Resolve the existing trainer before loading its initial experience snapshot. Allow the existing registry owner to load the snapshot lazily only on a miss, retaining the current registration lock and checking again after asynchronous loading so concurrent callers still receive one registered trainer.

Keep support for already-loaded snapshots. Preserve the existing key, public APIs, extraction policy, batching, and the locked reload before planning/applying updates. That authoritative reload is still required.

Alternatives Considered

  • Parallelizing the initial file reads would keep the same unused work and increase concurrent storage load.
  • Adding a separate snapshot cache would introduce invalidation and ownership questions. The existing trainer registry is sufficient for this optimization.

Feature Area

Session Management

Use Case

With Agent Evolution enabled and extracted training cases, successive commits for the same user reuse a streaming trainer. As the experience directory grows, the discarded snapshot gets increasingly expensive to load.

Additional Context

The proposed change is limited to the experience-trainer setup path. Validation should cover initial loading, reuse without snapshot I/O, independent keys, concurrent first access, load failures, and retaining the update-time reload.

Contribution

  • [x] I am willing to contribute to implementing this feature

loading2332 avatar Oct 20 '26 11:10 loading2332