[PR #7284] [MERGED] fix(memory): stop combined summaries that shorten nothing from repeating every reply #7663

Closed
opened 2026-10-24 04:06:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7284
Author: @SpicyMarinara
Created: 10/7/2026
Status: ✅ Merged
Merged: 10/8/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/combine-behaviour-followup


📝 Commits (6)

  • aaf1016 fix(memory): stop combined summaries that shorten nothing from repeating every reply
  • 9fcc764 docs(changelog): note the combined-summary follow-up fixes
  • 7598dc7 Merge origin/staging into fix/combine-behaviour-followup
  • f10c614 Merge origin/staging into fix/combine-behaviour-followup
  • 8ac4a79 Merge origin/staging into fix/combine-behaviour-followup
  • b011008 Merge origin/staging into fix/combine-behaviour-followup

📊 Changes

3 files changed (+40 additions, -6 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/services/advanced-memory.ts (+14 -6)
📝 scripts/regressions/advanced-memory-post-generation.regression.ts (+25 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Follow-up to #7275 (merged), which closed #7270. Refs #7270.

Why this change

A behaviour check of #7275 with realistic fixtures (one-by-one and merged group chats, a narrator, a newcomer, hidden messages, tight and roomy budgets, 20 constants) compared against staging turned up two ways the new combining wasted Helper calls:

  • A Helper call after every reply, for nothing. When summaries have private parts, the Helper gets them with their character conditions, but its reply was measured without them. Helpers often write the shared part without a condition, since Advanced Memory adds it back. So a reply that shortened nothing still looked shorter, got saved, and the next reply paid for the same thing again. Each round also left one more inactive copy in Chat Summaries. In the fixture (one summary with a secret for Maukie), the merged #7275 code made 4 Helper calls in 4 replies and left 5 entries. staging before #7275 made 0 calls, and this PR makes 1 call and then stops.
  • Safe results thrown away. The check that stops a private sentence reaching more characters also rejected sentences those characters could already read: a shared sentence repeated in a private part, or the same fact two characters each learned privately. The paid result was dropped, those summaries were not combined, and the plain summaries needed a second call.

Mari asked for the Helper to combine memories to shorten them. Both problems cost her money without shortening anything.

What changed

  • packages/server/src/services/advanced-memory.ts
    • A combined group's result is measured with its conditions restored before it counts as shorter. Plain groups are measured exactly as before.
    • A private sentence counts as copied into a wider section only if that section didn't already contain it before combining.
    • The rejection warning now says in plain words what happened: the Helper's combined summary would change who can read a private part, so it was not saved. Summaries with private parts kept as they are: N. Other summaries shortened on their own: M.
  • scripts/regressions/advanced-memory-post-generation.regression.ts: two new cases in the #7270 block. No existing assertion changed.
    • A reply that only drops a condition is requested once and not saved.
    • A sentence that was already shared doesn't block the combination.
    • Each case fails with its fix removed.
  • CHANGELOG.md: entry at the top of [Unreleased].

No docs change: docs/agents/memory.md already says a result that isn't shorter, or that changes who can read a private part, isn't saved.

Fixture results (PR vs staging before #7275)

  • Maukie and Pantalone, one-by-one: 4 automated recaps, 3 of them with private parts. Views went from 895 and 844 tokens to 423 and 398 in one call, with a 700-token share. staging stayed over budget at 764 and 713 after 3 replies and 2 calls. Neither character saw the other's secrets.
  • Narrator in every condition: under budget in one call; the narrator kept both secrets. staging left the narrator over budget at 732.
  • Merged chat with a newcomer: the sections from before Columbina joined kept their Maukie+Pantalone condition. staging combined none of them.
  • Tight budget (300) with 20 constants: under the share after 3 replies, then 0 calls. staging paid on every reply and was still at 604 tokens against a 210-token share.
  • Roomy budget: 0 calls on both.

Known cost, unchanged here: if a Helper never keeps the conditions, every reply where the plain summaries still shrink costs 2 calls (the combine attempt plus the plain fallback), where staging cost 1. It stops when the plain summaries stop shrinking.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Agent-run checks (for the reviewer to confirm, not proof):

  • pnpm check: exit 0.
  • pnpm regression:prompt: 3 of 3 passed.
  • All advanced-memory-*, memory-recall-* and summary regressions, plus roleplay-regeneration-context and roleplay-interrupt-generation: 23 of 23 passed.
  • Both new regression cases fail with their fix removed.
  • Local CodeRabbit was not run.

Manual verification notes

  • Manually verify in a one-by-one Roleplay group chat with Advanced Memory on: set Summary and recall budget low so constant summaries go over their share, and include an automated summary with a {{#if char == "Name"}} section. Send a reply and confirm, in Chat Summaries, that one combined summary replaces them and keeps the private section's condition.
  • Manually verify with a Helper reply that only drops the shared condition, or with debug logging on: send two more replies and confirm the server log shows no further Advanced Memory summary prompt for those summaries, and no new inactive copy appears in Chat Summaries.
  • Manually verify that the other character's Peek Prompt does not include the private section.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Not applicable: server only.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7284 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/7/2026 **Status:** ✅ Merged **Merged:** 10/8/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/combine-behaviour-followup` --- ### 📝 Commits (6) - [`aaf1016`](https://github.com/Pasta-Devs/Marinara-Engine/commit/aaf1016c3a036ae1a94bd4349fed06047919b1d5) fix(memory): stop combined summaries that shorten nothing from repeating every reply - [`9fcc764`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9fcc764415ab2d17542ca61b08df08baae093b85) docs(changelog): note the combined-summary follow-up fixes - [`7598dc7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7598dc71639f0d9e2b772b2c360d437e145e02a1) Merge origin/staging into fix/combine-behaviour-followup - [`f10c614`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f10c614b550fe9e48bac752ae4d70e58f7a3cf82) Merge origin/staging into fix/combine-behaviour-followup - [`8ac4a79`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8ac4a794875242b945350d39fd8f175d95e28218) Merge origin/staging into fix/combine-behaviour-followup - [`b011008`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b011008d46427f92aaa25b5b3c44f73a03ef49b4) Merge origin/staging into fix/combine-behaviour-followup ### 📊 Changes **3 files changed** (+40 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/services/advanced-memory.ts` (+14 -6) 📝 `scripts/regressions/advanced-memory-post-generation.regression.ts` (+25 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Follow-up to #7275 (merged), which closed #7270. Refs #7270. ## Why this change A behaviour check of #7275 with realistic fixtures (one-by-one and merged group chats, a narrator, a newcomer, hidden messages, tight and roomy budgets, 20 constants) compared against `staging` turned up two ways the new combining wasted Helper calls: - **A Helper call after every reply, for nothing.** When summaries have private parts, the Helper gets them with their character conditions, but its reply was measured without them. Helpers often write the shared part without a condition, since Advanced Memory adds it back. So a reply that shortened nothing still looked shorter, got saved, and the next reply paid for the same thing again. Each round also left one more inactive copy in Chat Summaries. In the fixture (one summary with a secret for Maukie), the merged #7275 code made 4 Helper calls in 4 replies and left 5 entries. `staging` before #7275 made 0 calls, and this PR makes 1 call and then stops. - **Safe results thrown away.** The check that stops a private sentence reaching more characters also rejected sentences those characters could already read: a shared sentence repeated in a private part, or the same fact two characters each learned privately. The paid result was dropped, those summaries were not combined, and the plain summaries needed a second call. Mari asked for the Helper to combine memories to shorten them. Both problems cost her money without shortening anything. ## What changed - `packages/server/src/services/advanced-memory.ts` - A combined group's result is measured with its conditions restored before it counts as shorter. Plain groups are measured exactly as before. - A private sentence counts as copied into a wider section only if that section didn't already contain it before combining. - The rejection warning now says in plain words what happened: *the Helper's combined summary would change who can read a private part, so it was not saved. Summaries with private parts kept as they are: N. Other summaries shortened on their own: M.* - `scripts/regressions/advanced-memory-post-generation.regression.ts`: two new cases in the #7270 block. No existing assertion changed. - A reply that only drops a condition is requested once and not saved. - A sentence that was already shared doesn't block the combination. - Each case fails with its fix removed. - `CHANGELOG.md`: entry at the top of `[Unreleased]`. No docs change: `docs/agents/memory.md` already says a result that isn't shorter, or that changes who can read a private part, isn't saved. **Fixture results (PR vs `staging` before #7275)** - Maukie and Pantalone, one-by-one: 4 automated recaps, 3 of them with private parts. Views went from 895 and 844 tokens to 423 and 398 in one call, with a 700-token share. `staging` stayed over budget at 764 and 713 after 3 replies and 2 calls. Neither character saw the other's secrets. - Narrator in every condition: under budget in one call; the narrator kept both secrets. `staging` left the narrator over budget at 732. - Merged chat with a newcomer: the sections from before Columbina joined kept their Maukie+Pantalone condition. `staging` combined none of them. - Tight budget (300) with 20 constants: under the share after 3 replies, then 0 calls. `staging` paid on every reply and was still at 604 tokens against a 210-token share. - Roomy budget: 0 calls on both. **Known cost, unchanged here:** if a Helper never keeps the conditions, every reply where the plain summaries still shrink costs 2 calls (the combine attempt plus the plain fallback), where `staging` cost 1. It stops when the plain summaries stop shrinking. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Agent-run checks (for the reviewer to confirm, not proof): - `pnpm check`: exit 0. - `pnpm regression:prompt`: 3 of 3 passed. - All `advanced-memory-*`, `memory-recall-*` and summary regressions, plus `roleplay-regeneration-context` and `roleplay-interrupt-generation`: 23 of 23 passed. - Both new regression cases fail with their fix removed. - Local CodeRabbit was not run. ### Manual verification notes - Manually verify in a one-by-one Roleplay group chat with Advanced Memory on: set **Summary and recall budget** low so constant summaries go over their share, and include an automated summary with a `{{#if char == "Name"}}` section. Send a reply and confirm, in Chat Summaries, that one combined summary replaces them and keeps the private section's condition. - Manually verify with a Helper reply that only drops the shared condition, or with debug logging on: send two more replies and confirm the server log shows no further Advanced Memory summary prompt for those summaries, and no new inactive copy appears in Chat Summaries. - Manually verify that the other character's Peek Prompt does not include the private section. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) Not applicable: server only. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:06:17 +07:00
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#7663
No description provided.