[PR #7281] [MERGED] fix(memory): drop excerpt reasons when recall is left out to fit #7661

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

📋 Pull Request Information

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

Base: staging ← Head: fix/excerpts-privacy-code-followup


📝 Commits (3)

  • 53fc9c1 fix(memory): drop excerpt reasons when recall is left out to fit
  • 5e4d29e Merge remote-tracking branch 'origin/staging' into fix/excerpts-privacy-code-followup
  • 12957ae Merge origin/staging into fix/excerpts-privacy-code-followup

📊 Changes

3 files changed (+28 additions, -2 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/services/generation/advanced-memory-context.ts (+7 -1)
📝 scripts/regressions/advanced-memory-context.regression.ts (+20 -1)

📄 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 #7277 (already merged) for #7269. Refs #7269

Why this change

#7277 added reasons that say why a recalled scene has no message excerpt (excerpt-no-room, excerpt-private-scene, excerpt-no-source), shown in the memory receipt and saved as notes in Peek Prompt → Decision diagnostics.

A privacy and correctness review of #7277 found one case where those reasons go stale. When the whole formatted request does not fit with optional recall, prepareAdvancedMemoryContext drops every recalled scene ("Optional recall omitted to fit the complete formatted request."). It already cleared the recalled ids and marked every diagnostics row Not selected, but it kept the excerpt reasons and the new notes. The receipt then:

  • explained missing excerpts of scenes that were not recalled at all;
  • for excerpt-no-room, told the user to raise Summary and recall budget, which would make the request even less likely to fit;
  • kept decision-excerpt-fallback ("Some original excerpts were chosen by text matching…") although no excerpt was sent.

What changed

  • packages/server/src/services/generation/advanced-memory-context.ts: when optional recall is omitted to fit, also drop the excerpt-* and decision-excerpt-fallback reasons and the Decision diagnostics notes. Other reasons (for example decision-recall) stay. The saved swipe snapshot therefore holds only reasons about memory that was actually sent.
  • scripts/regressions/advanced-memory-context.regression.ts: the fake memory service now returns those reasons and a notes list when it recalls something. A new check confirms that the "limited" case (recall dropped to fit a 12k cap) keeps only decision-recall plus the omission note, and has no notes. It fails without the fix. No existing check changed.
  • CHANGELOG.md: one entry at the top of [Unreleased].
  • No model prompt, client copy or docs change.

Review of #7277 (privacy and correctness), no change needed

  • Excerpts are still a contiguous slice of the scene's already filtered source: only messages every reader may read, without disabled or hidden messages and within knowledge starts. Widening between the Decision model's picks cannot add anything else.
  • canRecallExcerpt (narrator-only raw excerpts from scenes whose summary has {{#if char …}} parts) still gates both the Decision message pass and the excerpt size.
  • The new notes are fixed codes, at most 4 of them, so the .max(8) schema cannot reject a saved report or a swipe snapshot.
  • The two-round fit cannot overspend: each scene's round-1 minimum still fits in round 2. The minimum-first round is pinned, because removing it makes advanced-memory-decisions.regression.ts fail ("neither scene loses its excerpt").
  • The new #7277 checks fail on the pre-merge staging (121b46c45) and pass after it.

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 commands (for the reviewer to confirm, not ticked):

  • pnpm check
  • pnpm regression:prompt
  • node ./scripts/run-regressions.mjs --filter for advanced-memory (15/15), memory-recall (5/5), summary (5/5), roleplay-user-private-memory, native-export-memory and roleplay-whisper (2/2)
  • The new check in advanced-memory-context.regression.ts fails with the server change reverted and passes with it.

Manual verification notes

  • Manually verify in a Roleplay chat with Advanced Memory and Use Decision model on, and a connection whose context limit is just big enough for the chat without recall. Send a message so the receipt shows "Optional recall omitted to fit the complete formatted request." Then check that the memory receipt does not also say "Some recalled scenes have no message excerpt…" or "Some original excerpts were chosen by text matching…".
  • Manually verify in the same chat that Peek Prompt → Decision diagnostics → Advanced Memory activity shows every row as Not selected and no missing-excerpt reason under the recall report.
  • Manually verify that with a roomy context limit, the missing-excerpt reasons from #7277 still appear when the summaries fill the recall room.

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)

No docs/ guide changed, so no [docs-i18n] follow-up is needed.

UI evidence (if applicable)

No UI component changed. The fix only stops the server from saving stale reason codes.


🔄 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/7281 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/7/2026 **Status:** ✅ Merged **Merged:** 10/7/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/excerpts-privacy-code-followup` --- ### 📝 Commits (3) - [`53fc9c1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/53fc9c1dc62f3ffb410607f9852c4187863e79ee) fix(memory): drop excerpt reasons when recall is left out to fit - [`5e4d29e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5e4d29e3f6a9441c0fc9096a9e71d1078f45cdab) Merge remote-tracking branch 'origin/staging' into fix/excerpts-privacy-code-followup - [`12957ae`](https://github.com/Pasta-Devs/Marinara-Engine/commit/12957ae8f0b58010050c9fa6c267420db4946e56) Merge origin/staging into fix/excerpts-privacy-code-followup ### 📊 Changes **3 files changed** (+28 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/services/generation/advanced-memory-context.ts` (+7 -1) 📝 `scripts/regressions/advanced-memory-context.regression.ts` (+20 -1) </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 #7277 (already merged) for #7269. Refs #7269 ## Why this change #7277 added reasons that say why a recalled scene has no message excerpt (`excerpt-no-room`, `excerpt-private-scene`, `excerpt-no-source`), shown in the memory receipt and saved as `notes` in **Peek Prompt → Decision diagnostics**. A privacy and correctness review of #7277 found one case where those reasons go stale. When the whole formatted request does not fit with optional recall, `prepareAdvancedMemoryContext` drops every recalled scene ("Optional recall omitted to fit the complete formatted request."). It already cleared the recalled ids and marked every diagnostics row **Not selected**, but it kept the excerpt reasons and the new `notes`. The receipt then: - explained missing excerpts of scenes that were not recalled at all; - for `excerpt-no-room`, told the user to raise **Summary and recall budget**, which would make the request even less likely to fit; - kept `decision-excerpt-fallback` ("Some original excerpts were chosen by text matching…") although no excerpt was sent. ## What changed - `packages/server/src/services/generation/advanced-memory-context.ts`: when optional recall is omitted to fit, also drop the `excerpt-*` and `decision-excerpt-fallback` reasons and the Decision diagnostics `notes`. Other reasons (for example `decision-recall`) stay. The saved swipe snapshot therefore holds only reasons about memory that was actually sent. - `scripts/regressions/advanced-memory-context.regression.ts`: the fake memory service now returns those reasons and a `notes` list when it recalls something. A new check confirms that the "limited" case (recall dropped to fit a 12k cap) keeps only `decision-recall` plus the omission note, and has no `notes`. It fails without the fix. No existing check changed. - `CHANGELOG.md`: one entry at the top of `[Unreleased]`. - No model prompt, client copy or docs change. ### Review of #7277 (privacy and correctness), no change needed - Excerpts are still a contiguous slice of the scene's already filtered source: only messages every reader may read, without disabled or hidden messages and within knowledge starts. Widening between the Decision model's picks cannot add anything else. - `canRecallExcerpt` (narrator-only raw excerpts from scenes whose summary has `{{#if char …}}` parts) still gates both the Decision message pass and the excerpt size. - The new `notes` are fixed codes, at most 4 of them, so the `.max(8)` schema cannot reject a saved report or a swipe snapshot. - The two-round fit cannot overspend: each scene's round-1 minimum still fits in round 2. The minimum-first round is pinned, because removing it makes `advanced-memory-decisions.regression.ts` fail ("neither scene loses its excerpt"). - The new #7277 checks fail on the pre-merge staging (`121b46c45`) and pass after it. ## 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 commands (for the reviewer to confirm, not ticked): - `pnpm check` - `pnpm regression:prompt` - `node ./scripts/run-regressions.mjs --filter` for `advanced-memory` (15/15), `memory-recall` (5/5), `summary` (5/5), `roleplay-user-private-memory`, `native-export-memory` and `roleplay-whisper` (2/2) - The new check in `advanced-memory-context.regression.ts` fails with the server change reverted and passes with it. ### Manual verification notes - Manually verify in a Roleplay chat with Advanced Memory and **Use Decision model** on, and a connection whose context limit is just big enough for the chat without recall. Send a message so the receipt shows "Optional recall omitted to fit the complete formatted request." Then check that the memory receipt does not also say "Some recalled scenes have no message excerpt…" or "Some original excerpts were chosen by text matching…". - Manually verify in the same chat that **Peek Prompt → Decision diagnostics → Advanced Memory activity** shows every row as **Not selected** and no missing-excerpt reason under the recall report. - Manually verify that with a roomy context limit, the missing-excerpt reasons from #7277 still appear when the summaries fill the recall room. ## 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) No `docs/` guide changed, so no `[docs-i18n]` follow-up is needed. ## UI evidence (if applicable) No UI component changed. The fix only stops the server from saving stale reason codes. --- <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:16 +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#7661
No description provided.