[PR #7391] [MERGED] fix(memory): show where absent characters were when deciding who sees a message #7713

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

📋 Pull Request Information

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

Base: staging ← Head: fix/visibility-last-seen


📝 Commits (8)

  • 8d122ad fix(memory): show where absent characters were when deciding who sees a message
  • 2bbc47f fix(memory): keep where absent characters were through trimming, and prefer the latest sighting
  • 953aff9 fix(memory): add a last sighting only for characters who were away
  • 4814442 fix(memory): count a character as away only when the whole scene was hidden from them
  • 415c0a0 fix(memory): judge "away" over the whole scene, and only after a few decisions
  • 6665a8d fix(memory): count a scene message nobody decided as visible to everyone
  • 1d64d44 fix(memory): apply the away rule only inside a saved scene
  • 12bac83 fix(memory): never bring back a message hidden from the AI as last seen

📊 Changes

3 files changed (+145 additions, -13 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/services/advanced-memory.ts (+58 -13)
📝 scripts/regressions/advanced-memory-visibility.regression.ts (+86 -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

Closes #7390

Why this change

  • Mari reported that Decide who sees new messages (Advanced Memory, Decision model = hosted Jev) stopped hiding messages, so she had to hide them by hand.
  • Her chat: since a *** scene break, every message is one stair scene and three characters are far away. The automatic decisions hid all three for the first messages of the scene, then two, then one, then nobody.
  • The visibility code itself didn't change. #7373/#7374 made Decision-model scene checks actually save scene starts. planVisibility shows the decision the current scene plus at least 4 earlier messages. Before #7371, scenes never ended, so that window always reached back into earlier scenes. Now, once a scene runs past 4 messages, the window never places the absent characters anywhere. The presence question treats "unclear" as present, so nobody is hidden.
  • Evidence: a replay of her chat (her messages, settings and scene records) against a local System One mock. Every presence request was small (at most about 6k of 30k tokens), well-formed and answered quickly, on this build and on the build before #7371, and the request bodies were byte-identical. The absent characters' names left the Decision state in exactly the order the live decisions got worse.

What changed

Rule chosen by Mari (2026-10-10): a character counts as away only when every earlier message of the current scene was hidden from them, by the decision or by her own hides.

  • planVisibility collects the saved hiddenFromAICharacterIds of every earlier message of the scene that isn't hidden from everyone. A message nobody decided (older than the decision window, or from before the setting was on) counts as visible to all. A candidate hidden from every one of them, across at least four messages, is away. This applies only inside a saved scene: without a saved scene start, the last 12 messages may not be the whole scene, so nothing is added there, and those chats keep staging's 12-message window, which #7390 did not shrink. Each away candidate's latest earlier message joins the presence transcript, so the decision still sees where they are once the scene runs long. A message hidden from the AI is never chosen. Anyone who could perceive any of the scene gets nothing added.
  • What that means in practice: one step-out, a short cutaway, or a cutaway the scene check opened a scene with makes nobody away, and a character carried in silently is never shown somewhere else. One message wrongly left visible to a character switches the rule off for that scene until it is hidden by hand. No names are matched, so it works in any language.
  • visibilityTranscript keeps those messages, in time order, through trimming (the oldest other context goes first, keeping at least four other earlier messages). A message pulled in from before the window is shortened to 256 tokens; one already in the window keeps its full length.
  • Regression (advanced-memory-visibility), all failing without their part of the fix:
    • away all scene: the swamp line is kept first through trimming;
    • carried in, never hidden: nothing is added;
    • one step-out at the end: nothing is added;
    • a scene that opens with a two-message cutaway: nothing is added;
    • a scene with one undecided message before eleven hidden ones: nothing is added;
    • no saved scene start: nothing is added;
    • her latest message is hidden from the AI: the one before it is used instead.
    • The existing exact-transcript case is unchanged.
  • Replay of her chat: from the stair scene's fourth decided message on, every presence request includes Maukie's and Tighnari's last messages. Before, they were gone by 10:31Z. Cyno's last message is older than the 30 replayed messages; her real chat has it.

Known residual, accepted: a cutaway of four or more messages, all hidden from a silent companion whose last line was elsewhere, followed by a return to them.

Review

  • Five rounds of adversarial review. Each rejected design could hide a present character:
    • an unconditional last line;
    • matching names, which missed Chinese, Japanese and Korean names, inflected names and surnames, and counted mentions from afar;
    • deciding "away" from the latest decided message alone, which fired on a step-out or cutaway;
    • deciding it over only the messages in view, or over a scene the scene check opened at a cutaway.
  • Local CodeRabbit:
    • Fixed: its point to check the whole saved scene; to count a scene message nobody decided as visible; to skip messages hidden from the AI when choosing a last line. The last run had no findings.
  • GitHub CodeRabbit: fixed its point that the 12-message fallback isn't a whole scene.
    • Declined: changelog-length nits (rewritten to be plainer instead).
    • Follow-up, not done here: its idea to pass "away" to the model as an explicit fact needs measuring against hosted Jev first.

Not changed: a failed shared presence answer still hides nothing and isn't asked again, as the existing regression requires.

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 by the agent: pnpm check; node ./scripts/run-regressions.mjs --filter for all 16 advanced-memory-* regressions, roleplay-whisper-hidden-recipient, roleplay-user-private-generation and prompt (all pass).

Manual verification notes

  • Manually verify in a one-by-one Roleplay group chat with the Decision model on: after a scene break and five or more messages without some characters, new messages are hidden from them again.
  • Manually verify that a character who is in the scene but silent is not hidden.

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)

CHANGELOG [Unreleased] has an entry. No user docs change.

Summary by CodeRabbit

  • Bug Fixes
    • In one-by-one Roleplay group chats, a character counts as away only if they were hidden from every earlier scene message across at least four messages. Messages without a visibility decision, or messages they could see, do not qualify.
    • When this condition is met, the character’s latest earlier assistant message can inform visibility decisions in longer scenes, even after older conversation is trimmed. Short cutaways do not qualify.

🔄 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/7391 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/10/2026 **Status:** ✅ Merged **Merged:** 10/10/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/visibility-last-seen` --- ### 📝 Commits (8) - [`8d122ad`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8d122ad94314dd1e3993569ee7e08522ed4e8bde) fix(memory): show where absent characters were when deciding who sees a message - [`2bbc47f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2bbc47fc8e0c8c13661ea2be58a387404489539a) fix(memory): keep where absent characters were through trimming, and prefer the latest sighting - [`953aff9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/953aff9d64bf70d96a257d250d25f35c004cd6e1) fix(memory): add a last sighting only for characters who were away - [`4814442`](https://github.com/Pasta-Devs/Marinara-Engine/commit/481444283f60f28135cbcb65c93163532ec4cd3e) fix(memory): count a character as away only when the whole scene was hidden from them - [`415c0a0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/415c0a056f9b65f9ad4c23323e305c0b51af44eb) fix(memory): judge "away" over the whole scene, and only after a few decisions - [`6665a8d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6665a8da27d1e062fc55364496a46de71d735f08) fix(memory): count a scene message nobody decided as visible to everyone - [`1d64d44`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1d64d4461e52c732c327ce0c77d229af018d68d6) fix(memory): apply the away rule only inside a saved scene - [`12bac83`](https://github.com/Pasta-Devs/Marinara-Engine/commit/12bac83bf6b513867b46a4cbec1390762a35f669) fix(memory): never bring back a message hidden from the AI as last seen ### 📊 Changes **3 files changed** (+145 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/services/advanced-memory.ts` (+58 -13) 📝 `scripts/regressions/advanced-memory-visibility.regression.ts` (+86 -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 Closes #7390 ## Why this change - Mari reported that **Decide who sees new messages** (Advanced Memory, Decision model = hosted Jev) stopped hiding messages, so she had to hide them by hand. - Her chat: since a `***` scene break, every message is one stair scene and three characters are far away. The automatic decisions hid all three for the first messages of the scene, then two, then one, then nobody. - The visibility code itself didn't change. #7373/#7374 made Decision-model scene checks actually save scene starts. `planVisibility` shows the decision the current scene plus at least 4 earlier messages. Before #7371, scenes never ended, so that window always reached back into earlier scenes. Now, once a scene runs past 4 messages, the window never places the absent characters anywhere. The presence question treats "unclear" as present, so nobody is hidden. - Evidence: a replay of her chat (her messages, settings and scene records) against a local System One mock. Every presence request was small (at most about 6k of 30k tokens), well-formed and answered quickly, on this build and on the build before #7371, and the request bodies were byte-identical. The absent characters' names left the Decision state in exactly the order the live decisions got worse. ## What changed Rule chosen by Mari (2026-10-10): **a character counts as away only when every earlier message of the current scene was hidden from them**, by the decision or by her own hides. - `planVisibility` collects the saved `hiddenFromAICharacterIds` of every earlier message of the scene that isn't hidden from everyone. A message nobody decided (older than the decision window, or from before the setting was on) counts as visible to all. A candidate hidden from every one of them, across at least four messages, is away. This applies only inside a saved scene: without a saved scene start, the last 12 messages may not be the whole scene, so nothing is added there, and those chats keep staging's 12-message window, which #7390 did not shrink. Each away candidate's latest earlier message joins the presence transcript, so the decision still sees where they are once the scene runs long. A message hidden from the AI is never chosen. Anyone who could perceive any of the scene gets nothing added. - What that means in practice: one step-out, a short cutaway, or a cutaway the scene check opened a scene with makes nobody away, and a character carried in silently is never shown somewhere else. One message wrongly left visible to a character switches the rule off for that scene until it is hidden by hand. No names are matched, so it works in any language. - `visibilityTranscript` keeps those messages, in time order, through trimming (the oldest other context goes first, keeping at least four other earlier messages). A message pulled in from before the window is shortened to 256 tokens; one already in the window keeps its full length. - Regression (`advanced-memory-visibility`), all failing without their part of the fix: - away all scene: the swamp line is kept first through trimming; - carried in, never hidden: nothing is added; - one step-out at the end: nothing is added; - a scene that opens with a two-message cutaway: nothing is added; - a scene with one undecided message before eleven hidden ones: nothing is added; - no saved scene start: nothing is added; - her latest message is hidden from the AI: the one before it is used instead. - The existing exact-transcript case is unchanged. - Replay of her chat: from the stair scene's fourth decided message on, every presence request includes Maukie's and Tighnari's last messages. Before, they were gone by 10:31Z. Cyno's last message is older than the 30 replayed messages; her real chat has it. Known residual, accepted: a cutaway of four or more messages, all hidden from a silent companion whose last line was elsewhere, followed by a return to them. ## Review - Five rounds of adversarial review. Each rejected design could hide a present character: - an unconditional last line; - matching names, which missed Chinese, Japanese and Korean names, inflected names and surnames, and counted mentions from afar; - deciding "away" from the latest decided message alone, which fired on a step-out or cutaway; - deciding it over only the messages in view, or over a scene the scene check opened at a cutaway. - Local CodeRabbit: - Fixed: its point to check the whole saved scene; to count a scene message nobody decided as visible; to skip messages hidden from the AI when choosing a last line. The last run had no findings. - GitHub CodeRabbit: fixed its point that the 12-message fallback isn't a whole scene. - Declined: changelog-length nits (rewritten to be plainer instead). - Follow-up, not done here: its idea to pass "away" to the model as an explicit fact needs measuring against hosted Jev first. Not changed: a failed shared presence answer still hides nothing and isn't asked again, as the existing regression requires. ## 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 by the agent: `pnpm check`; `node ./scripts/run-regressions.mjs --filter` for all 16 `advanced-memory-*` regressions, roleplay-whisper-hidden-recipient, roleplay-user-private-generation and prompt (all pass). ### Manual verification notes - Manually verify in a one-by-one Roleplay group chat with the Decision model on: after a scene break and five or more messages without some characters, new messages are hidden from them again. - Manually verify that a character who is in the scene but silent is not hidden. ## 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) CHANGELOG `[Unreleased]` has an entry. No user docs change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * In one-by-one Roleplay group chats, a character counts as away only if they were hidden from every earlier scene message across at least four messages. Messages without a visibility decision, or messages they could see, do not qualify. * When this condition is met, the character’s latest earlier assistant message can inform visibility decisions in longer scenes, even after older conversation is trimmed. Short cutaways do not qualify. <!-- 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:46 +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#7713
No description provided.