[GH-ISSUE #837] [Issue]: Lorebook depth 0 entries show as active but are not injected into prompts #404

Closed
opened 2026-10-20 17:28:28 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (May 14, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/837

Summary

A Discord forum report describes Lorebook / World Info entries that activate correctly and appear in the Active World Info UI, but are omitted from the final prompt when the entry uses depth injection with depth: 0.

Local source inspection supports the report: depth-based lorebook entries are filtered with a.entry.depth > 0, so activated depth-0 entries never reach injectAtDepth even though the injector documents depth 0 as valid.

Expected behavior

When a Lorebook entry is activated and configured for depth injection at depth: 0, it should be injected into the generated prompt at the documented depth-0 position.

Changing the same entry from depth: 0 to depth: 1 should only change placement, not whether the entry is injected at all.

Actual behavior

The entry appears in Active World Info, but the final prompt inspected through Settings -> Advanced -> Debug Mode does not include the entry when depth: 0.

Changing the same entry to depth: 1 causes it to appear in the final prompt.

Steps to reproduce

  1. In Roleplay mode, attach or create a Lorebook with an entry that can activate.
  2. Configure the entry for depth injection (position: 2) with depth: 0.
  3. Trigger the entry and confirm it appears in the Active World Info UI.
  4. Enable Settings -> Advanced -> Debug Mode and inspect the final prompt / console output.
  5. Confirm the activated entry is missing from the prompt.
  6. Change the same entry to depth: 1, trigger it again, and confirm it is injected.

Environment

  • Marinara Engine version: v1.5.9
  • Install type: Official Windows installer (Marinara-Engine-Installer-1.5.9.exe)
  • OS + version: Windows 10
  • Browser or app shell: Desktop app shell / official installer
  • Chat mode: Roleplay

Logs, screenshots, or video

Reported verification source:

  • Active World Info UI shows the entry as active.
  • Settings -> Advanced -> Debug Mode final prompt and console output show it is missing at depth: 0.
  • The same entry appears in the final prompt at depth: 1.

Additional context

Code trail from local investigation:

  • packages/shared/src/schemas/lorebook.schema.ts allows depth values down to 0:
    • depth: z.number().int().min(0).default(4)
  • packages/server/src/services/lorebook/prompt-injector.ts documents depth 0 as valid:
    • Depth 0 = after the last message, depth 1 = before the last message, etc.
  • injectAtDepth can already place depth-0 injections with result.length - depth.
  • However, getDepthInjectedEntries currently excludes lorebook entries at depth 0:
    • .filter((a) => a.entry.position >= 2 && a.entry.depth > 0)
  • Other generation code already uses injectAtDepth(... depth: 0 ...) for pre-generation agent context, which suggests the shared injector supports this case.

Likely fix direction: change the depth-entry filter to include depth >= 0, and add focused coverage so processActivatedEntries returns depth-0 entries and injectAtDepth places them as documented.

Related historical issue: #27 was a broader closed lorebook activation report, but this appears to be a distinct, narrower depth-0 injection bug.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (May 14, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/837 ## Summary A Discord forum report describes Lorebook / World Info entries that activate correctly and appear in the Active World Info UI, but are omitted from the final prompt when the entry uses depth injection with `depth: 0`. Local source inspection supports the report: depth-based lorebook entries are filtered with `a.entry.depth > 0`, so activated depth-0 entries never reach `injectAtDepth` even though the injector documents depth 0 as valid. ## Expected behavior When a Lorebook entry is activated and configured for depth injection at `depth: 0`, it should be injected into the generated prompt at the documented depth-0 position. Changing the same entry from `depth: 0` to `depth: 1` should only change placement, not whether the entry is injected at all. ## Actual behavior The entry appears in Active World Info, but the final prompt inspected through Settings -> Advanced -> Debug Mode does not include the entry when `depth: 0`. Changing the same entry to `depth: 1` causes it to appear in the final prompt. ## Steps to reproduce 1. In Roleplay mode, attach or create a Lorebook with an entry that can activate. 2. Configure the entry for depth injection (`position: 2`) with `depth: 0`. 3. Trigger the entry and confirm it appears in the Active World Info UI. 4. Enable Settings -> Advanced -> Debug Mode and inspect the final prompt / console output. 5. Confirm the activated entry is missing from the prompt. 6. Change the same entry to `depth: 1`, trigger it again, and confirm it is injected. ## Environment - Marinara Engine version: v1.5.9 - Install type: Official Windows installer (`Marinara-Engine-Installer-1.5.9.exe`) - OS + version: Windows 10 - Browser or app shell: Desktop app shell / official installer - Chat mode: Roleplay ## Logs, screenshots, or video Reported verification source: - Active World Info UI shows the entry as active. - Settings -> Advanced -> Debug Mode final prompt and console output show it is missing at `depth: 0`. - The same entry appears in the final prompt at `depth: 1`. ## Additional context Code trail from local investigation: - `packages/shared/src/schemas/lorebook.schema.ts` allows `depth` values down to 0: - `depth: z.number().int().min(0).default(4)` - `packages/server/src/services/lorebook/prompt-injector.ts` documents depth 0 as valid: - `Depth 0 = after the last message, depth 1 = before the last message, etc.` - `injectAtDepth` can already place depth-0 injections with `result.length - depth`. - However, `getDepthInjectedEntries` currently excludes lorebook entries at depth 0: - `.filter((a) => a.entry.position >= 2 && a.entry.depth > 0)` - Other generation code already uses `injectAtDepth(... depth: 0 ...)` for pre-generation agent context, which suggests the shared injector supports this case. Likely fix direction: change the depth-entry filter to include `depth >= 0`, and add focused coverage so `processActivatedEntries` returns depth-0 entries and `injectAtDepth` places them as documented. Related historical issue: #27 was a broader closed lorebook activation report, but this appears to be a distinct, narrower depth-0 injection bug. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:28:28 +07:00
  • closed this issue
  • added the
    server
    bug
    labels
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#404
No description provided.