mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7463] [MERGED] fix(memory): keep merged scene constants compactable when a reader leaves or the text uses {{user}} #7745
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#7745
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/7463
Author: @SpicyMarinara
Created: 10/12/2026
Status: ✅ Merged
Merged: 10/12/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/advanced-memory-merged-constant-followups📝 Commits (1)
76fc280fix(memory): keep merged scene constants compactable when a reader leaves or the text uses {{user}}📊 Changes
4 files changed (+199 additions, -39 deletions)
View changed files
📝
docs/agents/memory.md(+2 -2)📝
packages/server/src/services/advanced-memory.ts(+51 -34)📝
packages/shared/src/utils/macro-engine.ts(+25 -0)📝
scripts/regressions/advanced-memory-post-generation.regression.ts(+121 -3)📄 Description
Linked issue
Follow-up to #7458 (#7454)
Why this change
#7458 gives a scene one Advanced Memory constant for every reader of its recap, instead of a copy per reader. A reviewer reproduced two cases where that merged constant then never gets shortened, so a character's share of Summary and recall budget stays over the limit after every reply:
{{user}}. The merged constant now has private parts, and the privacy check treated text containing any macro as unreadable for its purposes, so such a summary was skipped (0 Helper calls).{{user}}reads the same for every character, so it doesn't need that protection.It also tidies the order in which a scene's new constants are saved. The constant that needs no Helper call was saved after any paid re-summary of a partly covered copy. If that call failed, the narrator's and the other readers' constant was held back until the next run.
What changed
packages/shared/src/utils/macro-engine.ts: newcharacterConditionNames(text)lists the names a summary's character-only conditions compare against, the same wayscopeCharacterSummaryreads them.packages/server/src/services/advanced-memory.ts, compaction:{{else}}), stays as it is, as before.{{user}}. Any other macro ({{char}}, character fields, variables) still blocks combining a summary with private parts, as before.ponytail:comment to match.packages/server/src/services/advanced-memory.ts, new constants: the scene's constant that needs no Helper call is saved first, before re-summarizing partly covered copies.docs/agents/memory.md: "Everyone who read a scene's recap shares one summary of it" now applies only to group chats where characters reply one at a time. The compaction paragraph now covers a departed character's part and{{user}}.Known older limitation, out of scope: in a merged group chat, a scene with a message hidden from one character gets no automatic constant at all, because
archivedIdsuses the all-characters view there. This predates #7458, so the docs no longer claim one shared summary for merged chats.No CHANGELOG entry: both freezes and the save order came from #7458, which hasn't been released. Its
[Unreleased]entry already describes the behavior this PR restores.Validation
pnpm checkpasses locallyCONTRIBUTING.mdNotes, commands run by the agent:
pnpm check: exit 0.node ./scripts/run-regressions.mjs --filter advanced-memory: 16/16 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 context-fit: 2/2 passed.scripts/regressions/advanced-memory-post-generation.regression.ts. Each one fails when its fix is reverted on its own:{{user}}in the shared part: one combine call. Maukie and Pantalone each still read only their own private part. Fails without the fix: "a shared part with {{user}} is shortened too".coderabbit review --agent --committed --base-commit $(git merge-base HEAD origin/staging)): 2 findings. The review base was the merge base withstagingtaken before #7458 merged, so it also covered #7458's changes. Neither was fixed here:docs/agents/memory.mdneeds thedocs-i18nmirror or a follow-up issue. Dismissed: the existing follow-up issue #7462 ([docs-i18n] docs/agents/memory.md) covers it, and this PR's edits are noted there.advanced-memory.tscompares 4-word runs. A private section shorter than four words has no runs, so the check wouldn't catch it being copied word for word into shared text. Dismissed as out of scope: the gap is in #7458'sruns/leakscode, which this PR doesn't change. This PR does send a few more summaries through that check (ones with a departed character's part or with{{user}}). The suggested fix (runs ofmin(4, words)) would also reject answers for 1- and 2-word sections that share a common word, and that tradeoff is for the maintainer to decide in a separate follow-up.Manual verification needed
{{#if char == "B"}}section.{{#if char == "B"}}. Check that A's prompt (Prompt Inspector) doesn't contain B's part.{{user}}in the scene summary's shared text. Check that the over-budget share is shortened,{{user}}still shows your persona name in each character's prompt, and neither character sees the other's private part.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)Docs:
docs/agents/memory.mdis updated (the shared-summary sentence and the compaction paragraph). The translation follow-up is noted on the existing #7462 ([docs-i18n] docs/agents/memory.md).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.