From 697d1596a8dcaa1abd2ff85f5391387b35e5227c Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Sat, 19 Sep 2026 15:22:37 +0530 Subject: [PATCH] test(review): memory prompts name both stores and forbid dual writes Two behaviour contracts: both memory-writing prompts name target='user' and target='memory' so facts are routed rather than defaulted, and the combined prompt no longer instructs writing a preference lesson to both a skill and memory. Both red on main's prompt file. --- tests/agent/test_review_prompt_class_first.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/agent/test_review_prompt_class_first.py b/tests/agent/test_review_prompt_class_first.py index 7497c9156e..12cc7ecf14 100644 --- a/tests/agent/test_review_prompt_class_first.py +++ b/tests/agent/test_review_prompt_class_first.py @@ -216,3 +216,33 @@ def test_curator_prompt_consolidates_by_distilling(): lower = CURATOR_REVIEW_PROMPT.lower() assert "distill" in lower, "curator must distill absorbed content, not file it" assert "verbatim" in lower and "per-incident" in lower, "curator must not copy siblings verbatim into references/" + + +# --------------------------------------------------------------------------- +# Memory store routing. The memory tool writes to two files — USER.md +# (target='user': who the user is) and MEMORY.md (target='memory': environment +# facts). A prompt that just says "save it using the memory tool" lets +# user-profile data land in the environment store and vice versa, and the +# combined prompt used to instruct writing preference lessons to BOTH a skill +# and memory, which is how MEMORY.md ends up restating SKILL.md content until +# both stores hit their size limits. +# --------------------------------------------------------------------------- + + +def test_memory_prompts_name_both_memory_targets(): + """Both memory-writing prompts must name the two targets so facts are routed, not defaulted.""" + for label, prompt in ( + ("_MEMORY_REVIEW_PROMPT", AIAgent._MEMORY_REVIEW_PROMPT), + ("_COMBINED_REVIEW_PROMPT", AIAgent._COMBINED_REVIEW_PROMPT), + ): + assert "target='user'" in prompt, f"{label}: must name the USER.md target" + assert "target='memory'" in prompt, f"{label}: must name the MEMORY.md target" + + +def test_combined_review_prompt_forbids_dual_store_writes(): + """A user-preference lesson lives in one place; the prompt must not ask for both.""" + prompt = AIAgent._COMBINED_REVIEW_PROMPT + assert "Both should carry" not in prompt, ( + "must not instruct writing the same preference lesson to both a skill and memory" + ) + assert "never both" in prompt, "must state the one-store rule for preference lessons"