hermes - 💡(How to fix) Fix [Feature]: Memory usage frequency tracking for smarter eviction [1 participants]

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…
GitHub stats
NousResearch/hermes-agent#15471Fetched 2026-04-25 06:22:34
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
labeled ×3

Error Message

  1. Manual curation is error-prone: The agent must re-read all entries and make subjective judgments about what to remove. This is slow, inconsistent, and wastes tokens.

Root Cause

  • Frequency = value signal: Entries that are referenced often are clearly more important. This is a much better eviction heuristic than position or age alone.
  • Low implementation cost: A sidecar JSON file + increment on match. No format changes to MEMORY.md/USER.md.
  • Complements #678: The Forgetting proposal covers decay/pruning. This adds the missing frequency dimension that makes decay smarter.

Code Example

// MEMORY.meta.json
{
  "entries": {
    "用户太太:李杏元": {"use_count": 12, "last_used": "2026-04-26T10:00:00Z"},
    "软件安装规则:优先国内镜像": {"use_count": 3, "last_used": "2026-04-20T08:00:00Z"}
  }
}
RAW_BUFFERClick to expand / collapse

Problem

The built-in MemoryStore (MEMORY.md / USER.md) has a hard character limit (memory_char_limit=2200, user_char_limit=1375). When the limit is reached, add() simply rejects the new entry and asks the agent to manually replace or remove.

There is no usage frequency tracking on memory entries, which means:

  1. No data-driven eviction: When memory is full, the agent has to guess which entries are less important. There is no signal indicating which entries are actually referenced/used frequently vs. which are stale.

  2. Equal weight for all entries: A frequently-referenced preference (e.g., "user prefers Chinese") occupies the same priority as a one-time observation from months ago. The agent cannot distinguish high-value from low-value entries.

  3. Manual curation is error-prone: The agent must re-read all entries and make subjective judgments about what to remove. This is slow, inconsistent, and wastes tokens.

Proposed Solution

Add a lightweight use_count field to each memory entry:

On each replace or implicit reference:

  • Increment use_count for the matched entry
  • Store metadata in a sidecar file (e.g., MEMORY.meta.json) to avoid modifying the text format

On eviction (when add() would exceed limit):

  • Sort entries by use_count (ascending)
  • Suggest or auto-remove the lowest-frequency entry
  • Optionally combine with recency (last modified timestamp)

Minimal implementation:

// MEMORY.meta.json
{
  "entries": {
    "用户太太:李杏元": {"use_count": 12, "last_used": "2026-04-26T10:00:00Z"},
    "软件安装规则:优先国内镜像": {"use_count": 3, "last_used": "2026-04-20T08:00:00Z"}
  }
}

Why This Matters

  • Frequency = value signal: Entries that are referenced often are clearly more important. This is a much better eviction heuristic than position or age alone.
  • Low implementation cost: A sidecar JSON file + increment on match. No format changes to MEMORY.md/USER.md.
  • Complements #678: The Forgetting proposal covers decay/pruning. This adds the missing frequency dimension that makes decay smarter.

Related

  • #678 — Memory Extraction + Forgetting (decay-based lifecycle)
  • #11425 — Skills lifecycle management (similar frequency tracking for skills)
  • #12987 — Ebbinghaus decay for mem0 plugin (external, not built-in memory)

Environment

  • Hermes Agent latest (as of 2026-04-26)
  • Built-in MemoryStore in tools/memory_tool.py

extent analysis

TL;DR

Implement a use_count field in the MemoryStore to track entry usage frequency and enable data-driven eviction when the character limit is reached.

Guidance

  • Add a use_count field to each memory entry and store metadata in a sidecar file (e.g., MEMORY.meta.json) to avoid modifying the text format.
  • Increment use_count for each entry on replace or implicit reference.
  • On eviction, sort entries by use_count (ascending) and suggest or auto-remove the lowest-frequency entry.
  • Consider combining use_count with recency (last modified timestamp) for more effective eviction.

Example

// MEMORY.meta.json
{
  "entries": {
    "用户太太:李杏元": {"use_count": 12, "last_used": "2026-04-26T10:00:00Z"},
    "软件安装规则:优先国内镜像": {"use_count": 3, "last_used": "2026-04-20T08:00:00Z"}
  }
}

Notes

This solution assumes that the MemoryStore is implemented in tools/memory_tool.py and that the character limits (memory_char_limit and user_char_limit) are enforced. The proposed solution complements the Forgetting proposal (#678) by adding a frequency dimension to the eviction heuristic.

Recommendation

Apply the proposed workaround by implementing the use_count field and sidecar file to enable data-driven eviction, as it provides a more effective and efficient way to manage memory entries.

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