From 0422da119258f59de8c867bbfdb0aa5f9d2014d4 Mon Sep 17 00:00:00 2001 From: aman shah Date: Wed, 15 Jul 2026 17:14:10 -0400 Subject: [PATCH] fix(memory): reject one-off/topic content in update_memory tool prompt Add contrastive negative examples to the update_memory tool description so the agent's primary save path stops persisting the current task's topic as if it were a durable preference: a question or a one-off task command (even phrased as "add/include/show") -> save NOTHING; a standing preference, business definition/metric, hard constraint, or correction -> SAVE. Mirrors MEMORY_CONTRASTIVE_EXAMPLES in the web app (lib/services/memory/memory-policy.ts). Co-Authored-By: Claude Opus 4.8 (1M context) --- tools/user_notes_tool.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/user_notes_tool.py b/tools/user_notes_tool.py index a104fbfddd28c..0636cfc33e9d6 100644 --- a/tools/user_notes_tool.py +++ b/tools/user_notes_tool.py @@ -740,7 +740,20 @@ def _check_user_notes_requirements() -> bool: "on something, ALWAYS capture it. Do NOT save the topic of the current " "conversation, what the user is working on or asking about right now, their " "current goals/tasks, one-off request parameters, transient values, or small " - "talk — conversation content is not memory. Most turns need NO save, and no save " + "talk — conversation content is not memory. " + # Contrastive examples — mirror of MEMORY_CONTRASTIVE_EXAMPLES in the web app + # (lib/services/memory/memory-policy.ts). Naming the exact leak modes stops + # a one-off task instruction being saved as if it were a durable preference. + "Examples — do NOT save for: a question ('how does Q3 revenue compare by " + "region?'), or a one-off request scoped to the current task ('make this chart " + "blue', 'add the total row and include Q4', 'break revenue down by region for " + "this analysis') — transient even when phrased as commands with " + "'add/include/show'. DO save for a fact that outlives this task: a standing " + "preference ('always show revenue in millions'), a business definition/metric " + "('fiscal year ends in March'), a hard constraint, or an explicit correction " + "('actually, churn should exclude trials'). When unsure whether something is " + "standing or one-off, do NOT save it. " + "Most turns need NO save, and no save " "means DO NOT CALL THIS TOOL — never call it with placeholder content like " "'nothing' or 'none'; only call when you have a real fact to write. The current " "memory is shown in your context under 'Project Memory (AI-maintained)'. Never "