fix: strengthen anti-repetition guidance in observer prompt#3352
Open
ryanoboril wants to merge 1 commit into
Open
fix: strengthen anti-repetition guidance in observer prompt#3352ryanoboril wants to merge 1 commit into
ryanoboril wants to merge 1 commit into
Conversation
content_hash dedup only catches byte-identical observations, so the observer re-emits paraphrased restatements of a fact it already recorded (e.g. iterative PR-review loops that re-confirm the same fix each round). Reproduced with a real DB: 40+ observations across 9 near-duplicate batches from a single user prompt, all describing the same fix (error code collision, action_fallback reuse, whitespace fix) in different wording, none caught by content_hash since the text differs. The observer's own conversationHistory already includes everything it previously wrote this session, so it has the data needed to avoid this - the prompt just never told it to check. This adds an explicit instruction to recording_focus and a specific skip_guidance bullet naming iterative-loop re-confirmation as the concrete failure mode. This is a generation-side complement to the write-time/capture-side fixes proposed in thedotmack#3038 and thedotmack#3163, not a replacement - it reduces how often the paraphrase gets emitted in the first place, but a write-time fuzzy-dedup guard is still the right backstop since prompt compliance on a small model isn't guaranteed. Refs thedotmack#3038, thedotmack#3163
Contributor
Greptile SummaryThis PR updates the code-mode observer prompt to reduce duplicate memory observations. The main changes are:
Confidence Score: 5/5Safe to merge with minimal risk. Narrow prompt-text-only change with valid JSON and no runtime, schema, or configuration changes. No files require special attention.
What T-Rex did
Important Files Changed
Reviews (1): Last reviewed commit: "fix: strengthen anti-repetition guidance..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Small, generation-side complement to #3038 and #3163. Neither of those issues' proposed fixes touch the observer's own prompt, so I'm filing this separately rather than duplicating the write-time dedup work they already scoped.
content_hashonly catches byte-identical observations. When the primary session re-confirms the same fact across an iterative loop (PR review rounds, retries, polling), the observer re-summarizes it in different words each time, and the hash never matches, so it gets stored as a "new" observation.Evidence
Reproduced against a real
claude-mem.db: one single user prompt (constantprompt_numberacross all rows, confirming this happened within one turn, not across repeated user messages) produced 9 separate observation batches over about 10 minutes, several of them near-identical paraphrases of a single underlying bug fix. All 9 batches were variations on the same three facts (a validation-guard change, an error-registry update, and a decision to reuse existing error-handling infrastructure instead of adding a new module), each phrased differently, each with a distinctcontent_hashdespite describing the same fact.This matches the shape both #3038 and #3163 already documented from their own DBs.
Why a prompt fix helps here
The observer's own
conversationHistoryalready includes everything it previously wrote earlier in the session (seedi()inworker-service.cjs, which pushes each generation's output into history before the next call). So it has the data needed to recognize a repeat, the prompt just never instructed it to check.skip_guidancealready had one vague bullet ("Repetitive operations you've already documented") but nothing calling out the actual failure mode (iterative loops re-confirming the same outcome), and nothing telling it to check its own prior output before writing.What this does NOT fix
This is instruction-following on a (by default) small model, not a hard constraint, so it won't eliminate the problem. The write-time fuzzy/semantic dedup guard proposed in #3038 and the capture-side suppression in #3163 are still the right backstop for cases where the model doesn't comply. This PR just reduces how often the paraphrase gets generated in the first place, cheaply, with no schema or runtime changes.
Change
Two prompt-text edits in
plugin/modes/code.json:recording_focus: added an explicit instruction to check prior messages in the conversation before writing, and skip if already recorded.skip_guidance: added a specific bullet naming iterative-loop re-confirmation as a skip case, ahead of the existing generic bullets.No code, schema, or config changes.