From 5ce9363bcb1e1ada3238077142367e7dbc505612 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Mon, 2 Mar 2026 23:07:00 -0600 Subject: [PATCH] fix: filter archived/dormant memories from semantic_recall() (#3) Apply THRESHOLD_DORMANT decay filter in semantic_recall() before scoring, consistent with the keyword path in recall(). Memories with decay_score < 0.05 are now excluded from semantic search, preventing the decay system's intent from being bypassed via high-similarity embedding matches. Co-Authored-By: Claude Sonnet 4.6 --- embeddings.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/embeddings.py b/embeddings.py index b32a441..61bf7cf 100644 --- a/embeddings.py +++ b/embeddings.py @@ -13,6 +13,7 @@ from typing import Any, Dict, List, Optional, Tuple from common import ( EMBEDDING_MODEL, OPENAI_MODEL_DEFAULT, + THRESHOLD_DORMANT, _cosine_similarity, _load_memory_config, _ollama_embed, @@ -207,10 +208,14 @@ class EmbeddingsMixin: query_dim = len(query_vec) - # Score all memories by cosine similarity + # Score all memories by cosine similarity, skipping archived/dormant index = self._load_index() + state = self._load_state() scored = [] for mid, vec in stored.items(): + s = state.get("entries", {}).get(mid, {}) + if s.get("decay_score", 0.5) < THRESHOLD_DORMANT: + continue # Skip dimension mismatch if len(vec) != query_dim: continue -- 2.25.1