hermes - 💡(How to fix) Fix [Feature Request] Memory: automatic conversation capture via session lifecycle hooks

Official PRs (…)
ON THIS PAGE

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…

Error Message

Users must manually call the memory tool after each conversation to persist facts. This is error-prone and rarely done consistently.

Root Cause

However, the most valuable feature of external memory providers — automatic conversation capture — cannot work in Hermes today because there is no hook that fires with the full conversation content (user message + assistant response) in a way that can write to memory without an explicit memory tool call from the LLM.

Fix Action

Fix / Workaround

Current Workaround

Code Example

on_turn_start()          # per-turn tick
on_session_end()         # end-of-session extraction
on_session_switch()      # session_id rotation
on_pre_compress()        # context compression before
on_memory_write()        # mirror built-in memory writes
on_delegation()          # parent-side observation of subagent work

---

def on_turn_complete(self, user_content: str, assistant_content: str, *, session_id: str = "") -> None:
    """Called after each conversational turn completes.

    Providers can inspect the content and auto-write relevant facts
    to their memory backend without requiring an explicit memory tool call.

    This is the hook that makes auto-capture possible.
    """

---

# After each turn (post tool calls, pre next iteration)
for provider in self._memory_manager.providers:
    if hasattr(provider, 'on_turn_complete'):
        provider.on_turn_complete(user_content, assistant_content, session_id=session_id)
RAW_BUFFERClick to expand / collapse

Feature Request: Memory Auto-Capture via Session Lifecycle Hooks

Problem

Hermes has a well-designed MemoryProvider plugin architecture (shipped with providers like Honcho, Mem0, Supermemory) and a rich set of lifecycle hooks in agent/memory_provider.py:

on_turn_start()          # per-turn tick
on_session_end()         # end-of-session extraction
on_session_switch()      # session_id rotation
on_pre_compress()        # context compression before
on_memory_write()        # mirror built-in memory writes
on_delegation()          # parent-side observation of subagent work

However, the most valuable feature of external memory providers — automatic conversation capture — cannot work in Hermes today because there is no hook that fires with the full conversation content (user message + assistant response) in a way that can write to memory without an explicit memory tool call from the LLM.

Target Users and Scenarios

  • Power users who want Hermes to automatically remember facts from conversations without manually invoking the memory tool
  • Long-running sessions where important context is conveyed mid-session but never persisted
  • Multi-session continuity: Facts stated once in session A should be available in session B without the user having to re-explain

Proposed Solution

Extend the MemoryProvider interface with a new hook that fires after each turn with access to the full user+assistant content:

def on_turn_complete(self, user_content: str, assistant_content: str, *, session_id: str = "") -> None:
    """Called after each conversational turn completes.

    Providers can inspect the content and auto-write relevant facts
    to their memory backend without requiring an explicit memory tool call.

    This is the hook that makes auto-capture possible.
    """

Integration point: Wire it into run_agent.py after the agent loop's tool-call cycle completes:

# After each turn (post tool calls, pre next iteration)
for provider in self._memory_manager.providers:
    if hasattr(provider, 'on_turn_complete'):
        provider.on_turn_complete(user_content, assistant_content, session_id=session_id)

Why This Cannot Be Worked Around Today

  1. LLM decides when to call memory: The LLM must voluntarily choose to call the memory tool, which means 90%+ of conversations have zero memory persistence
  2. pre_llm_call / post_llm_call hooks are for context injection only: pre_llm_call can ONLY inject context, cannot filter self.tools (tools list is fixed at AIAgent.__init__ time — this is an architectural constraint documented in run_agent.py)
  3. sync_turn() exists but is a no-op for built-in: The built-in MemoryStore provider has sync_turn() = pass because the built-in memory tool requires manual writes

Current Workaround

Users must manually call the memory tool after each conversation to persist facts. This is error-prone and rarely done consistently.

Additional Notes

This is a prerequisite for making external memory providers (Honcho, Supermemory, Mem0) truly useful — their auto-capture value proposition only works if there is a reliable hook to trigger it.

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