[PR #7381] [MERGED] fix(roleplay): deliver whisper-only messages with Advanced Memory on #7709

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

📋 Pull Request Information

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

Base: staging ← Head: fix/whisper-only-user-message


📝 Commits (8)

  • f74861c fix(roleplay): deliver whisper-only messages with Advanced Memory on
  • 2d74fd0 fix(roleplay): place whisper-only whispers inside their wrapper and window
  • bd0b88a fix(roleplay): keep whisper placeholders whole and the empty window narrow
  • a7db608 fix(roleplay): let memory's own rules pick which whisper-only messages count
  • e7bc0e2 fix(roleplay): add whisper-only messages inside Advanced Memory's own window
  • 176fd2d fix(roleplay): rebuild stale memory snapshots for whisper-only messages
  • 363595c docs(changelog): note that regenerating a reply picks up a missed whisper
  • 3a6736f Merge remote-tracking branch 'origin/staging' into fix/whisper-only-user-message

📊 Changes

6 files changed (+365 additions, -17 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/routes/generate.routes.ts (+10 -1)
📝 packages/server/src/routes/generate/dry-run-route.ts (+18 -5)
📝 packages/server/src/services/advanced-memory.ts (+43 -4)
📝 packages/server/src/services/generation/roleplay-commands.ts (+38 -5)
📝 scripts/regressions/roleplay-whisper-hidden-recipient.regression.ts (+255 -2)

📄 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 #7380

Why this change

  • In a Roleplay chat with Advanced Memory on, a message that is only a whisper (for example [whisper: character="Powers That Be" text="..."] with nothing else) never reached its recipient or the narrator. Whispers the model wrote, and whispers inside a message with other text, did arrive.
  • The message saves with an empty visible body and keeps the whisper in its extra data. Advanced Memory keeps only messages with text or attachments, so this message was never in its kept window. The prompt dropped it, and appendRoleplayWhispers had no message to attach the whisper to. Without Advanced Memory, the same message shows as [Private whisper] and the whisper arrives.
  • Seen on a live chat: the narrator's saved prompt ended with the previous character's turn. Its Advanced Memory snapshot listed seven kept messages without the whisper message, even though that message was the last one the memory pass covered.

What changed

  • Advanced Memory preparation (prepareImpl): after building its live window, it also lists the whisper-only messages its own reader rules allow (allowed() with a new keepEmptyIds option) that come after the window's start: the context boundary, or the end of a trimmed open-scene prefix. So conversation starts, personal starts, saved context starts, knowledge starts, regeneration prefixes, hiding and merged readers all apply as they do to text. These messages are never part of a record, so recall, archives and summaries are unchanged.
  • Preparation version bumped to v23, so a reply saved before this fix is prepared again when regenerated instead of reusing a snapshot without the whisper.
  • Shared agent prompt and Peek Prompt's first pass add the same messages through selectAdvancedMemoryWhisperOnlyIds. Peek then runs the same preparation as the live route. Under impersonation, Peek now reads memory as its owner, without one character's knowledge range, as the live route already did.
  • Whisper placement (appendRoleplayWhispers): when a message's body is the [Private whisper] placeholder, every whisper goes right after it. Before, a whisper-only last message got its whisper after the closing </last_message> (and a second closing tag after Advanced Memory re-wrapped it), and a blank body such as [whisper …] [whisper …] could split the placeholder. The #7191 stand-ins use the same rule.
  • filterPromptHistoryByMessageIds and the Advanced Memory context are unchanged from staging.
  • Regression (roleplay-whisper-hidden-recipient), all through the real routes with Advanced Memory on: a whisper-only user message to the narrator, and a narrator reply that is only a whisper; a single closing tag; a conversation reset; a chat that opens with a whisper; a blank body between two whispers; a personal conversation start on a whisper; a system notice between a whisper and later text; a knowledge start on a whisper; regenerating before a knowledge start; a one-character chat; impersonation in Peek Prompt. Each case was checked to fail without its part of the fix.

Review

  • Local CodeRabbit (6 runs): fixed the empty-window case, attachments counted as whisper-only, and a weak wrapper assertion (also raised on GitHub). Declined "add merged-mode coverage": whispers are only delivered in one-by-one group chats and one-character chats, which this PR does not change, so a one-character case was added instead.
  • Multi-agent adversarial review over five rounds. Earlier designs placed whisper-only messages by guessing memory's window from the kept messages. Each guess missed a case: a system notice in between, a personal start, a knowledge start, a saved context start. The final design moves the decision into Advanced Memory's own preparation, which knows the window. The last round's findings (stale snapshots, impersonation in Peek, attachments) are fixed. Refuted along the way: a [Private whisper] trace for characters that automatic visibility never decides on (same as without Advanced Memory), and no regression for the sharedPromptForAgents wiring (a coverage gap, not a defect).

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 plus roleplay-whisper-hidden-recipient, roleplay-whisper-generation, roleplay-user-private-generation, roleplay-user-private-storage, roleplay-user-private-memory, roleplay-commands, roleplay-regeneration-context and prompt (all 24 pass).

Manual verification notes

  • Manually verify in a Roleplay group chat with Advanced Memory on: send only [whisper: character="<narrator name>" text="..."], generate the narrator's reply, and check in Peek Prompt that the whisper appears right after [Private whisper] under your message.
  • Manually verify that another character's Peek Prompt shows only [Private whisper] for that message, not the text.
  • Manually verify that regenerating a narrator reply that missed a whisper before this fix now includes the whisper.

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 Roleplay chats with Advanced Memory enabled, messages and replies containing only whispers now reach their intended recipients and the narrator. Whisper-only content appears in the appropriate conversation context, including prompt previews and chats that are just starting. Existing visibility, audience, and conversation-start filtering continues to apply.
    • Regenerating a reply that previously missed a whisper now includes that whisper when it is visible to the prompt’s intended audience.

🔄 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/7381 **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/whisper-only-user-message` --- ### 📝 Commits (8) - [`f74861c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f74861c03eeeb74c5822c53b1c205110d183e438) fix(roleplay): deliver whisper-only messages with Advanced Memory on - [`2d74fd0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2d74fd0181f726178b0a3cbd5584a6af7e760fe4) fix(roleplay): place whisper-only whispers inside their wrapper and window - [`bd0b88a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bd0b88a2fa802f38d9685015f7e6e700fc167d07) fix(roleplay): keep whisper placeholders whole and the empty window narrow - [`a7db608`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a7db6083a6ae72dffcee8d73a47f7201a9898a04) fix(roleplay): let memory's own rules pick which whisper-only messages count - [`e7bc0e2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e7bc0e2248a12219ef45de98e4a4bd4f14499c01) fix(roleplay): add whisper-only messages inside Advanced Memory's own window - [`176fd2d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/176fd2de5324e6ed873ff774333e6ca6f220643b) fix(roleplay): rebuild stale memory snapshots for whisper-only messages - [`363595c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/363595c169e37e630ae9e5889cbfff484a0fe45e) docs(changelog): note that regenerating a reply picks up a missed whisper - [`3a6736f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3a6736fb0cffbb6e3032fdcba3514977c3e87bfe) Merge remote-tracking branch 'origin/staging' into fix/whisper-only-user-message ### 📊 Changes **6 files changed** (+365 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+10 -1) 📝 `packages/server/src/routes/generate/dry-run-route.ts` (+18 -5) 📝 `packages/server/src/services/advanced-memory.ts` (+43 -4) 📝 `packages/server/src/services/generation/roleplay-commands.ts` (+38 -5) 📝 `scripts/regressions/roleplay-whisper-hidden-recipient.regression.ts` (+255 -2) </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 #7380 ## Why this change - In a Roleplay chat with Advanced Memory on, a message that is only a whisper (for example `[whisper: character="Powers That Be" text="..."]` with nothing else) never reached its recipient or the narrator. Whispers the model wrote, and whispers inside a message with other text, did arrive. - The message saves with an empty visible body and keeps the whisper in its extra data. Advanced Memory keeps only messages with text or attachments, so this message was never in its kept window. The prompt dropped it, and `appendRoleplayWhispers` had no message to attach the whisper to. Without Advanced Memory, the same message shows as `[Private whisper]` and the whisper arrives. - Seen on a live chat: the narrator's saved prompt ended with the previous character's turn. Its Advanced Memory snapshot listed seven kept messages without the whisper message, even though that message was the last one the memory pass covered. ## What changed - **Advanced Memory preparation** (`prepareImpl`): after building its live window, it also lists the whisper-only messages its own reader rules allow (`allowed()` with a new `keepEmptyIds` option) that come after the window's start: the context boundary, or the end of a trimmed open-scene prefix. So conversation starts, personal starts, saved context starts, knowledge starts, regeneration prefixes, hiding and merged readers all apply as they do to text. These messages are never part of a record, so recall, archives and summaries are unchanged. - **Preparation version** bumped to v23, so a reply saved before this fix is prepared again when regenerated instead of reusing a snapshot without the whisper. - **Shared agent prompt and Peek Prompt's first pass** add the same messages through `selectAdvancedMemoryWhisperOnlyIds`. Peek then runs the same preparation as the live route. Under impersonation, Peek now reads memory as its owner, without one character's knowledge range, as the live route already did. - **Whisper placement** (`appendRoleplayWhispers`): when a message's body is the `[Private whisper]` placeholder, every whisper goes right after it. Before, a whisper-only last message got its whisper after the closing `</last_message>` (and a second closing tag after Advanced Memory re-wrapped it), and a blank body such as `[whisper …] [whisper …]` could split the placeholder. The #7191 stand-ins use the same rule. - `filterPromptHistoryByMessageIds` and the Advanced Memory context are unchanged from staging. - **Regression** (`roleplay-whisper-hidden-recipient`), all through the real routes with Advanced Memory on: a whisper-only user message to the narrator, and a narrator reply that is only a whisper; a single closing tag; a conversation reset; a chat that opens with a whisper; a blank body between two whispers; a personal conversation start on a whisper; a system notice between a whisper and later text; a knowledge start on a whisper; regenerating before a knowledge start; a one-character chat; impersonation in Peek Prompt. Each case was checked to fail without its part of the fix. ## Review - Local CodeRabbit (6 runs): fixed the empty-window case, attachments counted as whisper-only, and a weak wrapper assertion (also raised on GitHub). Declined "add merged-mode coverage": whispers are only delivered in one-by-one group chats and one-character chats, which this PR does not change, so a one-character case was added instead. - Multi-agent adversarial review over five rounds. Earlier designs placed whisper-only messages by guessing memory's window from the kept messages. Each guess missed a case: a system notice in between, a personal start, a knowledge start, a saved context start. The final design moves the decision into Advanced Memory's own preparation, which knows the window. The last round's findings (stale snapshots, impersonation in Peek, attachments) are fixed. Refuted along the way: a `[Private whisper]` trace for characters that automatic visibility never decides on (same as without Advanced Memory), and no regression for the `sharedPromptForAgents` wiring (a coverage gap, not a defect). ## 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 plus roleplay-whisper-hidden-recipient, roleplay-whisper-generation, roleplay-user-private-generation, roleplay-user-private-storage, roleplay-user-private-memory, roleplay-commands, roleplay-regeneration-context and prompt (all 24 pass). ### Manual verification notes - Manually verify in a Roleplay group chat with Advanced Memory on: send only `[whisper: character="<narrator name>" text="..."]`, generate the narrator's reply, and check in Peek Prompt that the whisper appears right after `[Private whisper]` under your message. - Manually verify that another character's Peek Prompt shows only `[Private whisper]` for that message, not the text. - Manually verify that regenerating a narrator reply that missed a whisper before this fix now includes the whisper. ## 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 Roleplay chats with Advanced Memory enabled, messages and replies containing only whispers now reach their intended recipients and the narrator. Whisper-only content appears in the appropriate conversation context, including prompt previews and chats that are just starting. Existing visibility, audience, and conversation-start filtering continues to apply. * Regenerating a reply that previously missed a whisper now includes that whisper when it is visible to the prompt’s intended audience. <!-- 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:45 +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#7709
No description provided.