From 6e5489c9f3ecb93c0b907d5647bcc6a569b8f77e Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sat, 9 May 2026 12:48:25 -0700 Subject: [PATCH] fix(memory): tighten MEMORY_GUIDANCE against ephemeral PR/issue/SHA notes (#22781) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The model regularly writes session-outcome facts to MEMORY.md despite the existing 'Do NOT save task progress' line — entries like 'Submitted PR #22577 for the kanban dedup fix' or 'Fixed bug X in file Y'. These are stale within days, pollute the system prompt, and crowd out durable user preferences (the issue #22563 reporter saw 9 sections of bug-fix notes injected on a brand-new task). Add explicit examples of what NOT to save (PR numbers, issue numbers, commit SHAs, 'fixed/submitted/Phase N done', file counts) plus the 7-day-staleness heuristic so the model has a concrete calibration target rather than guessing what counts as 'task progress'. Closes #22563 (the prompt-side, low-risk portion). The bigger relevance-based-injection / vector-retrieval feature requested in #22563 is tracked under #2184 (Richer local memory). Per skill rule on prompt caching, dynamic memory injection breaks the frozen-snapshot invariant and needs a separate design call. --- agent/prompt_builder.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/agent/prompt_builder.py b/agent/prompt_builder.py index d907a581583..456cd099ea1 100644 --- a/agent/prompt_builder.py +++ b/agent/prompt_builder.py @@ -157,6 +157,9 @@ MEMORY_GUIDANCE = ( "User preferences and recurring corrections matter more than procedural task details.\n" "Do NOT save task progress, session outcomes, completed-work logs, or temporary TODO " "state to memory; use session_search to recall those from past transcripts. " + "Specifically: do not record PR numbers, issue numbers, commit SHAs, 'fixed bug X', " + "'submitted PR Y', 'Phase N done', file counts, or any artifact that will be stale " + "in 7 days. If a fact will be stale in a week, it does not belong in memory. " "If you've discovered a new way to do something, solved a problem that could be " "necessary later, save it as a skill with the skill tool.\n" "Write memories as declarative facts, not instructions to yourself. "