Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix(memory): require semantic valid_at timestamp (#18462)

Loonga6b5e985c45a
diff --git a/memory/utils/prompt_util.py b/memory/utils/prompt_util.py
index 422f45cd48..18e5f0561e 100644
--- a/memory/utils/prompt_util.py
+++ b/memory/utils/prompt_util.py
@@ -77,7 +77,7 @@ You are an expert at analyzing conversations to extract structured memory.
"semantic": [
{
"content": "Clear factual statement",
- "valid_at": "timestamp or empty",
+ "valid_at": "timestamp — use the conversation time when the fact has no date of its own",
"invalid_at": "timestamp or empty"
}
]
diff --git a/test/unit_test/memory/utils/test_prompt_util.py b/test/unit_test/memory/utils/test_prompt_util.py
new file mode 100644
index 0000000000..ff06ac8b88
--- /dev/null
+++ b/test/unit_test/memory/utils/test_prompt_util.py
@@ -0,0 +1,24 @@
+#
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from memory.utils.prompt_util import PromptAssembler
+
+
+def test_semantic_output_format_requires_valid_at_timestamp():
+ prompt = PromptAssembler.assemble_system_prompt({"memory_type": ["semantic"]})
+
+ assert '"valid_at": "timestamp — use the conversation time when the fact has no date of its own"' in prompt
+ assert '"valid_at": "timestamp or empty"' not in prompt