hermes - 💡(How to fix) Fix bug(memory): OpenViking plugin never updates _session_id on session rotation (/new, /reset, /resume) [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

The base class MemoryProvider at agent/memory_provider.py:199 defines on_session_switch() as a no-op with explicit documentation:

"Providers that cache per-session state in initialize() (_session_id, _document_id, accumulated turn buffers, counters) should update or reset that state here so subsequent writes land in the correct session's record."

The OpenViking provider caches self._session_id in initialize() at line 475 and increments _turn_count in sync_turn() at line 573, but never overrides on_session_switch() to keep these in sync after session rotation.

Fix Action

Fixed

Code Example

def on_session_switch(
    self,
    new_session_id: str,
    *,
    parent_session_id: str = "",
    reset: bool = False,
    **kwargs,
) -> None:
    if not new_session_id:
        return
    self._session_id = new_session_id
    if reset:
        self._turn_count = 0
RAW_BUFFERClick to expand / collapse

Bug Description

The OpenViking memory plugin (plugins/memory/openviking/__init__.py) fails to implement MemoryProvider.on_session_switch(), causing self._session_id to become permanently stale after any agent session rotation. All subsequent sync_turn() writes and the final on_session_end() commit target the original session ID instead of the new one, silently corrupting the session data on the OpenViking server.

Impact

After using /new, /reset, /resume, /branch, or undergoing context compression in a session that uses the OpenViking memory provider:

  1. All turn-level messages (sync_turn) are written to the previous session on the OpenViking server
  2. The final commit (on_session_end) commits the wrong session, leaving the current session's data invisible in OpenViking
  3. The current session appears to have zero messages in OpenViking since its session_id was never used
  4. Previously committed sessions get "updated" with the new session's data, corrupting their records

In one observed case, a session with 172 messages was never created on the OpenViking server, while the preceding orphaned session was double-committed with 8 accumulated turns.

Root Cause

The base class MemoryProvider at agent/memory_provider.py:199 defines on_session_switch() as a no-op with explicit documentation:

"Providers that cache per-session state in initialize() (_session_id, _document_id, accumulated turn buffers, counters) should update or reset that state here so subsequent writes land in the correct session's record."

The OpenViking provider caches self._session_id in initialize() at line 475 and increments _turn_count in sync_turn() at line 573, but never overrides on_session_switch() to keep these in sync after session rotation.

Steps to Reproduce

  1. Configure Hermes with memory.provider: openviking
  2. Start a CLI session (Session A)
  3. Type /new to create Session B
  4. Send several messages in Session B
  5. Type /new again to create Session C
  6. Observe that Session B's messages were never committed to OpenViking, while Session A was double-committed with Session B's data appended

Expected Behavior

Each session's messages should be written to and committed under the correct session_id on the OpenViking server, regardless of session rotation events.

Proposed Fix

Override on_session_switch() in the OpenViking provider to update self._session_id and, when reset=True, reset _turn_count to 0:

def on_session_switch(
    self,
    new_session_id: str,
    *,
    parent_session_id: str = "",
    reset: bool = False,
    **kwargs,
) -> None:
    if not new_session_id:
        return
    self._session_id = new_session_id
    if reset:
        self._turn_count = 0

I have verified this fix locally — it resolves the issue by ensuring all subsequent writes land in the correct session's record.

Environment

  • Hermes agent version: Current main (June 2026)
  • OpenViking server: v0.3.3 (localhost)
  • OS: Linux (Ubuntu)
  • Reproduced on: CLI interactive mode with /new command

Additional Context

The bug is exclusively in the Hermes OpenViking plugin — the OpenViking server itself handles the API correctly. Other memory providers (Honcho, Hindsight) likely have similar issues since they also override on_session_switch — but this was only verified for OpenViking.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix bug(memory): OpenViking plugin never updates _session_id on session rotation (/new, /reset, /resume) [1 pull requests]