[GH-ISSUE #5372] [Issue]: Agent prompts HTML-escape lorebook entry tags before sending them to the model #2974

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

Originally created by @SpicyMarinara on GitHub (Aug 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5372

Originally assigned to: @SpicyMarinara on GitHub.

Problem

Lorebook entry content reaches the main assembled prompt verbatim, but the same activated content is HTML-entity escaped when added to agent prompts. Authored tags such as </dottore_lore> and <mari_lore> become &lt;/dottore_lore&gt; and &lt;mari_lore&gt; before the agent model receives them. Reasoning output may then render the underscore as \_, exposing the full regression signature.

The stored lorebook row remains correct; corruption occurs only while building agent prompt context.

Root cause

packages/server/src/services/agents/agent-executor.ts still calls escapeXml(...) on lorebook entry bodies in activated, triggered, and Lorebook Keeper existing-entry contexts. This escaped user-authored prompt leaf content was not covered by the earlier main-prompt fix in #3765.

Expected behavior

User-authored lorebook entry bodies reach every model verbatim. Structural attribute values such as entry IDs and names remain escaped.

Acceptance criteria

  • Activated lorebook context preserves literal <, >, &, and underscores in entry content.
  • Per-agent triggered lorebook context preserves the same content verbatim.
  • Lorebook Keeper existing-entry bodies preserve the same content verbatim.
  • Structural XML attribute escaping remains unchanged.
  • A focused regression locks the exact </dottore_lore> / <mari_lore> case.
Originally created by @SpicyMarinara on GitHub (Aug 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5372 Originally assigned to: @SpicyMarinara on GitHub. ## Problem Lorebook entry content reaches the main assembled prompt verbatim, but the same activated content is HTML-entity escaped when added to agent prompts. Authored tags such as `</dottore_lore>` and `<mari_lore>` become `&lt;/dottore_lore&gt;` and `&lt;mari_lore&gt;` before the agent model receives them. Reasoning output may then render the underscore as `\_`, exposing the full regression signature. The stored lorebook row remains correct; corruption occurs only while building agent prompt context. ## Root cause `packages/server/src/services/agents/agent-executor.ts` still calls `escapeXml(...)` on lorebook entry bodies in activated, triggered, and Lorebook Keeper existing-entry contexts. This escaped user-authored prompt leaf content was not covered by the earlier main-prompt fix in #3765. ## Expected behavior User-authored lorebook entry bodies reach every model verbatim. Structural attribute values such as entry IDs and names remain escaped. ## Acceptance criteria - Activated lorebook context preserves literal `<`, `>`, `&`, and underscores in entry content. - Per-agent triggered lorebook context preserves the same content verbatim. - Lorebook Keeper existing-entry bodies preserve the same content verbatim. - Structural XML attribute escaping remains unchanged. - A focused regression locks the exact `</dottore_lore>` / `<mari_lore>` case.
bsakaguchi 2026-10-21 05:58:28 +07:00
Author
Owner

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

Landed on staging via #5373.

<!-- gh-comment-id:5375944608 --> @SpicyMarinara commented on GitHub (Aug 21, 2026): Landed on staging via #5373.
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#2974
No description provided.