[PR #6584] [MERGED] fix(roleplay): preserve live instructions across memory cutoffs #7235

Closed
opened 2026-10-23 04:17:47 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: staging ← Head: codex/roleplay-regeneration-context


📝 Commits (2)

  • aedea82 docs: track Roleplay regeneration fixes for #6583
  • 19ac250 fix(roleplay): keep live instructions through memory cutoffs

📊 Changes

4 files changed (+303 additions, -13 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 packages/server/src/services/generation/roleplay-commands.ts (+20 -9)
📝 scripts/regressions/roleplay-commands.regression.ts (+16 -4)
➕ scripts/regressions/roleplay-regeneration-context.regression.ts (+265 -0)

📄 Description

Linked issue

Related to #6583. Keep the issue open: this fixes a reproduced cutoff failure, while the original discarded-swipe leak still needs confirmation.

Why this change

Roleplay Personal Notes and command instructions could be appended to an old user message. Advanced Memory then removed that message at the live-context cutoff, removing the current instructions with it. This is reproducible when the retained history ends in the responding character's assistant turns.

What changed

Keep live notes/command instructions in a separate injection when their target would be chat history. Reuse an existing tracker Context block for notes and preserve an explicit assistant prefill at the end. No new storage or caching mechanism.

Add a route-level regression using the real Anthropic adapter and a local streaming provider fixture. It exercises textual and native dice calls, same-character and alternating-character history, saved note edits, regeneration with reused memory, saved Peek Prompt, and deleting a reply before generating again. It asserts that discarded swipe text/tool results are absent and current notes are present.

The cutoff case fails before this patch and passes afterward. The original reported discarded-swipe leak and exact stale-text case were not reproduced; the affected swipe had been deleted, and the supplied chat export does not contain saved prompts. Fresh generation was subsequently confirmed to use the edited notes. The tests protect the reported request boundaries without claiming a confirmed cause for the remaining report.

Validation

Completed automated checks: pnpm check, pnpm regression:prompt, all 8 Roleplay regressions, Advanced Memory context/generation regressions, and the desktop Chromium Roleplay notes/swipes/branches browser test. Docker built and served both /api/health and / successfully. Local CodeRabbit reviewed all four changed files with zero findings.

  • 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

Manual verification notes

Manually verify on the affected chat that editing a preceding message's Personal Notes updates the next swipe's Peek Prompt, including after a dice tool call and an Advanced Memory cutoff. Verify no narration or dice result from the discarded swipe appears. Live Anthropic generation and the original deleted swipe remain unverified locally.

Docs and release impact

Added an Unreleased changelog entry. No version or installation changes.

Summary by CodeRabbit

  • Bug Fixes
    • Roleplay Personal Notes and command instructions now remain available when Advanced Memory cuts off older conversation context.
    • Regenerated replies now use the current Personal Notes and retained conversation context, rather than stale notes or discarded message content.

🔄 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/6584 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/23/2026 **Status:** ✅ Merged **Merged:** 9/23/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `codex/roleplay-regeneration-context` --- ### 📝 Commits (2) - [`aedea82`](https://github.com/Pasta-Devs/Marinara-Engine/commit/aedea821971e068b8707a5c86603d7e89d58731a) docs: track Roleplay regeneration fixes for #6583 - [`19ac250`](https://github.com/Pasta-Devs/Marinara-Engine/commit/19ac250a35d4a5a7df9aa236fbbd1a7b6f85315d) fix(roleplay): keep live instructions through memory cutoffs ### 📊 Changes **4 files changed** (+303 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `packages/server/src/services/generation/roleplay-commands.ts` (+20 -9) 📝 `scripts/regressions/roleplay-commands.regression.ts` (+16 -4) ➕ `scripts/regressions/roleplay-regeneration-context.regression.ts` (+265 -0) </details> ### 📄 Description ## Linked issue Related to #6583. Keep the issue open: this fixes a reproduced cutoff failure, while the original discarded-swipe leak still needs confirmation. ## Why this change Roleplay Personal Notes and command instructions could be appended to an old user message. Advanced Memory then removed that message at the live-context cutoff, removing the current instructions with it. This is reproducible when the retained history ends in the responding character's assistant turns. ## What changed Keep live notes/command instructions in a separate injection when their target would be chat history. Reuse an existing tracker Context block for notes and preserve an explicit assistant prefill at the end. No new storage or caching mechanism. Add a route-level regression using the real Anthropic adapter and a local streaming provider fixture. It exercises textual and native dice calls, same-character and alternating-character history, saved note edits, regeneration with reused memory, saved Peek Prompt, and deleting a reply before generating again. It asserts that discarded swipe text/tool results are absent and current notes are present. The cutoff case fails before this patch and passes afterward. The original reported discarded-swipe leak and exact stale-text case were not reproduced; the affected swipe had been deleted, and the supplied chat export does not contain saved prompts. Fresh generation was subsequently confirmed to use the edited notes. The tests protect the reported request boundaries without claiming a confirmed cause for the remaining report. ## Validation Completed automated checks: `pnpm check`, `pnpm regression:prompt`, all 8 Roleplay regressions, Advanced Memory context/generation regressions, and the desktop Chromium Roleplay notes/swipes/branches browser test. Docker built and served both `/api/health` and `/` successfully. Local CodeRabbit reviewed all four changed files with zero findings. - [ ] `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` ### Manual verification notes Manually verify on the affected chat that editing a preceding message's Personal Notes updates the next swipe's Peek Prompt, including after a dice tool call and an Advanced Memory cutoff. Verify no narration or dice result from the discarded swipe appears. Live Anthropic generation and the original deleted swipe remain unverified locally. ## Docs and release impact Added an Unreleased changelog entry. No version or installation changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Roleplay Personal Notes and command instructions now remain available when Advanced Memory cuts off older conversation context. * Regenerated replies now use the current Personal Notes and retained conversation context, rather than stale notes or discarded message content. <!-- 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-23 04:17:47 +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#7235
No description provided.