mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #225] [MERGED] fix(server): inject lorebooks into preset-less roleplay and visual-no… #4514
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#4514
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/225
Author: @Trade-Mottoes
Created: 4/25/2026
Status: ✅ Merged
Merged: 4/26/2026
Merged by: @LukaTheHero
Base:
main← Head:fix/lorebooks-ignored-without-preset📝 Commits (1)
18af276fix(server): inject lorebooks into preset-less roleplay and visual-novel chats📊 Changes
1 file changed (+37 additions, -0 deletions)
View changed files
📝
packages/server/src/routes/generate.routes.ts(+37 -0)📄 Description
Why this change
Active lorebook entries are silently dropped from the prompt for roleplay and visual-novel chats that have no preset assigned. The Active World Info panel cheerfully reports "4 active • ~5,341 tokens" while the model never sees a single one of them — it generates as if the lorebook didn't exist.
The activation scanner is fine: it identifies the right entries, totals their tokens, surfaces them to the UI. The break is one layer deeper. The generation pipeline has lorebook-injection blocks for three paths:
assemblePrompt()expands thelorebookmarker.Preset-less roleplay and visual-novel fall through every gate.
processLorebooks()is never called, no<lore>block is built, and the model gets generated content it has no way to know about. From the user's perspective: lorebooks "don't work" in roleplay/VN unless they happen to assign a preset — which the UI gives them no obvious reason to do.What changed
A single 37-line block added between the conversation-mode lorebook block and Author's Notes injection in
generate.routes.ts:!presetId && (chatMode === "roleplay" || chatMode === "visual_novel")— exactly the modes the existing blocks miss.processLorebooks()with the chat's active lorebook IDs, entry state overrides, and context embedding — the same arguments the conversation and game blocks pass.<lore>block as a system message before the first user/assistant message (mirroring the conversation block's placement).injectAtDepth().The block is a near-duplicate of the conversation and game versions. That duplication is intentional in this PR: the goal is a narrow correctness fix that's trivial to review. A natural follow-up — extracting the three inline copies into a single
injectLorebookContent()helper — is noted in the commit message but deliberately deferred so this PR doesn't sprawl.Validation
pnpm checkManual verification notes
Built a clean-room test fixture: one preset-less roleplay chat, one character (Test Steward), one lorebook with a CONST entry containing invented vocabulary the model can't possibly know from training data ("World: Dolomar-9", "Currency: glints", "Marshal Brunnig the Eleventh"),
enableAgents: falseso no agent can sneak the lore in via a different path.Verified the bug and the fix using a prompt-dumping diagnostic that writes the assembled message array to a JSON file before it reaches the LLM:
<lore>block. The model says "I do not know" when asked for the local currency.<lore>\n…\n</lore>system message ahead of the character info, with the activated CONST entry's text in full. The model correctly answers "glints" and cites Marshal Brunnig.Same chat, same query, same lorebook configuration in both runs. The presence of
<lore>in the prompt is the deterministic discriminator.Docs and release impact
UI evidence (if applicable)
N/A — server-side prompt-assembly fix. No UI surface touched.
Summary by CodeRabbit
New Features
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.