mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7458] [MERGED] fix(memory): merge summaries across characters; the narrator reads them all #7747
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#7747
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/7458
Author: @SpicyMarinara
Created: 10/12/2026
Status: ✅ Merged
Merged: 10/12/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/advanced-memory-constant-merging📝 Commits (8)
92dbc53fix(memory): merge constant summaries across characters and let the narrator read them all3fb83e4fix(memory): address review findings on cross-reader constant merging63322f6docs(memory): shorten the constant-merging changelog entry and docs wording112c360test(memory): clamp the fixture Helper's target and keep the docs promise exact256160adocs(memory): name the {{char}} cases the narrator still reads by conditioned9633dfix(memory): give a scene one constant for every reader of its recapab6bd3adocs(memory): split the constant-merging guide paragraph and shorten the changelog entry90ff09dMerge branch 'staging' into fix/advanced-memory-constant-merging📊 Changes
7 files changed (+914 additions, -161 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
docs/agents/memory.md(+9 -3)📝
packages/server/src/services/advanced-memory.ts(+222 -114)📝
packages/shared/src/utils/macro-engine.ts(+80 -13)📝
scripts/regressions/advanced-memory-audience.regression.ts(+40 -3)📝
scripts/regressions/advanced-memory-post-generation.regression.ts(+555 -25)📝
scripts/regressions/advanced-memory-summary.regression.ts(+7 -3)📄 Description
Linked issue
Closes #7454
Why this change
Advanced Memory's constant Chat Summaries never merged in group chats, ran far past the memory budget, and hid summaries from the narrator. In Mari's chat "My Canon" (individual group generation, narrator "Powers That Be" + 4 characters, Summary and recall budget 12,228, so the constant trigger is floor(0.7 × 12,228) = 8,559, max context 65,536):
Merging across characters had been restricted on 2026-10-08 (
4ed53f83c) because one merged entry showed one message range and its story dates to every reader, which once showed Pantalone the date of a message hidden from him. Per Mari's 2026-10-12 decisions, this PR fixes that leak at the source (range and dates per reader) and allows the merge again.What changed
ponytail:comment).flattenCharacterConditions, reusing the existing character-only condition check).{{char}}in a section for one character reads as that character's name; branches no reader got together, such as an{{else}}, are joined with a space. Another character's copy of a scene summary the narrator already has (same or fewer messages, every sentence in the same order) is left out of the narrator's prompt and of its share (ponytail:comment for the ceiling once the Helper rewrites the copies). The narrator's per-scene coverage counts only sections written for it. Variable and mixed conditions still evaluate normally (documented). Merged prompts the narrator shares with characters (#7237) and owner/impersonation prompts keep today's behavior.ed9633d5c). A message hidden from one reader no longer splits a scene into a copy per reader: readers who get the same recap share one constant, and prompts show its range and dates per reader. So the narrator reads a whispered scene once, also after compaction. A scene that another summary already partly covered for some readers still gets a separate, re-summarized constant for them.ponytail:comment for the ceiling).scene-timeframe-constants-v24, so swipe snapshots don't reuse constants rendered under the old rules. Peek Prompt uses the same preparation.docs/agents/memory.md) and CHANGELOG updated.Existing regression assertions changed (each reversed by a 2026-10-12 maintainer decision, unless noted)
advanced-memory-post-generation: "Audience-dependent constant templates" (individual and merged): the hand-written per-character template is now sent to the Helper with its conditions (decision 3), so 3 calls instead of 1; the template is still kept unchanged because the fixture's answer drops its sections, and each character still sees only their own section.advanced-memory-post-generation: "a valid shorter recap is kept without retries to force a tiny group target": staging's assertion (calls.length === 1, no196 tokens) is kept. The fixture's tight template now also holds{{char}}, so under decision 3 it still can't be combined and still fills most of each view, which is what this #6512 guard tests. A new assertion checks the target asked for is over 1,000 tokens (the room-based target would ask for 191).advanced-memory-post-generation: the leaked-private-sentence case now makes 3 calls (combined, then the halves) instead of 2; the private summary is still never saved with a leak.advanced-memory-post-generation: "an edited summary is never rewritten": a hand-edited private summary is now combined (decision 3); the original stays as an unchanged inactive version, and Pantalone still never reads the secret.advanced-memory-post-generation: "Merged private range": the Maukie-only and shared summaries now merge in 1 call instead of 2 (decision 2). The Pantalone assertion (noMessages #1, noNIGHT_OF_THE_HEIST) is kept and now also checked in individual mode, with his exact range#2–#2and dateMORNING_AFTER.advanced-memory-summary: the borrower no longer sees "June 12" in his constants, since that date is in a message hidden from him (decision 2: dates per reader from visible messages); his recalled scene still shows it. TheMessages #1–#1;assertion is back to staging'sid === borrower.id: the narrator reads every section (decision 1) but no longer reads the borrower's copy of the scene it already has ("no doubling").advanced-memory-audience: Cara (who joined later) gets the plain constant without the#1–#2range header, since those messages are before her knowledge start (decision 2).Validation
pnpm checkpasses locallyCONTRIBUTING.mdCommands run on head
ed9633d5c(one constant per scene), with results:pnpm check: exit 0.node ./scripts/run-regressions.mjs --filter advanced-memory: 16/16 passed;--filter merged-chat-summary: 1/1;--filter memory-recall: 5/5;--filter context-fit: 2/2;--filter regeneration-context: 2/2.advanced-memory-post-generation: fails without the fix (2 constants instead of 1), passes with it. The narrator reads the scene once; Pantalone's prompt showsMessages #1–#1with only DAY_OF_STROLL and no whispered text.Commands the agent ran on the final code (head
112c3603c), with results:pnpm check: exit 0 (one pre-existing client lint warning inHomeProfessorMariChat.tsx, a file this PR doesn't touch).node ./scripts/run-regressions.mjs --filter advanced-memory: 16/16 passed.node ./scripts/run-regressions.mjs --filter context-fit: 2/2 passed.node ./scripts/run-regressions.mjs --filter regeneration-context: 2/2 passed.node ./scripts/run-regressions.mjs --filter merged-chat-summary: 1/1 passed.node ./scripts/run-regressions.mjs --filter memory-recall: 5/5 passed.node ./scripts/run-regressions.mjs --filter macro: 3/3 passed;--filter summary: 7/7 passed.coderabbit review --agent --committed --base-commit 3066f0c72: run twice. Round 1 (2 findings): the CHANGELOG entry was shortened and the docs wording simplified. Round 2 (2 findings): the fixture Helper's target is now clamped (CodeQL resource-exhaustion rule); "the leak check ignores private sections under four words" was dismissed because the sentence check it replaced also needed four words (it returns nothing formira killed jun.), so this isn't a regression, and the docs no longer promise more than the check does. Not re-run after those last text-only fixes.{{char}}in a section for one character names that character for the narrator, and{{else}}branches are spaced.{{char}}is still combined.Final verification by a separate agent:
112c3603c:pnpm checkexit 0 (same pre-existing warning);node ./scripts/run-regressions.mjs --filter advanced-memory: 16/16 passed. Related filters:memory22/22,summary7/7,macro3/3,context11/11,whisper3/3,merged1/1,recall5/5,prompt16/16,roleplay14/14, all passed.112c3603cwith no actionable comments.256160a86is docs-only (the narrator's{{char}}exceptions indocs/agents/memory.md, matching the code). On it:pnpm checkexit 0 (same pre-existing warning) andprettier --check docs/agents/memory.mdclean.Manual verification notes
{{#if char == "…"}}sections is merged too and that its original stays inactive and unchanged.{{#if}}tags, and a scene with a whisper appears once, not once per character's copy.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)Notes:
docs/agents/memory.md(combining paragraph, merged-chat paragraph and the Chat Summary merged-chat note) andCHANGELOG.mdwere updated. The translateddocs/agents/memory.mdondocs-i18nwas not touched; follow-up: #7462.Open risks
ed9633d5c).{{else if}}chain with one, still follows its condition for the narrator (documented). So does every part of a condition in which{{char}}could name more than one character, such as{{#if char == "Maukie" || "Pantalone"}}{{char}} saw the fire.{{/if}}or{{#if char == "Maukie"}}A{{else}}{{char}} slept.{{/if}}, or that uses another character macro such as{{description}}(documented in256160a86). The narrator then misses those parts, includingA. Base behaves the same.{{#if getvar::revealed == "yes"}}…{{/if}}while it is "yes") is combined as plain text, so the result no longer depends on the variable.🤖 Generated with Claude Code
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.