hermes - 💡(How to fix) Fix feat: pre-turn memory health hook in run_conversation() [1 comments, 1 participants]

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…
GitHub stats
NousResearch/hermes-agent#25061Fetched 2026-05-14 03:49:22
View on GitHub
Comments
1
Participants
1
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×4commented ×1

Root Cause

run_conversation() in run_agent.py (~L11713) has no pre-processing hook that checks memory health before each turn. The only mechanism is a text instruction in the system prompt, which depends on the LLM remembering to follow it — something it demonstrably fails at.

Fix Action

Fix / Workaround

  • memory-management-and-cleanup skill (user-created) documents this pattern
  • Current workaround: cron job that polls every 6h (rejected as insufficient — the right fix is code-level)

Code Example

if self._memory_store and self._memory_store.get_usage_pct() > 70:
    compacted = self._memory_store.compact(target_pct=60)
    if compacted:
        logger.info("Pre-turn memory compaction: freed %d chars", compacted)
RAW_BUFFERClick to expand / collapse

Problem

Standing rules in the system prompt that require proactive LLM behavior (e.g. "if memory exceeds 70%, compact entries") are consistently ignored. The LLM prioritizes the user's latest message over static rules, making these instructions unreliable regardless of how clearly they are written.

Root Cause

run_conversation() in run_agent.py (~L11713) has no pre-processing hook that checks memory health before each turn. The only mechanism is a text instruction in the system prompt, which depends on the LLM remembering to follow it — something it demonstrably fails at.

Proposed Fix

Add a pre-turn hook before the main LLM call in run_conversation() that:

  1. Checks self._memory_store.get_usage_pct()
  2. If > 70%, automatically runs compaction targeting < 60%
  3. Logs the action for observability

Something like:

if self._memory_store and self._memory_store.get_usage_pct() > 70:
    compacted = self._memory_store.compact(target_pct=60)
    if compacted:
        logger.info("Pre-turn memory compaction: freed %d chars", compacted)

This ensures memory health is enforced mechanically, not by LLM compliance with a text rule.

Related

  • memory-management-and-cleanup skill (user-created) documents this pattern
  • Current workaround: cron job that polls every 6h (rejected as insufficient — the right fix is code-level)

Opened via feedback from a user session: standing rules in system prompt that require proactive LLM behavior are unreliable.

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