hermes-agent/tests/plugins/memory
harshitAgr 813a4e3838 fix(openviking): implement on_session_switch hook (#28296)
OpenVikingMemoryProvider only overrides on_session_end and inherits the
base-class no-op for on_session_switch. When the agent rotates session_id
(via /new, /branch, /reset, /resume, or context compression), the
provider's cached _session_id stays at the value initialize() captured.
All subsequent sync_turn writes then land in the already-closed old
session, and on_session_end tries to commit it a second time — the new
session never accumulates messages and never triggers memory extraction.

The fix mirrors the pattern Hindsight uses (#17508):

  1. Wait for any in-flight sync thread to drain under the OLD _session_id
     before we mutate it, otherwise the commit below races the last
     message write.
  2. Commit the old session if it accumulated turns — same extraction
     semantics as on_session_end. Skip if empty (nothing to extract).
  3. Drain in-flight prefetch from the old session and clear its cached
     result so the new session doesn't see stale recall.
  4. Rotate _session_id to the new value and reset _turn_count.

Commit failures are swallowed (logged at WARN) so a flaky server can't
strand the provider on the old session forever — same posture as the
existing on_session_end commit.

(cherry picked from commit a1e7185e8a)
2026-06-17 12:53:54 +08:00
..
__init__.py fix: mem0 API v2 compat, prefetch context fencing, secret redaction (#5423) 2026-04-05 22:43:33 -07:00
test_hindsight_provider.py feat(hindsight): make observation scopes configurable on retain 2026-06-15 04:59:17 -07:00
test_mem0_v2.py fix(honcho): harden self-hosted setup paths 2026-05-29 22:29:48 -07:00
test_openviking_provider.py fix(openviking): implement on_session_switch hook (#28296) 2026-06-17 12:53:54 +08:00
test_supermemory_provider.py refactor(supermemory): session-level ingest + kebab aliases (salvaged from #32487) (#38756) 2026-06-04 11:50:02 +05:30