Skip to content

The agent that grows with you

fix(background-review): ground memory writes in the conversation, not inference

Teknium4a8cc6f705ff
diff --git a/agent/background_review.py b/agent/background_review.py
index 44e8350fd1c..5707d9207e3 100644
--- a/agent/background_review.py
+++ b/agent/background_review.py
@@ -378,6 +378,13 @@ _MEMORY_ROUTING_BLOCK = (
"their size limits and crowds out the facts that matter; misrouting it puts it where the next "
"session won't look. If the tool schema lists only one "
"target, that store is the only one enabled — use it and skip the other.\n\n"
+ # Without a grounding rule the reviewer saved trait guesses and one-off requests as standing
+ # facts. Store-neutral on purpose: scoped to USER.md only, the same guess moved to MEMORY.md.
+ "Save only facts GROUNDED in this conversation — a user message or tool result you can point "
+ "to. Never infer the user's traits, skill level, role, mood or preferences from topic, tone or "
+ "tools used, and never turn a one-off request into a standing preference (in either store) "
+ "unless the user marked it general ('always', 'from now on', 'remember'). If unsure, leave it "
+ "out — a wrong fact misleads every future session.\n\n"
)
_MEMORY_REVIEW_PROMPT = (
diff --git a/tests/agent/test_memory_review_grounding.py b/tests/agent/test_memory_review_grounding.py
new file mode 100644
index 00000000000..99b91f71a8a
--- /dev/null
+++ b/tests/agent/test_memory_review_grounding.py
@@ -0,0 +1,16 @@
+"""The memory-bearing review prompts carry the evidence-grounding rule; the skill prompt does not.
+
+Without it the review fork saved guesses (trait inferences, a one-off "make it shorter" turned
+into "user prefers concise responses") as durable memory.
+"""
+
+from agent.background_review import _COMBINED_REVIEW_PROMPT, _MEMORY_REVIEW_PROMPT, _SKILL_REVIEW_PROMPT
+
+_RULE_MARKERS = ("GROUNDED in this conversation", "never turn a one-off request into a standing preference")
+
+
+def test_grounding_rule_is_in_both_memory_prompts_and_not_the_skill_prompt():
+ for marker in _RULE_MARKERS:
+ assert marker in _MEMORY_REVIEW_PROMPT
+ assert marker in _COMBINED_REVIEW_PROMPT
+ assert marker not in _SKILL_REVIEW_PROMPT