mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #1979] Anchor lorebook depth injection to chat history bounds #971
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#971
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 @Xelvanis on GitHub (Jun 2, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1979
Originally assigned to: @cha1latte on GitHub.
Problem
Target 7 lorebooks parityscan found a likely depth-injection parity gap.
Legacy anchored
at depthlorebook entries to the chat history window. Refactor anchors depth entries against the full assembled prompt length, after other prompt and injected blocks may already be present.Refactor evidence
src/engine/generation-core/lorebooks/prompt-injector.ts:73-82accepts only messages and depth entries, then computes insertion withmessages.length - entry.depth.src/engine/generation/prompt-assembly.ts:2551-2564inserts conversation/context blocks, then callsinjectAtDepthwithout history bounds.src/engine/generation/prompt-assembly.ts:1925-1928inserts some context blocks before the last user message, which can change the full-message anchor used by depth injection.Legacy behavior
packages/server/src/services/lorebook/prompt-injector.ts:19-24supportedminIndexandanchorIndexoptions.packages/server/src/services/lorebook/prompt-injector.ts:95-104inserted depth entries relative to the bounded anchor.packages/server/src/services/prompt/assembler.ts:458-463passedfindHistoryBounds(finalMessages)intoinjectAtDepth.Impact
Lorebook entries configured for
at depthcan land at a different prompt position when non-history prompt blocks sit after or inside the chat history area. That changes the relative placement expected by legacy/ST-style lorebooks.Expected behavior
Depth injection should be anchored to the chat history bounds when history is present, matching legacy behavior. Fallback to full prompt length only when no history bounds exist.
Suggested fix
Restore bounded depth-injection options, compute history bounds in refactor prompt assembly before injecting lorebook/character/author-note depth entries, and add focused local proof with prompt blocks around history plus an
at depthlorebook entry.Parent: #1904 target 7 lorebooks parityscan.