mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6288] Deleted chat messages leave agent-written lorebook entries live (no attribution, no cascade) #3508
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#3508
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Ejmathewp on GitHub (Sep 17, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6288
Originally assigned to: @SpicyMarinara on GitHub.
Symptom
After deleting an assistant message (or regenerating/swiping it away), subsequent generations are still steered by "facts" the lorebook-keeper extracted from the deleted turn. Entries keep being injected into the prompt — including when the keeper rewrote an older, innocent entry in place, so even triaging entries by creation date misses carriers — and the model argues with the user's corrections using current-state lore that no longer has a source.
Root cause
DELETE /api/chats/:chatId/messages/:messageId->storage.removeMessage()(packages/server/src/services/storage/chats.storage.ts) only:invalidateMemoryChunksFrom()(memory-recall layer)Advanced Memory records are NOT the problem:
recordValid()inpackages/server/src/services/advanced-memory.tsfingerprints covered message ids and self-invalidates records when a source message disappears.Agent lorebook writes have no message linkage:
createLorebookEntryWriter(packages/server/src/services/generation/tool-resolution-runtime.ts) persists vialorebooksStore.createEntry()— no source-message field on entries.Message deletion therefore never cascades to these entries. Same gap on the regenerate/swipe-discard path: entries written during a discarded attempt survive it.
Proposed fix
createEntry/updateEntry).removeMessage/removeMessages(and the swipe/regenerate path), stale-mark or delete agent-authored entries whose source range intersects the removed messages (manual entries left untouched).Workaround until fixed
Treat message deletion and lore purge as one manual operation: find entries created (or updated) at the deleted generation's timestamp, delete/patch them, then
POST /api/generate/dryRun {"chatId":"...","returnPrompt":true}and grep the joined prompt to confirm the content is gone.@SpicyMarinara commented on GitHub (Sep 17, 2026):
Implemented in #6289 and included in the staging sweep #6295. Agent lore now records message/swipe sources; deletion removes new entries or restores the prior snapshot, inactive swipes are excluded, and human edits are preserved. Regression coverage includes tool writes made before the reply is saved, scoped and partial bulk deletion, concurrent metadata edits and stale embeddings. Legacy entries without provenance are preserved because their sources cannot be reconstructed reliably.