mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #3454] [MERGED] Skip active-persona fallback for persona-less game chats #5947
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#5947
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3454
Author: @kolacheee
Created: 7/10/2026
Status: ✅ Merged
Merged: 7/11/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/game-persona-fallback-3452📝 Commits (3)
0ca71cfSkip active-persona fallback for persona-less game chats76ac1e8Merge branch 'staging' into fix/game-persona-fallback-34526991675Centralize game-aware persona selection📊 Changes
8 files changed (+83 additions, -43 deletions)
View changed files
📝
packages/client/src/hooks/use-generate.ts(+4 -1)📝
packages/server/src/routes/chats.routes.ts(+10 -10)📝
packages/server/src/routes/encounter.routes.ts(+14 -7)📝
packages/server/src/routes/generate.routes.ts(+4 -6)📝
packages/server/src/routes/generate/dry-run-route.ts(+2 -3)📝
packages/server/src/routes/generate/generate-route-utils.ts(+18 -0)📝
packages/server/src/routes/prompts.routes.ts(+2 -3)📝
packages/server/src/routes/scene.routes.ts(+29 -13)📄 Description
Linked issue
Closes #3452
Why this change
A Game Mode chat created without a persona (
chat.personaId = null— a designed state: persona selection is optional in the setup wizard, and game creation stores "null = no persona") was still leaking the globally active persona into several generation and serialization paths. The main GM generation and the client display both already treat these chats as persona-less, so the model was receiving persona data in combat and scene prompts that the user never selected and the screen never shows, exported transcripts resolved{{user}}to the wrong name, and user messages were stamped with apersonaSnapshotof a persona that was never part of the chat. Full analysis and a live reproduction matrix are in #3452.This PR applies the same
mode !== "game"gate that the main generation path already uses (generate.routes.ts— "Game mode skips the fallback — persona must be explicitly selected in the setup wizard", andretry-agents-route.tssince #2989) to the remaining unguarded active-persona fallbacks. Outside Game Mode the fallback behavior is unchanged, and a game with an explicitly selected persona is unaffected (the chat-scoped persona resolves before the guard is consulted).What changed
packages/server/src/routes/chats.routes.tsbuildPersonaSnapshotForChat(feedspersonaSnapshotstamping on user messages and{{user}}/persona macro context in transcript exports) now skips the active-persona fallback for game chats./:id/memories/rebuildpath) no longer labels user turns with the active persona's name in persona-less game chats./:id/peek-promptpersona resolution gets the same guard (latent today — the game prompt assembly doesn't render it — but now matches generation).packages/server/src/routes/generate.routes.ts— the per-messagepersonaSnapshotstamped during generation uses the same game-mode guard as the prompt's own persona resolution a few lines below.packages/server/src/routes/generate/dry-run-route.ts— the dry-run persona resolution now actually matches its "same strategy as generation" comment (follow-up explicitly deferred in #2989).packages/server/src/routes/encounter.routes.ts—buildPersonaContexttakes the chat mode and skips the fallback for game chats; all three call sites (/init,/action,/summary) passchat.mode. A persona-less game now gets "No persona information available." in the<persona>block instead of the active persona's card and stats.packages/server/src/routes/scene.routes.ts—buildPersonaContextnow prefers the chat-scoped persona before the active-persona fallback (matching the resolution order everywhere else; previously it only ever used the active persona, which was also wrong for non-game chats with an explicit per-chat persona) and skips the fallback for game chats./createand/planpass the origin chat's persona/mode;/concludepasses the scene chat's inherited persona with the origin chat's mode (scene chats are alwaysroleplay, so the game guard must come from the origin). The origin fetch added for/concludeis deliberately separate from the pre-existing step-4 fetch — that one re-reads the origin after the LLM call so the metadata write doesn't clobber concurrent updates.packages/client/src/hooks/use-generate.ts— the optimistic message'spersonaSnapshotmirrors the server-side guard, so the optimistic render matches what the server persists.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
What I verified live (dev server on Windows, all LLM traffic routed through a local mock OpenAI-compatible endpoint that records every outbound prompt; game chat created via
POST /api/game/createwith nosetupConfig.personaId, persona "Astra Vex" globally active, marker strings in its card):POST /api/encounter/initsent a full<persona>block for Astra Vex;POST /api/scene/planleaked the persona; new user messages were stampedpersonaSnapshot: Astra Vex;GET /:id/export?format=textrendered{{user}}as "Astra Vex" while the actual generation prompt rendered the same message as "User".<persona>\nNo persona information available.\n</persona>(zero marker hits); scene plan prompt has zero marker hits; newly created user messages carry nopersonaSnapshot; export renders{{user}}as "User" (including for messages stamped before the fix, since export resolves at serialization time).personaId = nullstill receives the active persona in its outbound generation prompt (the intended global fallback is untouched); a game chat with an explicitly selected persona still gets that persona's full<persona>block in the combat prompt.pnpm check(typecheck + lint + build) run locally — result noted in the PR conversation.Docs and release impact
No docs or release-file changes are included; this is a behavior fix with no configuration surface.
UI evidence (if applicable)
No visual changes beyond user-message naming in persona-less game chats (server-side prompt/serialization fix); before/after prompt captures are quoted in #3452.
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.