mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7255] [MERGED] fix(memory): skip summaries whose sections all render empty #7647
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#7647
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/7255
Author: @SpicyMarinara
Created: 10/7/2026
Status: ✅ Merged
Merged: 10/7/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/memory-empty-summary-header📝 Commits (2)
bdf9507fix(memory): skip summaries whose sections all render emptyb360595fix(memory): keep dated empty-summary headers only for readers of that range📊 Changes
5 files changed (+123 additions, -1 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/server/src/services/advanced-memory.ts(+7 -1)📝
scripts/regressions/advanced-memory-audience.regression.ts(+81 -0)📝
scripts/regressions/advanced-memory-post-generation.regression.ts(+31 -0)📝
scripts/regressions/advanced-memory-summary.regression.ts(+3 -0)📄 Description
Linked issue
Closes #7250
Why this change
The builder of #7239 (the fix for #7237) found that Advanced Memory adds a bare range header for a Chat Summary that has nothing for the character replying. When every conditional section of an entry renders empty for the reader, the prompt still gets
Messages #a–#b; source timeframe (summary corrections take precedence): unknown (use message order).with nothing under it. This happens in Individual and merged group chats and in one-character chats, in the prompt sent to the model and in Peek Prompt. The header also counts against the memory budget.This happens most to a character who joins a group later. Every summary the earlier cast wrote for themselves turns into an empty header in the newcomer's prompt. It tells the model nothing and wastes about 25 tokens per entry.
Mari's design for merged chats (2026-10-07) is "things should not break; the who-remembers-what is more informative for the model". This change keeps that. Merged prompts still label private content with who knows it. The only change is that an entry with nothing for anyone replying no longer leaves a header behind. Entries that have content are byte-identical to
staging.What changed
prepareImpl(packages/server/src/services/advanced-memory.ts): whenrenderEntryreturns empty text for the reader, the entry is left out of the Chat Summary block, header included. Its tokens no longer count toward the budget, the receipt estimate or excerpt fitting. Peek Prompt uses the samepreparepath (readOnly: true), so it matches.sourceTimeline(covered)is not null), the dated header stays exactly as before. On 2026-09-25 (fd8f408d4), Mari decided that scene dates are shared with every participant, even when some messages are hidden.advanced-memory-summary.regression.tsasserts that every reader's Chat Summary containsJune 12. For the borrower, that date comes only from the header of an entry whose text is for others. Dropping every bare header would have broken that test, so a dated header stays only for a reader who saw part of that range (the borrower read message #1). A character who read none of it, such as a newcomer whose knowledge starts later, gets no header at all, dated or not. Without that limit, a newcomer in a dated chat still gotMessages #3–#4; source timeframe …: June 12.with nothing under it for every scene before they joined.updateConstantSummariesAfterGeneration): an entry with no text for a view no longer adds a\n\nseparator to that view's 70% count. Compaction never counted headers, only entry text, so it now counts exactly the entries recall shows text for. Before, every empty entry between two others added about half a token to the count.[Unreleased]. No docs change:docs/does not describe these headers, so no[docs-i18n]follow-up is needed.Prompt text, before and after
Individual group chat, reading as Cara, who joined after Maukie and Pantalone wrote
CONST_SHAREDscoped to themselves:Before (staging):
After:
Merged chat (Maukie, Pantalone, Narrator, Cara) with an extra entry
{{#if char == "Narrator"}}NARRATOR_ONLY_NOTE{{/if}}on messages #5–#6. Before, the prompt ended with:After, it ends at
…[Known only to Maukie: MIXED_SECRET]. That is the same text, byte for byte, as when the narrator-only entry does not exist (estimated tokens 606 → 580).Dated partial scene (unchanged): the borrower keeps
Messages #1–#2; source timeframe (summary corrections take precedence): June 12.. Pantalone and the narrator lose the bareMessages #1–#1; … unknown (use message order).header from the borrower-only entry.Byte-identity check against staging
I dumped
chatSummary,recalledScenes, the receipt'sestimatedTokensAfter, reasons and recalled/record counts from the same fixtures, on this branch and onorigin/staging:CONST_SHAREDentry is empty for her, which is the bug.New and extended regression coverage
advanced-memory-audience.regression.ts: Cara's exact Individual Chat Summary has no bare header, and still none after the earlier scenes getDate:lines, while Pantalone, who read the narrator-only range, keeps its dated header. In Individual and merged modes, adding a narrator-only entry leaves every other reader'schatSummary,recalledScenesand estimated tokens unchanged. The narrator still gets it with its header. In a one-character chat, an entry only for an absent character changes nothing. On staging this fails atno bare header for Cara. With that assertion skipped, it fails atindividual maukie: an empty summary adds no header and no tokens.advanced-memory-post-generation.regression.ts(per-character constant budgets): Maukie's entries sit just under his 7k share, with 40 Pantalone-only entries between them. On staging, their separators push him over and trigger a paid compaction call. Fails on staging atanother character's entries do not push Maukie over his share.advanced-memory-summary.regression.ts: one added assertion,Messages #1–#1;appears only for the borrower. That is the dated header kept for the shared date, and no bare undated header for anyone else. Fails on staging. No existing assertion was changed or removed.Not changed here (pre-existing, for a follow-up)
""view withrenderEntry(ctx, content, []). That reads conditions as the first chat character, not the labelled any-present-reader view #7239 gave recall. Compaction can therefore under-count a merged chat's constants after a newcomer joins. This is the same as on staging.if (ctx.individual && !audience.length) continue;).Validation
pnpm checkpasses locallyCONTRIBUTING.mdCommands the agent ran, all passing:
pnpm check: exit 0.node scripts/run-regressions.mjs --filter advanced-memory).memory-recall-exclusivity,memory-recall-revectorizeand the 3advanced-memory-recall*regressions (--filter memory-recall).conversation-summary,semantic-summary-settings,semantic-summary-cancellation,roleplay-user-private-memory,native-export-memory,prompt-token-counters,capability-prompt-preview.pnpm regression:prompt(prompt, prompt-attachments, context-fit).origin/staging'sadvanced-memory.ts, as described above.Manual verification notes
{{#if char == "OtherName"}}secret{{/if}}on a range outside live history, no longer shows aMessages #…; source timeframe …: unknown (use message order).line with nothing under it in Peek Prompt for the replying character, and that it still shows with its text for the character it names.Messages #…line in Peek Prompt, while entries known to some characters still show[Known only to …]marks.Date: June 12) still showsMessages #…; source timeframe …: June 12.for a character who can read some of those messages but not the entry's text.Messages #…line with nothing under it for scenes before they joined.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)CHANGELOG.mdgains one entry under[Unreleased]. Nodocs/page changes, so no[docs-i18n]follow-up.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.