refactor(memory): drop on_session_reset — commit-only is enough

OV transparently handles message history across /new and /compress: old
messages stay in the same session and extraction is idempotent, so there's
no need to rebind providers to a new session_id. The only thing the
session boundary actually needs is to trigger extraction.

- MemoryProvider / MemoryManager: remove on_session_reset hook
- OpenViking: remove on_session_reset override (nothing to do)
- AIAgent: replace rotate_memory_session with commit_memory_session
  (just calls on_session_end, no rebind)
- cli.py / run_agent.py: single commit_memory_session call at the
  session boundary before session_id rotates
- tests: replace on_session_reset coverage with routing tests for
  MemoryManager.on_session_end

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
zhiheng.liu 2026-04-16 00:38:19 +08:00 committed by Teknium
parent 8275fa597a
commit 7cb06e3bb3
6 changed files with 30 additions and 156 deletions

View file

@ -281,22 +281,6 @@ class MemoryManager:
provider.name, e,
)
def on_session_reset(self, new_session_id: str) -> None:
"""Notify all providers of a session reset.
Called after on_session_end() has committed the previous session.
Providers with per-session state override on_session_reset to rebind
it cheaply (default is a no-op on the base class).
"""
for provider in self._providers:
try:
provider.on_session_reset(new_session_id)
except Exception as e:
logger.debug(
"Memory provider '%s' on_session_reset failed: %s",
provider.name, e,
)
def on_pre_compress(self, messages: List[Dict[str, Any]]) -> str:
"""Notify all providers before context compression.

View file

@ -160,15 +160,6 @@ class MemoryProvider(ABC):
(CLI exit, /reset, gateway session expiry).
"""
def on_session_reset(self, new_session_id: str) -> None:
"""Transition to a new session without full teardown.
Called after on_session_end() has committed the previous session
(e.g. /new, context compression). Providers with per-session state
override to rebind counters/IDs while keeping HTTP clients alive.
Default: no-op.
"""
def on_pre_compress(self, messages: List[Dict[str, Any]]) -> str:
"""Called before context compression discards old messages.