Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:42 evey Hermes plugins memory decay

From Leeroopedia
Knowledge Sources
Domains Memory_Management, Decay_Model, Forgetting
Last Updated 2026-10-29 00:00 GMT

Overview

Concrete tool for applying exponential importance decay to memories, flagging stale entries below a threshold for removal while preserving frequently accessed ones.

Description

The memory_decay handler (handle_decay) applies an exponential decay model to all tracked memories. The decay formula is:

decayed_score = importance × e^(-0.693 × days_since_access / half_life_days)

With a default half-life of 14 days, meaning a memory's score halves every two weeks without access. The handler reads the scores file (~/.hermes/memories/.memory_scores.json), computes the decayed score for each memory, and returns memories grouped into healthy vs. flagged-for-removal based on a configurable threshold (default 0.1).

The _decay_score(importance, last_accessed, half_life_days) function implements the core decay formula. The memory_score tool (handle_score) provides complementary actions: rank (show all decayed scores sorted), boost (increase a memory's importance by 0.5, capped at 5.0), and access (mark a memory as recently used, incrementing access count).

State is persisted in ~/.hermes/memories/.memory_scores.json as a dict: {memory_text: {importance, last_accessed, accesses, created}}.

Usage

Call memory_decay during memory consolidation to prune stale memories. Call memory_score with action rank/boost/access to manage individual memory scores. Registered on the evey_memory toolset.

Code Reference

Source Location

  • Repository: hermes-plugins
  • File: evey-memory-adaptive/__init__.py
  • Lines: L24-190 (_load_scores L24-30, _save_scores L33-35, _decay_score L38-41, handle_score L88-140, handle_decay L143-175, schemas L44-85)

Signature

def _decay_score(importance: float, last_accessed: float, half_life_days: int = 14) -> float:
    """Exponential decay: score halves every half_life_days without access."""

def handle_decay(args: dict, **kwargs) -> str:
    """
    Args:
        args: {threshold: number - score threshold below which memories are flagged (default 0.1)}
    Returns:
        JSON: {status: "ok", healthy_count, flagged_for_removal: list[{key, score, days_since_access}], suggestion}
    """

def handle_score(args: dict, **kwargs) -> str:
    """
    Args:
        args: {
            action: str (required, enum: rank/boost/access),
            memory_key: str - for boost/access
        }
    Returns:
        rank: {status: "ok", memories: list[{key, importance, decayed_score, accesses, last_accessed}], count}
        boost: {status: "boosted", key, new_importance}
        access: {status: "accessed", key, accesses}
    """

Import

from evey_memory_adaptive import handle_decay, handle_score
# Or accessed via Hermes tool calls: memory_decay, memory_score

I/O Contract

Inputs (memory_decay)

Name Type Required Description
threshold number No Score threshold for flagging (default 0.1)
(state) dict — .memory_scores.json with per-memory importance, last_accessed, accesses

Outputs (memory_decay)

Name Type Description
status str "ok"
healthy_count int Memories above threshold
flagged_for_removal list[dict] Each: {key, score, days_since_access}
suggestion str Human-readable pruning suggestion

Usage Examples

Run Decay Check

result = tool_call("memory_decay", {"threshold": 0.1})
# {"status":"ok","healthy_count":18,
#  "flagged_for_removal":[
#    {"key":"old API endpoint","score":0.03,"days_since_access":45},
#    {"key":"temp debug info","score":0.05,"days_since_access":30}],
#  "suggestion":"2 memories below threshold 0.1. Consider consolidating or removing them."}

Rank All Memories

result = tool_call("memory_score", {"action": "rank"})
# {"status":"ok","memories":[
#   {"key":"use local model for research","importance":3.5,"decayed_score":3.2,"accesses":12,"last_accessed":"2026-10-28"},
#   {"key":"old API endpoint","importance":2.0,"decayed_score":0.03,"accesses":1,"last_accessed":"2026-09-14"}],
#  "count":2}

Boost and Access

tool_call("memory_score", {"action": "boost", "memory_key": "use local model for research"})
# {"status":"boosted","key":"use local model for research","new_importance":4.0}

tool_call("memory_score", {"action": "access", "memory_key": "use local model for research"})
# {"status":"accessed","key":"use local model for research","accesses":13}

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment