mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2737] [Issue]: Continuity / Prose Guardian rewrite destroys embedded HTML/CSS formatting (gfx) — rewrite agent fed HTML-stripped input, then overwrites the message wholesale #1377
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#1377
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 (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2737
Originally assigned to: @SpicyMarinara on GitHub.
Summary
The Continuity agent (and Prose Guardian, which shares the same rewrite path) deterministically destroys embedded HTML/CSS formatting ("gfx" — custom styled boxes, status bars,
<style>/<div>/<img>blocks) in the assistant message every time it decides a rewrite is needed. This is a code bug, not a prompt/model issue — which is why users report that switching models and "rewriting the prompt" does nothing.Two interacting defects on the post-processing rewrite path:
1. The rewrite agent is fed an HTML-stripped copy of the message
buildAgentMessagesbuilds the<assistant_response>block the rewrite model is asked to reproduce by running the message throughstripHtmlTags:packages/server/src/services/agents/agent-executor.ts:1589—finalParts.push(stripHtmlTags(context.mainResponse));stripHtmlTags(agent-executor.ts:28-33) doestext.replace(/<\/?[a-zA-Z][^>]*>/g, ""), deleting every HTML/XML tag.So by the time the continuity model reads the message, all
<div>/<span>/<style>/<img>markup is already gone, and a<style>open tag is removed while its raw CSS body leaks through as plain text. The model cannot reproduce gfx it was never shown.2. The stripped rewrite overwrites the stored message wholesale
packages/server/src/routes/generate.routes.ts:8817—editedTextis taken raw.:8823—strictEditNeededis true forprose-guardianandcontinuity.:8826-8831— whenchangedMessage,await chats.updateMessageContent(messageId, editedText)replaces the message with the stripped rewrite, with no diff/merge and no HTML restoration. The original is preserved only as a hidden revert snapshot (proseGuardianOriginalText,:8833-8836).packages/server/src/routes/generate/retry-agents-route.ts:2204-2207.The continuity prompt even instructs the model to "Preserve ... tags, and formatting" (
packages/shared/src/constants/agent-prompts.ts:67) — but that is futile because the tags were physically removed from its input at step 1. No code anywhere re-inserts HTML after the rewrite.How it degrades the UX
Users who use HTML/CSS "gfx" in roleplay (styled message frames, HUD/status blocks, images) and run Continuity or Prose Guardian see their formatting wiped on every turn the agent edits — the agent's "greatest joy," as one user put it. The only workaround today is turning the agent off, which users don't want to do. Prompt edits and model swaps can't help because the corruption happens in code before and after the model runs.
Steps to replicate
<div style="...">…</div>status box or a<style>…</style>block).editNeeded: true.Suggested fix
Primary (removes the deterministic corruption): do not
stripHtmlTagsthe rewrite target fortext_rewrite-type agents. InbuildAgentMessages, pass the rawcontext.mainResponseinto the<assistant_response>block when the agent's resolved result type istext_rewrite(continuity + prose-guardian), keeping the strip only for context-only agents (agent-executor.ts:1589, gate onresolveAgentResultType === "text_rewrite"or apreserveAssistantHtmlflag).Defense-in-depth:
generate.routes.ts:8826-8831,retry-agents-route.ts:2204-2207), extract fenced```blocks and HTML/<style>/<div>regions from the original, replace them with placeholders before sending, and re-substitute intoeditedTextafterward; oreditedTextdropped all of them, reject the rewrite (treat aseditNeeded:false) and log a warning, so gfx is never silently destroyed.agent-prompts.ts:64-73) to copy HTML/CSS/<style>/<img>/code-fence markup byte-for-byte (necessary but not sufficient without the primary fix).Template checklist
pnpm checkpasses (TypeScript + ESLint)<div style>/<style>block survives a Continuity rewrite intactReported by users in Discord ("consistency editor messing up gfx"); root-caused and verified by direct read of the
stagingtree at the cited file:line. Boxes left unchecked for human verification.@SpicyMarinara commented on GitHub (Jun 21, 2026):
Addressed in PR #2747.