[PR #7374] [MERGED] fix(memory): check every new message and show the last checked one #7705

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

📋 Pull Request Information

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

Base: staging ← Head: fix/scene-check-every-new-message


📝 Commits (7)

  • c95ebfd fix(memory): check every new message and show the last checked one
  • f404f23 Merge branch 'staging' into fix/scene-check-every-new-message
  • 5be70cc fix(memory): shorten a long previous message in the scene check
  • 4727872 fix(memory): show the Helper who wrote each scene-check message
  • 43bda6d fix(memory): restore scene-check guards and suites broken by #7373
  • 962baa4 Merge remote-tracking branch 'origin/fix/memory-scene-regressions' into fix/scene-check-every-new-message
  • 05aa664 Merge branch 'staging' into fix/scene-check-every-new-message

📊 Changes

10 files changed (+154 additions, -37 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/agents/memory.md (+1 -1)
📝 packages/client/src/localization/locales/en.json (+1 -1)
📝 packages/server/src/routes/generate.routes.ts (+3 -1)
📝 packages/server/src/services/advanced-memory-decisions.ts (+1 -2)
📝 packages/server/src/services/advanced-memory.ts (+55 -19)
📝 scripts/regressions/advanced-memory-decisions.regression.ts (+79 -6)
📝 scripts/regressions/advanced-memory-local-decision.regression.ts (+1 -1)
📝 scripts/regressions/advanced-memory-post-generation.regression.ts (+11 -5)
📝 scripts/regressions/advanced-memory-recall-shortlist.regression.ts (+1 -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.

Note

Stacked on #7373 (base fix/memory-scene-cuts-rescan). Once #7373 merges, GitHub retargets this PR to staging, and the diff shrinks to this change alone.

Linked issue

Refs #7371. It covers the two remaining gaps the maintainer approved in that thread. #7373 already closes the issue itself.

Why this change

These are two more ways a scene change was never asked about after a reply:

  1. Messages skipped when a turn jumps past the interval. The check fires once at least N new messages exist (N = Standalone scene check interval, default 5). It then sent only the last N. When your message and a reply arrived together, the count went from 4 to 6, and the oldest new message was never checked. A simulation of the maintainer's real chat, which lands on its known last check (1256–1260), shows #1180, #1201, #1212, #1228, #1234 and #1240 were never checked. That is about one in every three checks.
  2. The Helper model's seam. The Helper must name the message whose end finishes a scene, chosen from the checked messages. A scene change right at the first checked message ends the scene on the message before it, which the Helper never saw. One check earlier, that message was the last one, with nothing after it. So a change exactly between two checks got past both. (#7373 fixed this for the Decision model.)

What changed

  • getSceneCheck sends every message since the last check: at least the interval, as before, and at most twice the interval after missed checks (a ponytail: note says Re-scan scenes covers a longer backlog). When checks fire on time, the window is unchanged.
  • The request carries previous, the last message the previous check saw. sceneCheckTranscript() puts it first, marked alreadyChecked: true, for the standalone Helper call, the shared presence call and the tracker-bundled call. A bundled tracker only gets it when that message is already in its audience's view, the same rule its window follows. The commit accepts an ending on that message.
  • SCENE_CHECK_PROMPT explains alreadyChecked, saying to report it only when the next message starts a new scene. It also names switches to characters elsewhere and scene-break lines such as ***.
  • The interval's help text, docs/agents/memory.md and CHANGELOG describe the new window.

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

Automated evidence (the boxes above are for a human):

  • pnpm check passed locally.
  • New regression on a Helper chat with interval 2: one turn adds three messages. All three are checked, after message #2 marked alreadyChecked. A scene change at the first new message ends the scene on #2. Without this change, the window was [4, 5] and nothing came before it.
  • The post-reply suite's existing "subsequent checks inspect exactly the configured number of latest messages" assertion is kept, now on the checked messages. A new assertion checks the alreadyChecked entry. The suite's Helper mock ignores alreadyChecked, as the prompt instructs.

Manual verification notes

  • Manually verify with Use Decision model off, interval 5: send a message after four new ones, so the count jumps to 6. Peek Prompt / debug logs should show the scene prompt with all six new messages plus one alreadyChecked message.
  • Manually verify a tracker-bundled check in a group chat where the previous message is hidden from that tracker's character: the previous message must not appear in that tracker's prompt.

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)

One CHANGELOG entry, one help-text change, and one docs paragraph, which is added to #7372.

UI evidence (if applicable)

Help text only.

Summary by CodeRabbit

  • Improvements
    • Advanced Memory checks messages received since its previous scene check once the configured interval is reached after a reply, considering up to twice that interval at a time. Longer backlogs require Re-scan scenes.
    • Checks include the previous check’s ending message for comparison, along with message authors.
    • Scene changes can include switching to a character who is elsewhere or an explicit scene-break line.
    • Updated guidance clarifies when checks occur and which messages they consider.

🔄 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/7374 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/scene-check-every-new-message` --- ### 📝 Commits (7) - [`c95ebfd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c95ebfdd1df481557c4c498ad147a1c6c10a0b78) fix(memory): check every new message and show the last checked one - [`f404f23`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f404f23bfc687d6b893a69c0abd23a887456973a) Merge branch 'staging' into fix/scene-check-every-new-message - [`5be70cc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5be70cc80cd5d50fd547298860ffcadcbb2b34ed) fix(memory): shorten a long previous message in the scene check - [`4727872`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4727872c97177bd338448642ba9d6802ceca73fb) fix(memory): show the Helper who wrote each scene-check message - [`43bda6d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/43bda6d0c247dda524cf030ee56960aad6ee0c0a) fix(memory): restore scene-check guards and suites broken by #7373 - [`962baa4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/962baa4141a1dd3006721d3a8a99be7aeef6374e) Merge remote-tracking branch 'origin/fix/memory-scene-regressions' into fix/scene-check-every-new-message - [`05aa664`](https://github.com/Pasta-Devs/Marinara-Engine/commit/05aa6648e979a0c6735ae9a27884a9dc0b9e53b9) Merge branch 'staging' into fix/scene-check-every-new-message ### 📊 Changes **10 files changed** (+154 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/agents/memory.md` (+1 -1) 📝 `packages/client/src/localization/locales/en.json` (+1 -1) 📝 `packages/server/src/routes/generate.routes.ts` (+3 -1) 📝 `packages/server/src/services/advanced-memory-decisions.ts` (+1 -2) 📝 `packages/server/src/services/advanced-memory.ts` (+55 -19) 📝 `scripts/regressions/advanced-memory-decisions.regression.ts` (+79 -6) 📝 `scripts/regressions/advanced-memory-local-decision.regression.ts` (+1 -1) 📝 `scripts/regressions/advanced-memory-post-generation.regression.ts` (+11 -5) 📝 `scripts/regressions/advanced-memory-recall-shortlist.regression.ts` (+1 -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`. > [!NOTE] > Stacked on #7373 (base `fix/memory-scene-cuts-rescan`). Once #7373 merges, GitHub retargets this PR to `staging`, and the diff shrinks to this change alone. ## Linked issue Refs #7371. It covers the two remaining gaps the maintainer approved in that thread. #7373 already closes the issue itself. ## Why this change These are two more ways a scene change was never asked about after a reply: 1. **Messages skipped when a turn jumps past the interval.** The check fires once at least *N* new messages exist (*N* = **Standalone scene check interval**, default 5). It then sent only the last *N*. When your message and a reply arrived together, the count went from 4 to 6, and the oldest new message was never checked. A simulation of the maintainer's real chat, which lands on its known last check (1256–1260), shows #1180, #1201, #1212, #1228, #1234 and #1240 were never checked. That is about one in every three checks. 2. **The Helper model's seam.** The Helper must name the message whose end finishes a scene, chosen from the checked messages. A scene change right at the first checked message ends the scene on the message before it, which the Helper never saw. One check earlier, that message was the last one, with nothing after it. So a change exactly between two checks got past both. (#7373 fixed this for the Decision model.) ## What changed - `getSceneCheck` sends every message since the last check: at least the interval, as before, and at most twice the interval after missed checks (a `ponytail:` note says Re-scan scenes covers a longer backlog). When checks fire on time, the window is unchanged. - The request carries `previous`, the last message the previous check saw. `sceneCheckTranscript()` puts it first, marked `alreadyChecked: true`, for the standalone Helper call, the shared presence call and the tracker-bundled call. A bundled tracker only gets it when that message is already in its audience's view, the same rule its window follows. The commit accepts an ending on that message. - `SCENE_CHECK_PROMPT` explains `alreadyChecked`, saying to report it only when the next message starts a new scene. It also names switches to characters elsewhere and scene-break lines such as `***`. - The interval's help text, `docs/agents/memory.md` and CHANGELOG describe the new window. ## 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` Automated evidence (the boxes above are for a human): - `pnpm check` passed locally. - New regression on a Helper chat with interval 2: one turn adds three messages. All three are checked, after message #2 marked `alreadyChecked`. A scene change at the first new message ends the scene on #2. Without this change, the window was `[4, 5]` and nothing came before it. - The post-reply suite's existing "subsequent checks inspect exactly the configured number of latest messages" assertion is kept, now on the checked messages. A new assertion checks the `alreadyChecked` entry. The suite's Helper mock ignores `alreadyChecked`, as the prompt instructs. ### Manual verification notes - Manually verify with **Use Decision model** off, interval 5: send a message after four new ones, so the count jumps to 6. **Peek Prompt** / debug logs should show the scene prompt with all six new messages plus one `alreadyChecked` message. - Manually verify a tracker-bundled check in a group chat where the previous message is hidden from that tracker's character: the previous message must not appear in that tracker's prompt. ## 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) One CHANGELOG entry, one help-text change, and one docs paragraph, which is added to #7372. ## UI evidence (if applicable) Help text only. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Improvements** * Advanced Memory checks messages received since its previous scene check once the configured interval is reached after a reply, considering up to twice that interval at a time. Longer backlogs require **Re-scan scenes**. * Checks include the previous check’s ending message for comparison, along with message authors. * Scene changes can include switching to a character who is elsewhere or an explicit scene-break line. * Updated guidance clarifies when checks occur and which messages they consider. <!-- 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:06:41 +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#7705
No description provided.