mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3452] [Issue]: Game-mode chats with no persona leak the globally active persona into combat, scenes, snapshots, and exports #1866
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#1866
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 10, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3452
Originally assigned to: @kolacheee on GitHub.
Summary
Game Mode chats created without a persona (
chat.personaId = null— a designed state: persona selection is optional in the setup wizard, andgame.routes.tsexplicitly stores "null = no persona") still leak the globally active persona into several server paths: combat encounter prompts, scene planning prompts, per-messagepersonaSnapshotstamps, transcript exports, and memory-recall labels. The main GM generation and the client display both correctly treat these chats as persona-less, so the model receives persona data in some generations that the user never selected and the screen never shows.Expected behavior
A Game Mode chat with
personaId = nulluses no persona anywhere. That is the documented convention:packages/server/src/routes/generate.routes.ts:1101-1103— main generation skips the active-persona fallback in game mode, with the comment "Game mode skips the fallback — persona must be explicitly selected in the setup wizard".packages/server/src/routes/generate/retry-agents-route.ts:484— same guard (added for #2989).packages/server/src/routes/lorebooks.routes.ts:845-854— same guard.packages/server/src/routes/game.routes.ts:5896-5902— game creation comment: "Use only the persona explicitly selected in the wizard (null = no persona)".packages/client/src/components/chat/ChatArea.tsx:982-984skips the fallback in game mode;packages/client/src/components/game/GameSurface.tsx:7066-7075shows a default "Player" entry when no persona is selected.Actual behavior
Live-verified on staging @
7bb4ab66f(v2.1.2) with a game chat wherepersonaId = null, one character in the party, and an unrelated persona ("Astra Vex", with marker strings in its description/personality) marked globally active:POST /api/encounter/initsent my mock LLM a prompt containing<persona>\nName: Astra Vex\nASTRA_PERSONA_MARKER: ...\nASTRA_PERSONALITY_MARKER: ...\n</persona>, and the prompt instructs the model to narrate that persona's actions by name. Cause:packages/server/src/routes/encounter.routes.ts:162-166(buildPersonaContextfalls back toisActive === "true"with no mode guard; used by/init,/action,/summaryat lines 571, 666, 764). The persona's configured HP/stats are also surfaced (lines 177-190).POST /api/scene/planon the same game chat sent a prompt containing the Astra marker. Cause:packages/server/src/routes/scene.routes.ts:134-144— thisbuildPersonaContextnever even readschat.personaId; it always uses the active persona (so it is also wrong for non-game chats with an explicit per-chat persona). Used by/create,/conclude,/planat lines 299, 394, 764.personaSnapshot. Both the generation path (packages/server/src/routes/generate.routes.ts:649-654) and the plain message-create route (packages/server/src/routes/chats.routes.ts:335-343via lines 1601-1607) stampedpersonaSnapshot: Astra Vexonto user messages in the persona-less game chat. The client mirrors this in its optimistic message (packages/client/src/hooks/use-generate.ts:1090-1094, also unguarded), andpackages/client/src/components/chat/ChatMessage.tsx:1471-1478prefers the snapshot for the displayed user name and{{user}}macro context.{{user}}to the active persona. The sharpest contrast, same chat, same message: the real generation prompt (guarded) rendered{{user}} draws a blade.as "User draws a blade.", whileGET /api/chats/:id/export?format=textrendered it as "Astra Vex draws a blade." Cause:packages/server/src/routes/chats.routes.ts:2803-2812(buildPersonaSnapshotForChat, no mode guard at lines 338-341).packages/server/src/routes/chats.routes.ts:1547-1551(not live-verified; identical unguarded pattern feedinguserNameintorebuildMemoryChunks).Latent (live-verified as not currently user-visible, noted for completeness): the dry-run route (
packages/server/src/routes/generate/dry-run-route.ts:713-716, whose comment claims "same strategy as generation"; already flagged as a follow-up in #2989), the peek-prompt route (packages/server/src/routes/chats.routes.ts:2064-2067), and the preset-preview route (packages/server/src/routes/prompts.routes.ts:318-320) all resolve the persona with the unguarded fallback, but the game prompt assembly does not render those variables today — dry-run and peek responses for the game chat contained zero persona markers.Control check: a roleplay chat with
personaId = nullcorrectly received the active persona in its generation prompt — the global fallback itself is intended behavior outside Game Mode; only the missing game guard is the bug.Steps to reproduce
POST /api/characters/personas, thenPUT /api/characters/personas/:id/activate) — or just have any active persona, as most users do.GameSetupWizard.tsx:1468), orPOST /api/game/createwith asetupConfigthat omitspersonaId. The returned session chat has"mode":"game","personaId":null.POST /api/generate) — the outbound prompt contains no persona (correct), and the game UI shows "Player".POST /api/encounter/initwith{"chatId":"<gameChatId>","settings":{"historyDepth":8}}— the outbound prompt contains a<persona>block with the active persona's name, description, personality, and stats.{{user}}andGET /api/chats/<gameChatId>/export?format=text— the macro resolves to the active persona's name, unlike the real prompt.extra—personaSnapshotis the active persona.Environment
7bb4ab66f)pnpm dev, server only, driven via API)Logs, screenshots, or video
Captured outbound combat-init prompt (system message excerpt) for the persona-less game chat:
Same-chat contrast for the message
{{user}} draws a blade.:Captured main-generation prompt for the same chat: zero occurrences of the persona. Stored message extra:
personaSnapshot: { name: "Astra Vex", personaId: "0TTEk66_..." }.Additional context
buildPersonaContextpreferchat.personaId, but kept the unguarded active fallback.mode !== "game"gate used atgenerate.routes.ts:1101-1103to each remaining fallback site (the chat row withmodeis already in scope at every one), and makescene.routes.ts'sbuildPersonaContextadditionally prefer the chat-scoped persona like its encounter counterpart already does.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@kolacheee commented on GitHub (Jul 10, 2026):
Draft PR is up: #3454 (fork branch
kolacheee:fix/game-persona-fallback-3452, targetingstaging). All leak paths from the matrix above re-verified clean after the fix; the roleplay fallback and explicit game-persona paths verified unchanged. — owning this one (@kolacheee)