mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3052] [Issue]: Custom impersonate prompt drops a whole line (including co-located text) when a placeholder has an empty value #1621
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#1621
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 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3052
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
The impersonate-instruction renderer removes placeholders with an empty value at the whole-line level: if
{{persona_description}}(and the persona has no description) or{{impersonate_direction}}(and there is no steering direction) appears anywhere on a line, that ENTIRE line is dropped — including any other instruction text or other placeholders the user put on the same line. With a custom impersonate prompt that places a placeholder inline with meaningful text (e.g.Stay in character as {{user}} ({{persona_description}}) and reply.), an empty persona description silently deletes the whole "Stay in character as … and reply." instruction. The default prompt is unaffected (its placeholders sit on their own lines), so this only bites user-authored custom impersonate prompts.How to reproduce (try it yourself)
Write {{user}}'s reply ({{persona_description}}) staying in character.personaDescriptionis empty), and impersonate without a steering direction.You'll see: the entire line — including
Write {{user}}'s reply … staying in character.— is gone, because the empty{{persona_description}}caused the whole line to be filtered out.Expected: only the empty placeholder is removed; the surrounding instruction text (and the resolved
{{user}}) is preserved.Where it is
packages/server/src/services/conversation/impersonate-prompt.ts:48-62—renderImpersonateTemplatesplits the template into lines and, in the.filterat lines 50-53, drops any whole line containing{{persona_description}}whenpersonaDescriptionis empty (line 51) or{{impersonate_direction}}whendirectionis empty (line 52), BEFORE the placeholder replacement at lines 55-60. Reached via the custom-prompt path inbuildImpersonateInstruction(lines 76-84).What's happening
The empty-value cleanup is line-granular, not placeholder-granular. It was written assuming each removable placeholder occupies its own line (true for
DEFAULT_IMPERSONATE_PROMPT), but a custom template can legitimately put a placeholder inline with other content, and the filter removes that content along with the empty placeholder.Suggested fix
Drop a line only when an empty-valued placeholder was its sole meaningful content; otherwise keep the line and let the replacement turn the empty placeholder into an empty string. Replace
renderImpersonateTemplate's body (lines 48-62):This preserves the previous behavior for placeholder-only lines (a bare
{{persona_description}}/{{impersonate_direction}}line with an empty value is still removed, so no blank line is left), while a line that also carries instruction text or{{user}}is now kept and the empty placeholder simply renders as "". The default prompt round-trips identically (its removable placeholders are alone on their lines). When the value is non-empty, the line was never filtered before and still isn't.AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Claiming this for the current staging sweep in draft PR #3053 (branch
codex/issue-sweep-3033-3052).@SpicyMarinara commented on GitHub (Jun 29, 2026):
Fixed in PR #3053 on branch
codex/issue-sweep-3033-3052(commitbfb1bc76). Closing this issue as addressed; the PR remains open for staging review/merge.