mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3766] Angle brackets in cards, personas, and lorebooks get mangled to < before reaching the model #2030
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#2030
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 @kolacheee on GitHub (Jul 18, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3766
Originally assigned to: @kolacheee on GitHub.
If you type an angle bracket into a character card field, a persona/user description, a lorebook entry, or example dialogue, the model doesn't get what you typed. A
<is turned into<and a&into&before the prompt is sent.That matters because a lot of people organize their cards and lorebooks with angle-bracket / HTML-style tags like
<thinking>,<scenario>, or<div>, and some cards use inline HTML like<font color=...>for styling. All of that reaches the model garbled — it sees<thinking>and<font color=...>— so tag-based structure and HTML formatting break in the reply. The prompt viewer also shows the literal<, and the escaped entities waste tokens.This happens whenever the Conversation preset uses the default XML wrap format, which is the out-of-the-box setup.
Try it yourself (on released v2.3.3)
<test>in its description. (A character card field or a lorebook entry works too.)<test>where you typed<test>. That's exactly what the model receives.This affects "leaf" content generally: character card fields (description, personality, scenario, etc.), the persona / user description, lorebook entries, recalled memories, scene text, and example dialogue.
Why it happens (short note)
In
packages/server/src/services/prompt/prompt-escaping.ts, the functionescapeXmlTextrunsvalue.replace(/&/g,'&').replace(/</g,'<')on this leaf content and is applied to the XML-wrapped path viasanitizePromptLeaf. It was originally added as a prompt-injection guard against untrusted imported cards — but for a local single-user tool that "injection" is at most a rare, self-fixable annoyance (you see the weird output and edit your own card), while the escaping corrupts the very common, legitimate use of tags in cards and lorebooks. Leaf content should reach the model verbatim.This exact behavior has been broken and re-fixed several times, because each pass only partially carved out the guard (dropping
>, exempting the<START>example-dialogue marker, decoding on the display layer in #3206) instead of removing it — so the<escaping kept surviving.Not part of this bug
The agent value/attribute escapers that feed strictly machine-parsed XML — agent world-state, knowledge/entry catalogs, storyboard sections, attachment attributes — are correct to keep escaping and should stay as they are. This is only about the human-authored prompt leaf path.
Fix
A fix is already open in #3765: it makes leaf content verbatim and hardens the code so this stops recurring — https://github.com/Pasta-Devs/Marinara-Engine/pull/3765