[GH-ISSUE #7454] [Issue]: Advanced Memory constants never merge, overrun the budget, and hide summaries from the narrator #4152

Closed
opened 2026-10-21 06:11:50 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @SpicyMarinara on GitHub (Oct 11, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7454

Originally assigned to: @SpicyMarinara on GitHub.

Summary

In a Roleplay group chat with Advanced Memory, constant summaries (Chat Summaries) never merge. They grow far past the memory budget, and the narrator can't read some of them.

Expected behavior

  • Constants that go over the memory budget are merged after the reply, including summaries read by different characters. Who knows what is kept in {{#if char == …}} sections.
  • The constants stay within the budget (constants take at most 70% of "Summary and recall budget").
  • The Advanced Memory narrator can read every summary, whatever its conditions say.

Actual behavior

  • Constants are combined only with summaries read by exactly the same characters. In a group chat almost every scene has a different set of readers, so each summary sits in a group of its own. It gets shortened again on every reply while the view stays over budget, and it is never merged. In one chat, a single summary went through 13 shortened versions in two days.
  • Summaries written or merged by hand in Chat Summaries are never compacted when they have character sections. When they alone fill the budget, the automatic summaries keep shrinking and the budget never holds. Before a manual merge, one chat had 20 constants, about 22–33k tokens, against a 12,228-token budget.
  • The oversized constants squeeze live history, so the scene rollover saves a new cutoff every few dozen messages.
  • A section whose condition doesn't name the narrator is hidden from the narrator. 9 of 20 automatic summaries were invisible to the narrator in that chat.
  • The Helper's merged answer is thrown away when it adds or drops the narrator's name in a condition, though the narrator knows everything.

Steps to reproduce

  1. Roleplay group chat in individual mode, with a narrator and several characters. Advanced Memory is on with a narrator selected and a summary budget of about 12k.
  2. Play enough scenes with changing participants that several scenes are archived as constants.
  3. Open Chat Summaries and show inactive entries. Each automatic summary appears in many shortened versions, none merged, and the active total stays above the budget.

Environment

  • Marinara Engine version: 2.5.0 (staging 3066f0c72)
  • Install type: docker
  • OS + version: n/a (server-side)
  • Browser or app shell: n/a

Logs, screenshots, or video

Traced in updateConstantSummariesAfterGeneration (packages/server/src/services/advanced-memory.ts):

  • grouping by identical reader set (4ed53f83c);
  • conditional eligibility (origin === "automated", createdAt === updatedAt);
  • the section check, which counts the narrator's name.

The narrator rendering is in renderEntry. Reproduced with temporary regressions.

Additional context

Merging across characters was restricted on 2026-10-08 because a merged summary shows one message range and its story dates to every reader. Fix that by working out the range and dates per reader from the messages that reader can see, rather than by refusing the merge.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @SpicyMarinara on GitHub (Oct 11, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7454 Originally assigned to: @SpicyMarinara on GitHub. ## Summary In a Roleplay group chat with Advanced Memory, constant summaries (Chat Summaries) never merge. They grow far past the memory budget, and the narrator can't read some of them. ## Expected behavior - Constants that go over the memory budget are merged after the reply, including summaries read by different characters. Who knows what is kept in `{{#if char == …}}` sections. - The constants stay within the budget (constants take at most 70% of "Summary and recall budget"). - The Advanced Memory narrator can read every summary, whatever its conditions say. ## Actual behavior - Constants are combined only with summaries read by exactly the same characters. In a group chat almost every scene has a different set of readers, so each summary sits in a group of its own. It gets shortened again on every reply while the view stays over budget, and it is never merged. In one chat, a single summary went through 13 shortened versions in two days. - Summaries written or merged by hand in Chat Summaries are never compacted when they have character sections. When they alone fill the budget, the automatic summaries keep shrinking and the budget never holds. Before a manual merge, one chat had 20 constants, about 22–33k tokens, against a 12,228-token budget. - The oversized constants squeeze live history, so the scene rollover saves a new cutoff every few dozen messages. - A section whose condition doesn't name the narrator is hidden from the narrator. 9 of 20 automatic summaries were invisible to the narrator in that chat. - The Helper's merged answer is thrown away when it adds or drops the narrator's name in a condition, though the narrator knows everything. ## Steps to reproduce 1. Roleplay group chat in individual mode, with a narrator and several characters. Advanced Memory is on with a narrator selected and a summary budget of about 12k. 2. Play enough scenes with changing participants that several scenes are archived as constants. 3. Open Chat Summaries and show inactive entries. Each automatic summary appears in many shortened versions, none merged, and the active total stays above the budget. ## Environment - Marinara Engine version: 2.5.0 (staging 3066f0c72) - Install type: docker - OS + version: n/a (server-side) - Browser or app shell: n/a ## Logs, screenshots, or video Traced in `updateConstantSummariesAfterGeneration` (`packages/server/src/services/advanced-memory.ts`): - grouping by identical reader set (4ed53f83c); - conditional eligibility (`origin === "automated"`, `createdAt === updatedAt`); - the section check, which counts the narrator's name. The narrator rendering is in `renderEntry`. Reproduced with temporary regressions. ## Additional context Merging across characters was restricted on 2026-10-08 because a merged summary shows one message range and its story dates to every reader. Fix that by working out the range and dates per reader from the messages that reader can see, rather than by refusing the merge. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 06:11:50 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Oct 11, 2026):

Working on this: Claude Code on behalf of @SpicyMarinara. A PR against staging will follow shortly.

<!-- gh-comment-id:6115201529 --> @SpicyMarinara commented on GitHub (Oct 11, 2026): Working on this: Claude Code on behalf of @SpicyMarinara. A PR against `staging` will follow shortly.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4152
No description provided.