Skip to content

OpenVikingMemoryProvider missing on_session_switch — session ID goes stale after /new #28296

@numuly

Description

@numuly

Description:

plugins/memory/openviking/__init__.py implements on_session_end() but does not override on_session_switch(), whose base class default is a no-op.

When the agent rotates its session_id (via /new, /branch, context compression), _session_id inside the provider stays at the original value. All subsequent sync_turn() writes land in the already-committed old session, and on_session_end() tries to commit the same old session again. The new session never accumulates messages, so commit never triggers memory extraction for it.

Other providers like Hindsight already implement this hook correctly — OpenViking just missed it.

Fix approach:

Add an on_session_switch() override between on_session_end() and on_memory_write() that:

  1. Waits for any in-flight sync thread
  2. Commits the old session if it has pending turns
  3. Updates _session_id to the new session
  4. Resets _turn_count and clears stale prefetch cache

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/pluginsPlugin system and bundled pluginstool/memoryMemory tool and memory providerstype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions