diff --git a/backend/packages/harness/deerflow/agents/memory/backends/deermem/deermem/core/storage.py b/backend/packages/harness/deerflow/agents/memory/backends/deermem/deermem/core/storage.py index dce3399ae2..9f38aef87c 100644 --- a/backend/packages/harness/deerflow/agents/memory/backends/deermem/deermem/core/storage.py +++ b/backend/packages/harness/deerflow/agents/memory/backends/deermem/deermem/core/storage.py @@ -248,10 +248,31 @@ def _normalize_category(fact: dict[str, Any]) -> None: raw_category = fact.get("category", "context") if not isinstance(raw_category, str): raise ValueError("fact.category must be a string") - category = raw_category or "context" - if category not in CORE_CATEGORIES: - fact.setdefault("categoryExtension", category) - fact["category"] = "other" + fact["category"] = raw_category or "context" + # ``categoryExtension`` is only meaningful while ``category`` is "other" + # (pre-native-category builds parked non-core labels there). Once a label + # is stored natively -- including a legacy "other"+extension fact updated + # to a real category -- the leftover field would contradict the Gateway's + # documented meaning, so drop it. + if fact["category"] != "other": + fact.pop("categoryExtension", None) + + +def _category_comparison_key(fact: dict[str, Any]) -> tuple[Any, ...]: + """Category pair with the legacy ``other`` alias folded into the label. + + Pre-native-category builds persisted a label outside CORE_CATEGORIES as + ``category="other"`` plus ``categoryExtension=