[GH-ISSUE #5363] [Issue]: Lore book keeper make lot of lore books with same name #2967

Closed
opened 2026-10-21 05:58:25 +07:00 by bsakaguchi · 1 comment
Owner

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.
Image

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.

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. <img width="339" height="301" alt="Image" src="https://github.com/user-attachments/assets/cbc03021-135b-4a9c-bd18-876d85fa8843" /> 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.
bsakaguchi 2026-10-21 05:58:25 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Aug 21, 2026):

Resolved by #5367, merged into staging as 448042c2dc.

<!-- gh-comment-id:5374671410 --> @SpicyMarinara commented on GitHub (Aug 21, 2026): Resolved by #5367, merged into staging as 448042c2dced0b50ea28332525b65444e7d321b9.
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-Engine#2967
No description provided.