[GH-ISSUE #2886] [Issue]: Preset instructions contaminate context in impersonation mode #1469

Closed
opened 2026-10-21 05:36:02 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @WhatsUpJerks on GitHub (Jun 27, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2886

Originally assigned to: @SpicyMarinara on GitHub.

Summary

When using /impersonate in RP mode, the preset is still injected including any rules like "You are [char], respond only as [char]". Then the impersonate prompt is added at the end, saying "You are [user]", which causes LLMs to loop or get confused and respond inappropriately.

Expected behavior

Impersonation should not include conflicting system prompt instructions.

Actual behavior

Cross-contamination occurs

Steps to reproduce

  1. See above

Environment

  • Marinara Engine version: 2.0.5
  • Install type: (source / installer / docker / termux / other) source
  • OS + version: Windows 11
  • Browser or app shell:

Logs, screenshots, or video

Additional context

I think a reasonable fix is to just exclude the preset entirely when impersonating:
(assembler.ts):
Add a new flag for whether it's impersonation mode, then
if (input.impersonateMode && section.isMarker !== "true") continue;
when assembling the system prompt from the preset, but I don't want to open a PR if this is a really stupid or inappropriate method so I'm leaving it to the experts to decide how to approach this.

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 @WhatsUpJerks on GitHub (Jun 27, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2886 Originally assigned to: @SpicyMarinara on GitHub. ## Summary <!-- What is wrong in one or two sentences? --> When using /impersonate in RP mode, the preset is still injected including any rules like "You are [char], respond only as [char]". Then the impersonate prompt is added at the end, saying "You are [user]", which causes LLMs to loop or get confused and respond inappropriately. ## Expected behavior <!-- What should have happened? --> Impersonation should not include conflicting system prompt instructions. ## Actual behavior <!-- What happened instead? --> Cross-contamination occurs ## Steps to reproduce 1. See above 2. 3. ## Environment - Marinara Engine version: 2.0.5 - Install type: (source / installer / docker / termux / other) source - OS + version: Windows 11 - Browser or app shell: ## Logs, screenshots, or video <!-- Paste relevant logs and add screenshots when possible --> ## Additional context <!-- Optional: related issue links, temporary workaround, etc. --> I *think* a reasonable fix is to just exclude the preset entirely when impersonating: (assembler.ts): Add a new flag for whether it's impersonation mode, then `if (input.impersonateMode && section.isMarker !== "true") continue;` when assembling the system prompt from the preset, but I don't want to open a PR if this is a really stupid or inappropriate method so I'm leaving it to the experts to decide how to approach this. ## 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-21 05:36:02 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@SpicyMarinara commented on GitHub (Jun 28, 2026):

Ah, yes, I can see how presets may conflict with the impersonate command. Ditching the entire system prompt may result in subpar results, but there's no other easy way around it.

<!-- gh-comment-id:4825484051 --> @SpicyMarinara commented on GitHub (Jun 28, 2026): Ah, yes, I can see how presets may conflict with the impersonate command. Ditching the entire system prompt may result in subpar results, but there's no other easy way around it.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 28, 2026):

Fixed in the local staging branch: preset-driven impersonation now tells the prompt assembler to skip regular preset sections while preserving marker sections such as chat history and contextual markers. This prevents regular preset text like assistant-role instructions from conflicting with the final /impersonate instruction. Added a prompt regression for this path and the #2886 changelog note.\n\nValidation:\n- pnpm regression:prompt\n- pnpm --filter @marinara-engine/server lint

<!-- gh-comment-id:4825527051 --> @SpicyMarinara commented on GitHub (Jun 28, 2026): Fixed in the local staging branch: preset-driven impersonation now tells the prompt assembler to skip regular preset sections while preserving marker sections such as chat history and contextual markers. This prevents regular preset text like assistant-role instructions from conflicting with the final /impersonate instruction. Added a prompt regression for this path and the #2886 changelog note.\n\nValidation:\n- pnpm regression:prompt\n- pnpm --filter @marinara-engine/server lint
Author
Owner

@WhatsUpJerks commented on GitHub (Jun 28, 2026):

Awesome, thank you! It's good to see that my idea was actually more or less the "best" way to handle it. Maybe I'll be brave enough to open a PR of my own someday.

<!-- gh-comment-id:4826482963 --> @WhatsUpJerks commented on GitHub (Jun 28, 2026): Awesome, thank you! It's good to see that my idea was actually more or less the "best" way to handle it. Maybe I'll be brave enough to open a PR of my own someday.
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#1469
No description provided.