Skip to content

fix: strengthen anti-repetition guidance in observer prompt#3352

Open
ryanoboril wants to merge 1 commit into
thedotmack:mainfrom
ryanoboril:fix/observer-anti-repetition-guidance
Open

fix: strengthen anti-repetition guidance in observer prompt#3352
ryanoboril wants to merge 1 commit into
thedotmack:mainfrom
ryanoboril:fix/observer-anti-repetition-guidance

Conversation

@ryanoboril

@ryanoboril ryanoboril commented Jul 21, 2026

Copy link
Copy Markdown

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_hash only 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 (constant prompt_number across 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 distinct content_hash despite 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 conversationHistory already includes everything it previously wrote earlier in the session (see di() in worker-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_guidance already 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.

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
@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR updates the code-mode observer prompt to reduce duplicate memory observations. The main changes are:

  • Adds guidance to check prior observer messages before writing a new observation.
  • Tells the observer to skip facts, decisions, or fixes already recorded in different words.
  • Calls out iterative loops like review rounds, retries, and polling as cases where repeated confirmations should be recorded once.

Confidence Score: 5/5

Safe 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.

T-Rex T-Rex Logs

What T-Rex did

  • The initial CommonJS JavaScript attempt failed because the repository uses type:module.
  • The equivalent script using the .cjs extension was executed and completed successfully.
  • The post-CJS run produced matched excerpts for both required strings in the post-CJS log and exited with code 0.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
plugin/modes/code.json Updates observer prompt text to explicitly skip previously recorded facts and iterative-loop re-confirmations; no issues found.

Reviews (1): Last reviewed commit: "fix: strengthen anti-repetition guidance..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant