Skip to content

/new and /reset commands don't trigger OpenViking session commit #7759

@happy5318

Description

@happy5318

Problem

When using OpenViking as the memory provider, the /new and /reset commands do not trigger a session commit, which means memories stored via viking_remember are not extracted and indexed until the session expires via idle timeout or the gateway shuts down.

Current Behavior

Action Triggers OpenViking Commit?
/new or /reset ❌ No
Idle timeout (session expiry) ✅ Yes
Gateway shutdown ✅ Yes

Root Cause

In gateway/run.py, the _handle_reset_command() function:

  1. Calls _async_flush_memories() with a temporary agent that has skip_memory=True set
  2. Calls _evict_cached_agent() which only removes the agent from cache
  3. Does not call shutdown_memory_provider() on the cached agent

The relevant code (lines 3260-3279):

async def _handle_reset_command(self, event: MessageEvent) -> str:
    # ...
    _flush_task = asyncio.create_task(
        self._async_flush_memories(old_entry.session_id)
    )
    self._evict_cached_agent(session_key)  # Only removes from cache, no shutdown

In contrast, the session expiry watcher (lines 1307-1313) correctly calls:

await self._async_flush_memories(entry.session_id)
if hasattr(cached_agent, 'shutdown_memory_provider'):
    cached_agent.shutdown_memory_provider()  # This triggers OpenViking commit

Expected Behavior

/new and /reset should trigger the same memory provider shutdown as idle timeout does, so that OpenViking sessions are committed and memories are extracted/indexed immediately.

Suggested Fix

Add a call to shutdown_memory_provider() in _handle_reset_command() after flushing memories:

# After _evict_cached_agent, before resetting session
cached_agent = self._running_agents.get(session_key)
if cached_agent and cached_agent is not _AGENT_PENDING_SENTINEL:
    if hasattr(cached_agent, 'shutdown_memory_provider'):
        cached_agent.shutdown_memory_provider()

Impact

Users who manually reset sessions via /new or /reset expect their memories to be persisted immediately, not after waiting for idle timeout or gateway shutdown.

Environment

  • Hermes Agent version: v0.8.x
  • Memory provider: OpenViking
  • Platform: Gateway (Feishu/Telegram/Discord/etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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