[GH-ISSUE #1027] [Issue]: Prevent repeated LTM memories across subject variants and incomplete existing-note retrieval #526

Closed
opened 2026-10-20 17:28:19 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (Sep 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1027

Originally assigned to: @Promansis on GitHub.

Summary

Long-Term Memory extraction can create repeated memories for the same fact or event. Deduplication only compares candidates that already resolve to the same note ID and only against the existing notes selected for the extraction, so equivalent memories can bypass deduplication when subject surface forms differ or retrieval does not return the older note.

Affected package

long-term-memory (server-side extraction, existing-note selection, and evidence-unit deduplication)

Expected behavior

Before compiling a new mutation, an extracted candidate should be compared with the relevant existing memory after subject identity has been canonicalized. Equivalent facts/events with materially different wording should be recognized as duplicates within the documented similarity policy. Existing-note comparison should not depend solely on ranked recall returning the old memory.

The fix must preserve distinct facts, separate scopes, and additive sections where a new contribution is genuinely different.

Actual behavior

deduplicateUnits keys candidates by noteId + sectionKey, then checks exact text or an 0.85 lexical Jaccard threshold. A short/full-name identity split creates different note IDs, so the memories are never compared. In addition, extraction builds existingTypedNotes from retrieval results plus identity notes; an older equivalent memory that is not selected by retrieval is absent from the deduplication set.

The supplied trace shows multiple extractions with existing notes loaded but deduplications: 0, while repeated memory content was observed.

Steps to reproduce

  1. Seed a synthetic scoped memory for a character using a full-name subject and one wording of a durable fact.
  2. Extract the same fact using an abbreviated or first-name subject and materially different but equivalent wording.
  3. Repeat extraction with the old memory below the retrieval result limit or with a query that does not rank it into existingTypedNotes.
  4. Inspect the draft mutations and stored notes; the equivalent fact can appear as a new memory instead of a deduplication.

Environment

  • Marinara Engine version: current staging compatibility range
  • Package version: current long-term-memory staging build
  • Install type: source/test fixture
  • OS + version: Linux
  • Browser or app shell: Engine package host

Logs, screenshots, or video

The investigation used scratch/ltm-debug-log.jsonl; it contains private extraction identifiers and is not attached. Regression fixtures should be synthetic and contain no private chat data.

Additional context

Subject canonicalization is tracked separately in #1026 and should be treated as an upstream contract for this issue. Historical related work includes #756 and #913, but this report concerns runtime memory deduplication and existing-note coverage, not test assertion cleanup or extraction fingerprint freshness. The focused regression owners are tests/long-term-memory-extraction-graph.regression.ts and the relevant source-processing/storage regression suites.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Sep 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1027 Originally assigned to: @Promansis on GitHub. ## Summary Long-Term Memory extraction can create repeated memories for the same fact or event. Deduplication only compares candidates that already resolve to the same note ID and only against the existing notes selected for the extraction, so equivalent memories can bypass deduplication when subject surface forms differ or retrieval does not return the older note. ## Affected package `long-term-memory` (server-side extraction, existing-note selection, and evidence-unit deduplication) ## Expected behavior Before compiling a new mutation, an extracted candidate should be compared with the relevant existing memory after subject identity has been canonicalized. Equivalent facts/events with materially different wording should be recognized as duplicates within the documented similarity policy. Existing-note comparison should not depend solely on ranked recall returning the old memory. The fix must preserve distinct facts, separate scopes, and additive sections where a new contribution is genuinely different. ## Actual behavior `deduplicateUnits` keys candidates by `noteId + sectionKey`, then checks exact text or an 0.85 lexical Jaccard threshold. A short/full-name identity split creates different note IDs, so the memories are never compared. In addition, extraction builds `existingTypedNotes` from retrieval results plus identity notes; an older equivalent memory that is not selected by retrieval is absent from the deduplication set. The supplied trace shows multiple extractions with existing notes loaded but `deduplications: 0`, while repeated memory content was observed. ## Steps to reproduce 1. Seed a synthetic scoped memory for a character using a full-name subject and one wording of a durable fact. 2. Extract the same fact using an abbreviated or first-name subject and materially different but equivalent wording. 3. Repeat extraction with the old memory below the retrieval result limit or with a query that does not rank it into `existingTypedNotes`. 4. Inspect the draft mutations and stored notes; the equivalent fact can appear as a new memory instead of a deduplication. ## Environment - Marinara Engine version: current `staging` compatibility range - Package version: current `long-term-memory` staging build - Install type: source/test fixture - OS + version: Linux - Browser or app shell: Engine package host ## Logs, screenshots, or video The investigation used `scratch/ltm-debug-log.jsonl`; it contains private extraction identifiers and is not attached. Regression fixtures should be synthetic and contain no private chat data. ## Additional context Subject canonicalization is tracked separately in #1026 and should be treated as an upstream contract for this issue. Historical related work includes #756 and #913, but this report concerns runtime memory deduplication and existing-note coverage, not test assertion cleanup or extraction fingerprint freshness. The focused regression owners are `tests/long-term-memory-extraction-graph.regression.ts` and the relevant source-processing/storage regression suites. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:28:19 +07:00
  • closed this issue
  • added the
    bug
    label
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Agents#526
No description provided.