mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2970] [Issue]: Lorebook Keeper approval updates overwrite existing entry content instead of appending, destroying accumulated lore #1545
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#1545
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 @kolacheee on GitHub (Jun 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2970
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
When a chat has agent write approval enabled (
chatMeta.agentWriteApprovalRequired === true), approving a Lorebook Keeper update to an existing, populated entry replaces that entry's entire content with only the newly-extracted facts. All prior content the entry accumulated over many turns is lost. The same model output, with approval off, correctly appends. So enabling approval silently turns appends into destructive overwrites.How to reproduce (try it yourself)
chatMeta.agentWriteApprovalRequired = true) and enable the Lorebook Keeper agent.{"entryName":"Castle","newFacts":["A secret passage was found."]}.You'll see: the "Castle" entry now contains only "A secret passage was found." — every earlier paragraph is gone.
Expected: the new fact is appended to the existing content (the behavior you get with approval off).
Where it is
packages/server/src/routes/generate/agent-write-approval.ts:24-33—readUpdateContentflattensnewFactsinto a markdown bullet string, never including existing content.packages/server/src/routes/generate/agent-write-approval.ts:61-77—formatLorebookWriteApprovalTextputs only that flattened-facts string into the proposal.packages/server/src/routes/generate/agent-write-approval.ts:134-140—parseLorebookWriteApprovalTextre-wraps the approved text as{ action: "update", content: <flattened facts> }.packages/server/src/routes/generate/lorebook-keeper-utils.ts:307-313(getExplicitUpdateReplacementContent) and:407-414(existing-entry branch) — anyaction:"update"with non-empty top-levelcontentshort-circuitsmergeLorebookKeeperUpdateContentand becomes a full replacement.packages/server/src/routes/chats.routes.ts:1101-1124(parseLorebookWriteApprovalText(text)→persistLorebookKeeperUpdates(... updates)).What's happening
The non-approval path passes the raw model update (
{entryName, newFacts}) straight topersistLorebookKeeperUpdates, sogetExplicitUpdateReplacementContentreturns null (no top-levelcontent) and the merge appends. The approval round-trip instead flattens the update into a markdown proposal containing only the new facts, thenparseLorebookWriteApprovalTextre-wraps it asaction:"update"+ that text incontent. On commit,getExplicitUpdateReplacementContenttreatsaction:"update"+ non-emptycontentas a full replacement, bypassing the merge. The append intent is lost in the approval serialization, and the existing content is never shown in the proposal, so the user has no way to know it's about to be wiped.Suggested fix
Make the proposal what-you-see-is-what-you-commit. The cleanest fix is to build the proposal text from the merged (existing + new) content rather than the new facts alone — i.e. in
markLorebookResultForApproval/readUpdateContent, seed the proposal with the existing entry content plus the new facts, so the committed full-replacement is exactly the content the user reviewed (and can edit).Alternatively, preserve the append semantics across the round-trip: have
parseLorebookWriteApprovalTextemit the parsed facts asnewFacts(oraction:"append") instead ofaction:"update"+content, sopersistLorebookKeeperUpdatesmerges with existing content. (Note: with this approach, if the user edited the proposal text intending a rewrite, the edit would be appended rather than replacing — which is why surfacing the existing content in the proposal, option one, is the more predictable fix.)AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Fixed in the v2.0.7 branch: approval-gated Lorebook Keeper text is now parsed as append-style approved lore instead of an explicit replacement, so approving new facts no longer overwrites existing entry content. Validated with pnpm check and pnpm regression:prompt.