mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7254] [MERGED] fix(chat): merged group chats label Chat Summary sections by who knows them #7646
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#7646
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/7254
Author: @SpicyMarinara
Created: 10/7/2026
Status: ✅ Merged
Merged: 10/7/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/merged-classic-summary-conditions📝 Commits (6)
c75c366fix(chat): merged group chats label Chat Summary sections by who knows themf9f772afix(chat): keep summary readers for a chosen merged responder and in Peek Prompt02660cefix(chat): keep the single summary reading when a merged character's card cannot be readb4092dfMerge origin/staging into fix/merged-classic-summary-conditionscae2adbfix(chat): keep summary readers when a deleted card's id lingers in a merged chat17d5854Merge origin/staging into fix/merged-classic-summary-conditions📊 Changes
12 files changed (+475 additions, -27 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
docs/agents/memory.md(+2 -0)📝
packages/server/src/routes/chats.routes.ts(+18 -2)📝
packages/server/src/routes/generate.routes.ts(+15 -1)📝
packages/server/src/routes/generate/dry-run-route.ts(+14 -1)📝
packages/server/src/routes/generate/generate-route-utils.ts(+23 -0)📝
packages/server/src/services/advanced-memory.ts(+4 -15)📝
packages/server/src/services/prompt/assembler.ts(+11 -1)📝
packages/server/src/services/prompt/macro-context.ts(+40 -3)📝
packages/server/src/services/prompt/marker-expander.ts(+5 -1)📝
packages/shared/src/utils/macro-engine.ts(+28 -3)➕
scripts/regressions/merged-chat-summary.regression.ts(+314 -0)📄 Description
Linked issue
Closes #7252
Related: #7237, #7239. Translation follow-up: #7253.
Why this change
While building #7239, its builder found that the classic Chat Summary (Advanced Memory off) has the same problem #7239 fixed for Advanced Memory. A merged group chat resolves the summary once, with
{{char}}set to the first character in chat order. Only that character's{{#if char == "Name"}}sections reach the prompt; everyone else's are dropped. When the narrator comes first, narrator-only sections reach the shared prompt instead. Character-scoped sections like these are also what Advanced Memory saves into Chat Summaries, so they stay in the summary after Advanced Memory is turned off.Mari's design for merged group chats (2026-10-07): "things should not break; the who-remembers-what is more informative for the model." A merged reply can voice anyone present, so private content is kept and labelled with who knows it, instead of being evaluated as one arbitrary character. This PR applies that design to the classic Chat Summary with the same labels #7239 uses.
What changed
resolveChatSummaryMacros(packages/server/src/services/prompt/macro-context.ts) resolves the summary for a merged prompt. It reusesscopeCharacterSummarywith amarkcallback, as #7239 does:[Known only to Maukie: …]. A section everyone present gets has no mark.char == "Pantalone" && getvar::ready == "yes", is checked for each present character and marked the same way.{{char}}there resolves exactly as before. Lorebooks and the main prompt are untouched.mergedChatSummaryReaders(packages/server/src/routes/generate/generate-route-utils.ts) decides who the readers are: everyone present except the Advanced Memory narrator. It returns nothing, which keeps the old single reading, for one-character chats, Individual mode and impersonation. A chosen responder (forCharacterId, for example/guided respond for X) still gets readers: it does not pin a merged Roleplay reply to one speaker (mergedSpeaksOnlyTargetingenerate.routes.ts), and #7239's Advanced Memory reads for everyone present then too. In a merged chat of the narrator and one character, that character is the only reader, so the summary is read as them and narrator-only sections stay out, matching #7239.generate.routes.ts), the prompt preview (dry-run-route.ts) and Peek Prompt's live preview (chats.routes.ts, used before the first reply and whenever the summary changed since the last one) pass the readers to every summary placement: thechat_summarymarker (marker-expander.ts), the fallback append inside the assembler, and the preset-less fallback in generation (appendFallbackChatSummaryToSystemPrompt).scopeCharacterSummarynow also passes the nesting depth tomark. This is how top-level text is told apart from the content of a{{#if char == …}}branch. Without it,{{char}}inside a Maukie-only section resolved to the narrator in a narrator-and-Maukie chat. Existing callers ignore the extra argument.[Known only to …]formatting from #7239'srenderEntrymoved into a sharedmarkReaderVersions(packages/shared/src/utils/macro-engine.ts), used by both Advanced Memory and the Chat Summary. Advanced Memory output is unchanged; all 15 Advanced Memory regressions pass.ponytail:shortcut: a summary that contains a group block ([…]lines) keeps the old single reading, because splitting the block at a condition would undo its per-character repeat. The comment names the upgrade path (expand group blocks before scoping).docs/agents/memory.md(Chat Summary section) and a CHANGELOG entry. Translation follow-up: #7253.Prompt text, before and after
Merged chat with Narrator, Maukie and Pantalone, in that order, with the Advanced Memory narrator set to Narrator. Summary:
Before (staging):
After:
The first line still says "Narrator" because text outside every condition keeps the prompt's usual
{{char}}, as it did before.New regression
scripts/regressions/merged-chat-summary.regression.ts:chat_summarymarker, the assembler's fallback append and the preset-less fallback, asserted as exact strings.stagingproduces for the same fixture (captured from astagingrun). Without readers, all eight prompt variants of the fixture are byte-identical tostaging.mergedChatSummaryReadersexcludes the narrator and returns nothing for Individual mode, impersonation and a single-character chat.stagingsources, the regression fails ata merged summary marks who knows each private section and leaves out the narrator's (marker: true).No existing test was changed.
Not changed
stagingas well, so they were never read as the first character. They are left as they are.Verification follow-up (
f9f772a29)An adversarial check of
c75c36649found two gaps, now fixed:mergedChatSummaryReadersreturned nothing whenforCharacterIdwas set, but in merged Roleplay that doesn't pin the reply to one speaker (mergedSpeaksOnlyTarget), and Advanced Memory still reads for everyone present. So/guided respond for Narratorput narrator-only sections back into a prompt that can voice the cast. The target no longer turns readers off, in generation or the preview./chats/:id/peek-prompt) shows the saved request when it can. Before the first reply, or after the summary changed, it assembles a live preview without readers, so it showed the old first-character reading. That was exactly the case in the first manual step below. It now passes the same readers.Byte-identity rechecked independently: with four summaries (nested and
else ifbranches, a variable condition, card fields, a group block,{{trimStart}}), every prompt without readers matchedorigin/stagingoutput exactly, apart from unseeded dice rolls. The variants were Individual (deferred), merged without readers, chosen speaker and solo, each through the marker and the fallback, plusappendFallbackChatSummaryToSystemPromptwith and without deferral.Known limits, left as they are:
{{char}}inside a condition that doesn't name a character, such as{{#if getvar::x == "y"}}{{char}} …{{/if}}, is now read once per present character and marked, as #7239 does for Advanced Memory. Outside any condition it still resolves once.{{include::…}}resolves once, as onstaging.[lines padded with spaces or tabs only, not other whitespace.Validation
pnpm checkpasses locallyCONTRIBUTING.mdCommands the agent ran:
node scripts/run-regressions.mjs --filter merged-chat-summary: passed. It fails against thestagingsources, as described above.--filter advanced-memory): passed.memory-recallregressions and the 5summaryregressions (advanced-memory-summary,conversation-summary,merged-chat-summary,semantic-summary-cancellation,semantic-summary-settings): passed.roleplay-user-private-memory,native-export-memoryandactive-character-reference: passed.pnpm regression:prompt: passed.pnpm check: passed.f9f772a29:merged-chat-summary(also fails against c75c36649's routes at the new chosen-responder and Peek Prompt assertions),advanced-memory15/15,memory-recall5/5,summary5/5,group-7/7,roleplay-user-private-memory,native-export-memory,active-character-reference,assigned-chat-sweep,character-id-macro-modes,decision-conditionals,decision-reachable-statements,game-tool-controls,lorebook-decision-activation,roleplay-regeneration-context,roleplay-streaming,pnpm regression:promptandpnpm check: passed.Manual verification notes
{{#if char == "<second character>"}}SECRET{{/if}}, open Peek Prompt, and check that the Chat Summary shows[Known only to <second character>: SECRET].{{#if char == "A" || char == "B"}}…{{/if}}) shows without a mark.{{#if char == "<narrator>"}}…{{/if}}section does not appear in Peek Prompt or in the request sent to the model./guided respond for <narrator>sends a Chat Summary without the narrator-only section and with the other characters' sections marked.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)docs/agents/memory.mdgains one paragraph, andCHANGELOG.mdgains an entry at the top of[Unreleased]. Translation follow-up: #7253.UI evidence (if applicable)
No UI change. This changes prompt text only; see the before and after above.
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.