mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5363] [Issue]: Lore book keeper make lot of lore books with same name #2967
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#2967
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 @szaki2 on GitHub (Aug 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5363
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Professor Mari: :D
The Lorebook Keeper's auto-create feature enters a feedback loop: every Keeper run re-creates the same category lorebooks (NPC Registry, World Lore, Scene Log, Player Character) because auto-created lorebooks never appear back in the <writable_lorebooks> list on subsequent Keeper runs. This produced 33 duplicate lorebooks in 9 runs, all with identical names.

Root cause
When the Keeper uses a targetLorebook alias (e.g. "npc", "world", "scene", "player"), the system auto-creates the appropriately named lorebook (e.g. "The Farm — NPC Registry"). This works. However, on the next Keeper run, the newly created lorebook does NOT appear in the <writable_lorebooks> block — most likely because auto-created lorebooks are not automatically linked to the chat, and <writable_lorebooks> only includes chat-linked lorebooks.
This creates a feedback loop:
Run 1: <writable_lorebooks> has no NPC book → Keeper uses "npc" alias → system auto-creates "The Farm — NPC Registry"
Run 2: <writable_lorebooks> still doesn't include the NPC book created in run 1 → Keeper uses "npc" alias again → system auto-creates ANOTHER "The Farm — NPC Registry"
Run 3: same thing... and so on, 9 runs × 3–4 books = 33 duplicates
Expected behavior (feature request)
The intended workflow is:
Classify: The Keeper identifies whether a fact belongs to the NPC / world lore / scene / player category.
Search existing books: The Keeper checks <writable_lorebooks> for a book matching that category (e.g. a book whose name contains "NPC Registry").
If a matching book EXISTS: The Keeper writes the entry into that existing book — never creates a new one.
If no matching book exists: The Keeper uses the alias to auto-create it, and the system registers the auto-created lorebook back into <writable_lorebooks> for the next run (by linking it to the chat).
The critical fix: Auto-created lorebooks must be linked to the chat automatically so they appear in <writable_lorebooks> on subsequent Keeper runs. Without this, the auto-create feature is unusable — it duplicates on every single run.
Intended setup:
1 original lorebook (imported from SillyTavern, never modified by the Keeper)
4 category lorebooks (NPC Registry, World Lore, Scene Log, Player Character)
First Keeper run auto-creates the 4 category books
Every subsequent run writes into the already-existing books — no duplicates
Steps to reproduce
Enable Lorebook Keeper on a Roleplay chat
Modify the Keeper prompt to classify every fact and route using aliases (see prompt below)
Play 5–10 turns
Check the lorebook list — 20–30+ duplicate lorebooks will exist, all with the same names
Environment
Marinara Engine version: 2.4.4
Install type: Docker
OS + version: QNAP NAS
Browser or app shell: Browser
LLM: GLM 5.2 Thinking (zai-org/glm-5.2:thinking)
Keeper prompt (modified, triggers the bug):
(your full prompt as you already pasted it)
Additional context
The default Pasta Devs prompt is more conservative — it makes targetLorebook optional and only suggests using aliases "when the user's instructions ask you to separate lore by category." Our modified prompt made classification mandatory for every fact, which amplified the feedback loop exponentially.
However, the root cause is NOT the prompt — the prompt merely exposed the bug. The root cause is that auto-created lorebooks are not registered back into <writable_lorebooks>. If this were fixed, our prompt would work correctly: the first run would create the 4 category books, and every subsequent run would write into the existing ones.
@SpicyMarinara commented on GitHub (Aug 21, 2026):
Resolved by #5367, merged into staging as
448042c2dc.