hermes - 💡(How to fix) Fix commit_memory_session() missing context_compressor.on_session_end() call

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…

commit_memory_session() (called on /new, gateway session expiry, etc.) calls memory_manager.on_session_end() but does not call context_compressor.on_session_end(). This means plugin context engines like hermes-lcm (LCM) miss the final session-end flush.

Error Message

def commit_memory_session(self, messages: list = None) -> None: if not self._memory_manager: return try: self._memory_manager.on_session_end(messages or []) except Exception: pass # context_compressor.on_session_end() is NOT called here

Root Cause

commit_memory_session() (called on /new, gateway session expiry, etc.) calls memory_manager.on_session_end() but does not call context_compressor.on_session_end(). This means plugin context engines like hermes-lcm (LCM) miss the final session-end flush.

Fix Action

Fix

Add the missing context_compressor.on_session_end() call to commit_memory_session():

def commit_memory_session(self, messages: list = None) -> None:
    if not self._memory_manager:
        return
    try:
        self._memory_manager.on_session_end(messages or [])
    except Exception:
        pass
    if hasattr(self, "context_compressor") and self.context_compressor:
        try:
            self.context_compressor.on_session_end(
                self.session_id or "", messages or []
            )
        except Exception:
            pass

Code Example

def commit_memory_session(self, messages: list = None) -> None:
    if not self._memory_manager:
        return
    try:
        self._memory_manager.on_session_end(messages or [])
    except Exception:
        pass
    # context_compressor.on_session_end() is NOT called here

---

def shutdown_memory_provider(self, messages: list = None) -> None:
    if self._memory_manager:
        self._memory_manager.on_session_end(messages or [])
        self._memory_manager.shutdown_all()
    if hasattr(self, "context_compressor") and self.context_compressor:
        self.context_compressor.on_session_end(
            self.session_id or "", messages or []
        )

---

def commit_memory_session(self, messages: list = None) -> None:
    if not self._memory_manager:
        return
    try:
        self._memory_manager.on_session_end(messages or [])
    except Exception:
        pass
    if hasattr(self, "context_compressor") and self.context_compressor:
        try:
            self.context_compressor.on_session_end(
                self.session_id or "", messages or []
            )
        except Exception:
            pass
RAW_BUFFERClick to expand / collapse

Bug: commit_memory_session() does not notify context engine of session end

Summary

commit_memory_session() (called on /new, gateway session expiry, etc.) calls memory_manager.on_session_end() but does not call context_compressor.on_session_end(). This means plugin context engines like hermes-lcm (LCM) miss the final session-end flush.

Affected code

run_agent.py line ~4898:

def commit_memory_session(self, messages: list = None) -> None:
    if not self._memory_manager:
        return
    try:
        self._memory_manager.on_session_end(messages or [])
    except Exception:
        pass
    # context_compressor.on_session_end() is NOT called here

Compare with shutdown_memory_provider() (line ~4871) which correctly calls both:

def shutdown_memory_provider(self, messages: list = None) -> None:
    if self._memory_manager:
        self._memory_manager.on_session_end(messages or [])
        self._memory_manager.shutdown_all()
    if hasattr(self, "context_compressor") and self.context_compressor:
        self.context_compressor.on_session_end(
            self.session_id or "", messages or []
        )

Impact

  • CLI /new: LCM misses final _ingest_messages() and lifecycle.finalize_session() for the last few turns before /new
  • Gateway (Telegram/Discord/Slack) session expiry: _finalize_session() calls commit_memory_session(), same LCM data loss
  • Messages that arrived after the last compress() or should_compress_preflight() call are not persisted to lcm.db
  • LCM session is never finalized (stays as "active" in lifecycle store)

Fix

Add the missing context_compressor.on_session_end() call to commit_memory_session():

def commit_memory_session(self, messages: list = None) -> None:
    if not self._memory_manager:
        return
    try:
        self._memory_manager.on_session_end(messages or [])
    except Exception:
        pass
    if hasattr(self, "context_compressor") and self.context_compressor:
        try:
            self.context_compressor.on_session_end(
                self.session_id or "", messages or []
            )
        except Exception:
            pass

Environment

  • Hermes Agent version: latest
  • Context engine: hermes-lcm v0.9.2
  • Platform: affects both CLI and gateway (Telegram/Discord/Slack)

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