Heuristic:42 evey Hermes plugins Memory Size Limit
| Knowledge Sources | |
|---|---|
| Domains | Memory_Management, Optimization, Context_Management |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Cap MEMORY.md at 4200 characters and trim lowest-importance facts first when the limit is exceeded, preserving high-importance entries and structural headers.
Description
The memory consolidation plugin writes learned facts to MEMORY.md with importance scores (1-10). When the file exceeds CHAR_LIMIT = 4200 characters, the trimming algorithm identifies lines containing [importance:N] tags, sorts them by score ascending, and removes the lowest-scored facts one by one until the file is under the limit. Structural lines (headers, date markers) are preserved because only lines with [importance: are candidates for removal. This ensures the memory file stays compact enough for the agent's context window while retaining the most valuable learned facts.
Usage
Use this heuristic when managing a persistent memory file that grows over time and must fit within a context window. Apply importance-based trimming rather than FIFO or random eviction.
The Insight (Rule of Thumb)
- Action: Set a character limit (4200 chars) on the memory file. When exceeded, sort fact lines by their
[importance:N]score and remove the lowest first. - Value:
CHAR_LIMIT = 4200— small enough for most context windows, large enough for ~30-50 compact facts. - Trade-off: Low-importance facts (score 1-4) are pruned first, even if recent. This is intentional: a trivial fact that's 1 day old is less valuable than a critical fact that's 30 days old.
- Compatibility: Requires facts to be tagged with
[importance:N]scores during the scoring phase. Facts without scores are preserved (not candidates for removal).
Reasoning
The agent's context window is finite. If MEMORY.md grows unbounded, it eventually consumes the entire context, leaving no room for the current task. The 4200-character limit keeps the memory file to roughly 500-700 tokens — a small fraction of even a 4K-token context window.
Importance-based trimming is superior to FIFO because importance decays separately via the exponential decay model (half-life of 14 days). A fact that was important 2 weeks ago and has decayed to score 2 is a better removal candidate than a score-8 fact from yesterday. The trimming algorithm respects this by sorting on the stored importance score, not on recency.
The algorithm also handles index shifting: after removing a line, the remaining removable indices are adjusted (removable = [(i if i < idx else i-1, l) for i, l in removable]) to avoid index-out-of-bounds errors.