[PR #7458] [MERGED] fix(memory): merge summaries across characters; the narrator reads them all #7747

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

📋 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)

  • 92dbc53 fix(memory): merge constant summaries across characters and let the narrator read them all
  • 3fb83e4 fix(memory): address review findings on cross-reader constant merging
  • 63322f6 docs(memory): shorten the constant-merging changelog entry and docs wording
  • 112c360 test(memory): clamp the fixture Helper's target and keep the docs promise exact
  • 256160a docs(memory): name the {{char}} cases the narrator still reads by condition
  • ed9633d fix(memory): give a scene one constant for every reader of its recap
  • ab6bd3a docs(memory): split the constant-merging guide paragraph and shorten the changelog entry
  • 90ff09d Merge 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

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

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):

  • Before her manual merge there were 20 enabled constants. 4 were origin "manual" with private sections (Arc One/Two/Three and an earlier UI "Combined summary"), about 11.1k tokens in the narrator's view. They were never compacted, and that alone kept the narrator's view over 8,559.
  • Each automated constant had a different set of readers, so it sat in a group of its own and was shortened again on almost every reply. "Messages #1162–#1206" had 13–14 versions (7.4k down to 3.9k characters). Nothing ever merged.
  • 9 of the 20 automated entries had conditions without the narrator's name (for example only "Cyno", "Tighnari" or "Maukie"), so the narrator never saw them.

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

  • Behavior change: summaries you wrote or edited yourself can now be merged. When constants are over the budget, hand-written (origin "manual"/legacy) or hand-edited summaries with character sections, including results of a manual Combine in Chat Summaries, are combined and shortened too. The originals stay in Chat Summaries as inactive versions that can be turned back on. Summaries whose text holds other macros (the privacy check can't reason about them) and summaries with a section only a character who left the chat reads still stay as they are, also when only the narrator reads them (ponytail: comment).
  • Narrator reads everything, once. When the reader is only the Advanced Memory narrator, every character-only section of a summary is rendered once and plain, whoever its condition names, including characters no longer in the chat (shared helper 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.
  • One constant per scene for everyone who reads its recap (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.
  • Cross-reader merging. Compaction no longer groups by identical reader sets; ranged and legacy unranged summaries stay apart, ranged ones in chat order. Each summary goes to the Helper scoped to its own readers, and the answer is scoped to the union of the group's readers (not to every chat character). A summary is combined only once its messages are outside every character's live history, so a merged entry never hides a reader's older summaries while one of its messages is still live for them. The privacy check keeps every reader-set section, ignores the narrator's name in section keys, and now rejects any run of four words from a private section that appears in a wider section, so a shortened private sentence is caught too. A rejected answer is retried with the summaries each set of characters reads (which combine without conditions unless they have private parts), then in chronological halves down to single summaries (ponytail: comment for the ceiling).
  • Per-reader range and dates. In prepare, a constant's range label, story dates and timeline corrections come only from messages the prompt's readers can see. In a merged prompt they come from the messages every character who reads that summary can see, so the shared text never shows a date from a message hidden from one of them, while a summary only Maukie reads keeps its own range next to its "Known only to Maukie" mark. The outside-live rule is unchanged.
  • Targets. Each group's length target is its proportional share of the budget in each over-budget view, as since #6512 (no tiny targets), counted without conditions as the views are, so an answer of the target size brings the narrator under the share in one pass. A view that summaries which can't be combined already fill is skipped, so it isn't shortened on every reply. Only summaries an over-budget view reads are combined.
  • Merged-mode measurement. Merged group chats measure the constants as the shared prompt carries them for the chat's characters (as prepare renders them), not as the first character's view.
  • Preparation policy revision bumped to scene-timeframe-constants-v24, so swipe snapshots don't reuse constants rendered under the old rules. Peek Prompt uses the same preparation.
  • Docs (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, no 196 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 (no Messages #1, no NIGHT_OF_THE_HEIST) is kept and now also checked in individual mode, with his exact range #2–#2 and date MORNING_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. The Messages #1–#1; assertion is back to staging's id === 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–#2 range header, since those messages are before her knowledge start (decision 2).

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

Commands 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.
  • New proof "Whispered scene, one constant" in 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 shows Messages #1–#1 with 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 in HomeProfessorMariChat.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 for mira 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.
  • New proofs in existing regression files (each confirmed to fail when its fix is reverted):
    • A combined summary doesn't hide a reader's older summary while one of its messages is live for them (personal starts).
    • A summary only a departed character reads isn't sent to the Helper and stays as it is.
    • No tiny target when a summary that can't be combined fills most of a view.
    • A combined answer of exactly the target size brings the narrator under the share in one pass.
    • A rejected answer is retried per reader set: 3 calls instead of 7, 2 merged entries.
    • A shortened private sentence copied into shared text is caught.
    • A merged prompt for both readers shows only the range and date both can see; a Maukie-only summary keeps its own.
    • The narrator reads the partial-scene recap once.
    • {{char}} in a section for one character names that character for the narrator, and {{else}} branches are spaced.
    • A one-character summary with {{char}} is still combined.

Final verification by a separate agent:

  • On 112c3603c: pnpm check exit 0 (same pre-existing warning); node ./scripts/run-regressions.mjs --filter advanced-memory: 16/16 passed. Related filters: memory 22/22, summary 7/7, macro 3/3, context 11/11, whisper 3/3, merged 1/1, recall 5/5, prompt 16/16, roleplay 14/14, all passed.
  • GitHub CodeRabbit reviewed 112c3603c with no actionable comments.
  • 256160a86 is docs-only (the narrator's {{char}} exceptions in docs/agents/memory.md, matching the code). On it: pnpm check exit 0 (same pre-existing warning) and prettier --check docs/agents/memory.md clean.

Manual verification notes

  • In an individual Roleplay group chat with an Advanced Memory narrator, open Chat Summaries → Show inactive after a reply that pushes the constants over budget, and confirm entries read by different characters were merged into one entry, with the originals listed as inactive.
  • In the same chat, confirm a summary you wrote or edited yourself with {{#if char == "…"}} sections is merged too and that its original stays inactive and unchanged.
  • Send another reply without new scenes and confirm the Agents menu shows no new Advanced Recall compaction.
  • Peek Prompt as the narrator shows sections whose conditions don't name the narrator, each once and without {{#if}} tags, and a scene with a whisper appears once, not once per character's copy.
  • Peek Prompt as a character shows no message number or story date from a message hidden from them in the constant summaries.
  • In a merged group chat, confirm a combined summary is still marked "Known only to …" for the characters who read it, that a character outside those readers doesn't get it, and that the range above shared text has no date from a message hidden from one of the characters present.
  • With personal Mark as new start flags that differ between characters, confirm a character's older summaries stay in Peek Prompt after a compaction.
  • Check the server log for any "the Helper's combined summary would change who can read a private part" warnings and that the retry produced smaller merged entries.

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)

Notes: docs/agents/memory.md (combining paragraph, merged-chat paragraph and the Chat Summary merged-chat note) and CHANGELOG.md were updated. The translated docs/agents/memory.md on docs-i18n was not touched; follow-up: #7462.

Open risks

  • Needs Mari's call: tiny targets vs. grinding. The earlier version of this PR asked the Helper for the room left by summaries that can't be combined. That brought back the tiny targets #6512 removed (191 tokens in the regression fixture), so the target is again each group's proportional share. When summaries that can't be combined fill most, but not all, of a share, that view is shortened again on later replies, as on staging, until the Helper stops shortening. A view they fill completely is still skipped.
  • Copies of one scene for different readers still exist in chats from before this PR, and for scenes another summary partly covered for some readers. The narrator skips such a copy while it matches the other, but once the Helper rewrites one copy it reads both. New scenes no longer get copies (ed9633d5c).
  • A combined answer that drops a small private section is accepted when another summary has a section for the same readers. Condensing is lossy for shared text too, and the originals stay inactive.
  • A section whose condition also checks a variable, or that shares an {{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 in 256160a86). The narrator then misses those parts, including A. Base behaves the same.
  • As on staging, a summary with a variable condition that every reader currently reads the same way (for example {{#if getvar::revealed == "yes"}}…{{/if}} while it is "yes") is combined as plain text, so the result no longer depends on the variable.
  • A Helper that keeps rewriting conditions can be asked several times on one reply: one combined call, one per reader set, then halves. A rejected set is asked again only when its share of the budget changes; rejected sets are not remembered yet.
  • Merging everything one view reads into one entry asks the Helper for a long answer, up to about the constant share. With a small Chat Summary → Maximum output size, a very large share can hit the output limit; the error says to raise it.
  • A merged entry's coverage is the union of its sources. A later rerun of an old scene with a new participant can treat those messages as already covered for them.
  • A private section under four words is not checked for copying, as before this PR.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Constant summaries can be combined across character audiences while preserving private sections. Handwritten and edited summaries may also be combined, with original entries retained as inactive versions.
    • Summary ranges and story dates reflect only messages visible to each reader. When replying alone, the narrator can read every summary section.
  • Bug Fixes
    • Group-chat summaries and scene excerpts reflect what the relevant characters can see. Repeated narrator-visible summaries are omitted, and failed combinations are retried in smaller groups; entries that cannot be safely shortened remain unchanged.

🔄 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/7458 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/12/2026 **Status:** ✅ Merged **Merged:** 10/12/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/advanced-memory-constant-merging` --- ### 📝 Commits (8) - [`92dbc53`](https://github.com/Pasta-Devs/Marinara-Engine/commit/92dbc538a82d3b51149e366de7bb0646a6dab94e) fix(memory): merge constant summaries across characters and let the narrator read them all - [`3fb83e4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3fb83e4a87f195b709c6b6721ec8d4c8574e067d) fix(memory): address review findings on cross-reader constant merging - [`63322f6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/63322f6624481439816324cab2c70a0596073f49) docs(memory): shorten the constant-merging changelog entry and docs wording - [`112c360`](https://github.com/Pasta-Devs/Marinara-Engine/commit/112c3603ce581cc839cb2ea990496f0f1d5c6448) test(memory): clamp the fixture Helper's target and keep the docs promise exact - [`256160a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/256160a864639fdc6525c6c6d86ebfd470fa3d19) docs(memory): name the {{char}} cases the narrator still reads by condition - [`ed9633d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ed9633d5cac862b14e9fc012d6cfd7ed51282cce) fix(memory): give a scene one constant for every reader of its recap - [`ab6bd3a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ab6bd3a1216410bc532fa213e87b6d1812230143) docs(memory): split the constant-merging guide paragraph and shorten the changelog entry - [`90ff09d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/90ff09d405706e43f0ad7d5c7908ce0f1108909f) Merge branch 'staging' into fix/advanced-memory-constant-merging ### 📊 Changes **7 files changed** (+914 additions, -161 deletions) <details> <summary>View changed files</summary> 📝 `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) </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`. ## 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): - Before her manual merge there were 20 enabled constants. 4 were origin "manual" with private sections (Arc One/Two/Three and an earlier UI "Combined summary"), about 11.1k tokens in the narrator's view. They were never compacted, and that alone kept the narrator's view over 8,559. - Each automated constant had a different set of readers, so it sat in a group of its own and was shortened again on almost every reply. "Messages #1162–#1206" had 13–14 versions (7.4k down to 3.9k characters). Nothing ever merged. - 9 of the 20 automated entries had conditions without the narrator's name (for example only "Cyno", "Tighnari" or "Maukie"), so the narrator never saw them. 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 - **Behavior change: summaries you wrote or edited yourself can now be merged.** When constants are over the budget, hand-written (origin "manual"/legacy) or hand-edited summaries with character sections, including results of a manual **Combine** in Chat Summaries, are combined and shortened too. The originals stay in Chat Summaries as inactive versions that can be turned back on. Summaries whose text holds other macros (the privacy check can't reason about them) and summaries with a section only a character who left the chat reads still stay as they are, also when only the narrator reads them (`ponytail:` comment). - **Narrator reads everything, once.** When the reader is only the Advanced Memory narrator, every character-only section of a summary is rendered once and plain, whoever its condition names, including characters no longer in the chat (shared helper `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. - **One constant per scene for everyone who reads its recap** (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. - **Cross-reader merging.** Compaction no longer groups by identical reader sets; ranged and legacy unranged summaries stay apart, ranged ones in chat order. Each summary goes to the Helper scoped to its own readers, and the answer is scoped to the union of the group's readers (not to every chat character). A summary is combined only once its messages are outside every character's live history, so a merged entry never hides a reader's older summaries while one of its messages is still live for them. The privacy check keeps every reader-set section, ignores the narrator's name in section keys, and now rejects any run of four words from a private section that appears in a wider section, so a shortened private sentence is caught too. A rejected answer is retried with the summaries each set of characters reads (which combine without conditions unless they have private parts), then in chronological halves down to single summaries (`ponytail:` comment for the ceiling). - **Per-reader range and dates.** In prepare, a constant's range label, story dates and timeline corrections come only from messages the prompt's readers can see. In a merged prompt they come from the messages every character who reads that summary can see, so the shared text never shows a date from a message hidden from one of them, while a summary only Maukie reads keeps its own range next to its "Known only to Maukie" mark. The outside-live rule is unchanged. - **Targets.** Each group's length target is its proportional share of the budget in each over-budget view, as since #6512 (no tiny targets), counted without conditions as the views are, so an answer of the target size brings the narrator under the share in one pass. A view that summaries which can't be combined already fill is skipped, so it isn't shortened on every reply. Only summaries an over-budget view reads are combined. - **Merged-mode measurement.** Merged group chats measure the constants as the shared prompt carries them for the chat's characters (as prepare renders them), not as the first character's view. - Preparation policy revision bumped to `scene-timeframe-constants-v24`, so swipe snapshots don't reuse constants rendered under the old rules. Peek Prompt uses the same preparation. - Docs (`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`, no `196 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 (no `Messages #1`, no `NIGHT_OF_THE_HEIST`) is kept and now also checked in individual mode, with his exact range `#2–#2` and date `MORNING_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. The `Messages #1–#1;` assertion is back to staging's `id === 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–#2` range header, since those messages are before her knowledge start (decision 2). ## 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` Commands 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. - New proof "Whispered scene, one constant" in `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 shows `Messages #1–#1` with 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 in `HomeProfessorMariChat.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 for `mira 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. - New proofs in existing regression files (each confirmed to fail when its fix is reverted): - A combined summary doesn't hide a reader's older summary while one of its messages is live for them (personal starts). - A summary only a departed character reads isn't sent to the Helper and stays as it is. - No tiny target when a summary that can't be combined fills most of a view. - A combined answer of exactly the target size brings the narrator under the share in one pass. - A rejected answer is retried per reader set: 3 calls instead of 7, 2 merged entries. - A shortened private sentence copied into shared text is caught. - A merged prompt for both readers shows only the range and date both can see; a Maukie-only summary keeps its own. - The narrator reads the partial-scene recap once. - `{{char}}` in a section for one character names that character for the narrator, and `{{else}}` branches are spaced. - A one-character summary with `{{char}}` is still combined. Final verification by a separate agent: - On `112c3603c`: `pnpm check` exit 0 (same pre-existing warning); `node ./scripts/run-regressions.mjs --filter advanced-memory`: 16/16 passed. Related filters: `memory` 22/22, `summary` 7/7, `macro` 3/3, `context` 11/11, `whisper` 3/3, `merged` 1/1, `recall` 5/5, `prompt` 16/16, `roleplay` 14/14, all passed. - GitHub CodeRabbit reviewed `112c3603c` with no actionable comments. - `256160a86` is docs-only (the narrator's `{{char}}` exceptions in `docs/agents/memory.md`, matching the code). On it: `pnpm check` exit 0 (same pre-existing warning) and `prettier --check docs/agents/memory.md` clean. ### Manual verification notes - In an individual Roleplay group chat with an Advanced Memory narrator, open **Chat Summaries → Show inactive** after a reply that pushes the constants over budget, and confirm entries read by different characters were merged into one entry, with the originals listed as inactive. - In the same chat, confirm a summary you wrote or edited yourself with `{{#if char == "…"}}` sections is merged too and that its original stays inactive and unchanged. - Send another reply without new scenes and confirm the Agents menu shows no new **Advanced Recall** compaction. - **Peek Prompt** as the narrator shows sections whose conditions don't name the narrator, each once and without `{{#if}}` tags, and a scene with a whisper appears once, not once per character's copy. - **Peek Prompt** as a character shows no message number or story date from a message hidden from them in the constant summaries. - In a merged group chat, confirm a combined summary is still marked "Known only to …" for the characters who read it, that a character outside those readers doesn't get it, and that the range above shared text has no date from a message hidden from one of the characters present. - With personal **Mark as new start** flags that differ between characters, confirm a character's older summaries stay in **Peek Prompt** after a compaction. - Check the server log for any "the Helper's combined summary would change who can read a private part" warnings and that the retry produced smaller merged entries. ## 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) Notes: `docs/agents/memory.md` (combining paragraph, merged-chat paragraph and the Chat Summary merged-chat note) and `CHANGELOG.md` were updated. The translated `docs/agents/memory.md` on `docs-i18n` was not touched; follow-up: #7462. ### Open risks - **Needs Mari's call: tiny targets vs. grinding.** The earlier version of this PR asked the Helper for the room left by summaries that can't be combined. That brought back the tiny targets #6512 removed (191 tokens in the regression fixture), so the target is again each group's proportional share. When summaries that can't be combined fill most, but not all, of a share, that view is shortened again on later replies, as on staging, until the Helper stops shortening. A view they fill completely is still skipped. - Copies of one scene for different readers still exist in chats from before this PR, and for scenes another summary partly covered for some readers. The narrator skips such a copy while it matches the other, but once the Helper rewrites one copy it reads both. New scenes no longer get copies (ed9633d5c). - A combined answer that drops a small private section is accepted when another summary has a section for the same readers. Condensing is lossy for shared text too, and the originals stay inactive. - A section whose condition also checks a variable, or that shares an `{{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 in `256160a86`). The narrator then misses those parts, including `A`. Base behaves the same. - As on staging, a summary with a variable condition that every reader currently reads the same way (for example `{{#if getvar::revealed == "yes"}}…{{/if}}` while it is "yes") is combined as plain text, so the result no longer depends on the variable. - A Helper that keeps rewriting conditions can be asked several times on one reply: one combined call, one per reader set, then halves. A rejected set is asked again only when its share of the budget changes; rejected sets are not remembered yet. - Merging everything one view reads into one entry asks the Helper for a long answer, up to about the constant share. With a small **Chat Summary → Maximum output size**, a very large share can hit the output limit; the error says to raise it. - A merged entry's coverage is the union of its sources. A later rerun of an old scene with a new participant can treat those messages as already covered for them. - A private section under four words is not checked for copying, as before this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Constant summaries can be combined across character audiences while preserving private sections. Handwritten and edited summaries may also be combined, with original entries retained as inactive versions. * Summary ranges and story dates reflect only messages visible to each reader. When replying alone, the narrator can read every summary section. * **Bug Fixes** * Group-chat summaries and scene excerpts reflect what the relevant characters can see. Repeated narrator-visible summaries are omitted, and failed combinations are retried in smaller groups; entries that cannot be safely shortened remain unchanged. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:07:06 +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#7747
No description provided.