[GH-ISSUE #1751] [Feature]: Long-Term Memory: mark imported notes whose source is gone as outdated #1732

Closed
opened 2026-11-07 16:36:18 +07:00 by bsakaguchi · 0 comments
Owner

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

Originally assigned to: @Promansis on GitHub.

What problem does this solve?

When you import a source into Long-Term Memory (a chat's summaries or messages, a lorebook, a character), it becomes a source note, and memories are extracted from it. If that source later disappears, the note stays and nothing tells you. Its memories keep being recalled in chats, even though the text they came from is gone.

This happens because the import preview only reports freshness for sources that still exist. It matches each current candidate to an existing source note (existingMatcher in sources/interop.ts) and reports new, current, source_updated, context_updated or extraction_incomplete (LtmInteropPreviewFreshness, shared schema/sources.ts). A note whose source has gone matches no candidate, so it never appears in the preview at all.

Cases that leave such a note behind today:

  • Chat messages (1.5.0, #1744): the first message of an imported piece is deleted, or an edit shortens an oversized message so it has fewer :part:N pieces. A branch chat can also miss deduplication against a parent chat whose pieces were cut differently. #1747 already keeps pieces stable when an earlier message changes; these are the cases it leaves.
  • Conversation summaries: a summary entry is deleted, or regenerated with a new id.
  • Lorebooks: an entry or a whole lorebook is deleted.
  • Characters: the character is deleted.

Example: you import a lorebook, then delete its "Old capital" entry because the story moved on. The "Old capital" note and its memories stay in the vault and keep showing up in recall. The Sources screen never mentions it.

Proposed package or change

Package: long-term-memory. Server and UI change, no Engine change.

When a preview covers a whole source (a chat, a lorebook, the character list), report the source notes with that provenance kind and source id that no candidate matched as outdated. For each one the Sources screen offers:

  • Keep: leave the note and its memories as they are.
  • Remove: remove the note and the memories extracted from it, using the existing note deletion and its memory cleanup.

Nothing is removed automatically.

Questions to settle before implementing:

  1. Shape: a new LtmInteropPreviewFreshness value (outdated), or a separate outdated list in the preview response? A new enum value is a schema change that the client, and any saved preview or restored task, must accept. A separate list leaves the existing rows unchanged.
  2. Scope: report outdated notes only for a source the preview loaded in full. A paged or search-filtered preview must not report notes for rows it didn't load.
  3. Re-cut chat pieces: when a chat piece's note is outdated because its text now sits in another piece, should it offer "merge into that piece" instead of only remove?

Why should this be optional?

It lives in the Long-Term Memory package, which is already optional. Within the package it adds no setting: it only reports what is already true and asks before removing anything.

Alternatives considered

  • Remove the notes automatically: rejected. A source can disappear briefly, for example during a lorebook re-import, and memories the user edited or approved would be lost.
  • Keep the stored first message of a chat piece alive in the piece naming: #1747 does this for edits and deletions before a piece. It can't help when the stored first message itself is deleted, and doesn't cover the other source kinds.

Additional context

Follow-up from the Dottore review of #1747 (LTM 1.5.0). It was left out of that PR because it covers every source kind, not only chat messages.

Proof: a regression for each source kind that imports a source, deletes it (or its entry), previews, and expects the note reported as outdated. A paged or filtered preview must not report it.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Oct 27, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1751 Originally assigned to: @Promansis on GitHub. ## What problem does this solve? When you import a source into Long-Term Memory (a chat's summaries or messages, a lorebook, a character), it becomes a source note, and memories are extracted from it. If that source later disappears, the note stays and nothing tells you. Its memories keep being recalled in chats, even though the text they came from is gone. This happens because the import preview only reports freshness for sources that still exist. It matches each current candidate to an existing source note (`existingMatcher` in `sources/interop.ts`) and reports `new`, `current`, `source_updated`, `context_updated` or `extraction_incomplete` (`LtmInteropPreviewFreshness`, shared `schema/sources.ts`). A note whose source has gone matches no candidate, so it never appears in the preview at all. Cases that leave such a note behind today: - **Chat messages** (1.5.0, #1744): the first message of an imported piece is deleted, or an edit shortens an oversized message so it has fewer `:part:N` pieces. A branch chat can also miss deduplication against a parent chat whose pieces were cut differently. #1747 already keeps pieces stable when an earlier message changes; these are the cases it leaves. - **Conversation summaries:** a summary entry is deleted, or regenerated with a new id. - **Lorebooks:** an entry or a whole lorebook is deleted. - **Characters:** the character is deleted. Example: you import a lorebook, then delete its "Old capital" entry because the story moved on. The "Old capital" note and its memories stay in the vault and keep showing up in recall. The Sources screen never mentions it. ## Proposed package or change Package: `long-term-memory`. Server and UI change, no Engine change. When a preview covers a whole source (a chat, a lorebook, the character list), report the source notes with that provenance kind and source id that no candidate matched as **outdated**. For each one the Sources screen offers: - **Keep**: leave the note and its memories as they are. - **Remove**: remove the note and the memories extracted from it, using the existing note deletion and its memory cleanup. Nothing is removed automatically. Questions to settle before implementing: 1. **Shape:** a new `LtmInteropPreviewFreshness` value (`outdated`), or a separate `outdated` list in the preview response? A new enum value is a schema change that the client, and any saved preview or restored task, must accept. A separate list leaves the existing rows unchanged. 2. **Scope:** report outdated notes only for a source the preview loaded in full. A paged or search-filtered preview must not report notes for rows it didn't load. 3. **Re-cut chat pieces:** when a chat piece's note is outdated because its text now sits in another piece, should it offer "merge into that piece" instead of only remove? ## Why should this be optional? It lives in the Long-Term Memory package, which is already optional. Within the package it adds no setting: it only reports what is already true and asks before removing anything. ## Alternatives considered - **Remove the notes automatically:** rejected. A source can disappear briefly, for example during a lorebook re-import, and memories the user edited or approved would be lost. - **Keep the stored first message of a chat piece alive in the piece naming:** #1747 does this for edits and deletions before a piece. It can't help when the stored first message itself is deleted, and doesn't cover the other source kinds. ## Additional context Follow-up from the Dottore review of #1747 (LTM 1.5.0). It was left out of that PR because it covers every source kind, not only chat messages. Proof: a regression for each source kind that imports a source, deletes it (or its entry), previews, and expects the note reported as outdated. A paged or filtered preview must not report it. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-11-07 16:36:18 +07:00
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#1732
No description provided.