[PR #6103] [MERGED] feat: automate Roleplay context and memory management #7063

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

📋 Pull Request Information

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

Base: staging ← Head: feat/advanced-roleplay-memory


📝 Commits (6)

  • b1c6251 docs: record advanced Roleplay memory implementation
  • 71a207d feat: automate Roleplay context and memory management
  • 2954c83 fix: protect advanced memory metadata and downgrade storage
  • 96cce00 fix: harden advanced memory setup and data handling
  • 3a77d9b fix: normalize advanced memory reindex validation errors
  • 66d1b1f fix: preserve disabled and unsupported imported memories

📊 Changes

50 files changed (+7490 additions, -123 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/FAQ.md (+2 -0)
📝 docs/agents/memory.md (+47 -2)
➕ e2e/advanced-memory.e2e.ts (+401 -0)
➕ packages/client/public/sprites/mari/generated/professor-mari-memory-wheel.png (+0 -0)
➕ packages/client/public/sprites/mari/generated/professor-mari-memory-wheel.prompt.md (+7 -0)
➕ packages/client/src/components/chat/AdvancedMemoryInspector.tsx (+278 -0)
➕ packages/client/src/components/chat/AdvancedMemoryProgress.tsx (+95 -0)
➕ packages/client/src/components/chat/AdvancedMemorySettings.tsx (+387 -0)
📝 packages/client/src/components/chat/ChatArea.tsx (+11 -0)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+46 -6)
➕ packages/client/src/components/chat/advanced-memory.css (+42 -0)
📝 packages/client/src/components/presets/PresetEditor.tsx (+23 -7)
📝 packages/client/src/features/chat-settings/ChatSettingsSection.tsx (+11 -2)
➕ packages/client/src/hooks/use-advanced-memory.ts (+99 -0)
📝 packages/client/src/hooks/use-generate.ts (+34 -0)
📝 packages/client/src/localization/locales/en.json (+104 -0)
📝 packages/server/src/db/file-backed-store.ts (+5 -0)
➕ packages/server/src/db/schema/advanced-memory.ts (+30 -0)
📝 packages/server/src/db/schema/index.ts (+1 -0)

...and 30 more files

📄 Description

Linked issue

Closes #6102

Why this change

Long Roleplay chats require users to maintain summaries and cut history by hand. Advanced Memory Recall (Alpha) manages that work within a chosen context budget while retaining the original transcript and respecting each character's knowledge.

What changed

  • Added an opt-in coordinator using existing summary connections/prompts, embeddings, token estimates and file storage. Live history grows while it fits; completed scenes move into bounded continuity, and an oversized unfinished scene receives a temporary prefix summary without being closed.
  • Retrieve relevant scenes and exact neighboring dialogue, with source IDs, audience filtering, cached vectors and a per-generation receipt. Edited, hidden, deleted or swiped messages invalidate affected derivatives; manual summary corrections remain authoritative and preserved.
  • Resume initialization from durable classifier and paid summary-batch checkpoints. Confirm ambiguous Individual character knowledge before any helper or generation agent receives history; narrator access still respects explicit hiding and manual resets.
  • Reuse Chat Summary plus three preset markers for current-scene summaries, recalled scenes and recalled messages. All follow XML/Markdown/None, include explanatory text, and fall back once when placement is missing. Previews are read-only; full requests and tool follow-ups are checked before sending, without silent history trimming.
  • Keep settings, knowledge review, progress, source inspection, editing and import/export inside the existing Chat Settings drawer. Includes a generated pixel Professor Mari hamster-wheel animation and a reduced-motion still.
  • Preserve supported memory records through branches, transcript imports and native backups. Advanced mode owns automatic recall/summary scheduling while enabled; turning it off restores the existing behavior. Conversation and Game do not enable it.

Validation

Completed local automated checks:

  • pnpm install --frozen-lockfile
  • pnpm check (includes localization, formatting, TypeScript, ESLint, E2E types and production builds)
  • pnpm regression:prompt (prompt assembly, attachments and context fitting)
  • TMPDIR=/private/tmp pnpm regression:launcher-update (including offline conversion of the new memory table)
  • Focused Node regressions: advanced-memory-core, advanced-memory-context, advanced-memory-generation, chat-branch-lineage, existing memory-recall-revectorize, and capability-gm-verbs metadata ownership.

The isolated fixtures cover 800 messages, cancellation/resume without repeating a completed summary batch, private source gaps, edited/disabled summaries, exact promise/correction recall and unrelated-topic abstention, historical regeneration, impersonation, all preview entry points, preset scoping, macro edits, hidden tracker fields, fresh-ID imports and native profile export/restore. Added fault-injected branch rollback, joined-caller cancellation, bounded archive reads, reordered import dependencies, macro-resolved JSONL source validation, dropped-recall receipts, pre-run preview errors, unsupported import exclusion, and preservation of disabled corrections during initialization. Providers are deterministic local mocks; these checks do not establish recall quality or cost on real models.

Focused pnpm smoke:ui e2e/advanced-memory.e2e.ts --workers=1 passed in desktop Chromium (2/2), mobile Chromium and mobile WebKit (4/4). Verified setup/knowledge confirmation, keyboard focus, cancel/close/reopen/resume, editing, source inspection, disabling recall, Standard-mode restoration, light/dark Chroma colors and reduced motion. The review follow-up also covers 104-message knowledge paging with preserved off-page selections, explicit section opening over remembered collapse, and omitted-versus-false blocking errors.

  • 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 initialization and sustained play in a long Roleplay chat with your selected summary, helper and embedding providers.
  • Manually verify Individual character knowledge, narrator selection, corrected summaries and your custom preset placement.
  • Manually verify cancel/resume and drawer interaction on a physical phone. Automated browser checks do not establish real-device performance.

Docs and release impact

Updated CHANGELOG.md, docs/agents/memory.md and docs/FAQ.md. Translation follow-up: #6106. No version bump or new dependency.

UI evidence (if applicable)

Actual synthetic-chat screenshots: desktop and mobile browser evidence. Progress captures show initialization; inspector captures show the completed scene after a saved correction and exclusion from recall. No private chat data appears in the fixtures. Sprite source and generation prompt are included together under packages/client/public/sprites/mari/generated/professor-mari-memory-wheel.*.

Rendered Professor Mari wheel during initialization (synthetic chat, light Chroma theme):

Professor Mari running in a hamster wheel inside the Chat Settings drawer

Summary by CodeRabbit

  • New Features
    • Added opt-in Advanced Memory Recall (Alpha) for Roleplay chats.
    • Provides scene summaries, bounded continuity, selective historical recall, and character-aware context.
    • Added setup, progress, cancellation, resumption, editing, reindexing, import/export, and source inspection controls.
    • Added configurable memory placement markers in preset editing.
  • Documentation
    • Updated the FAQ and memory documentation with setup instructions, behavior details, limits, and recovery guidance.
  • Bug Fixes
    • Added clearer handling for blocking and background memory-processing errors.

🔄 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/6103 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/12/2026 **Status:** ✅ Merged **Merged:** 9/12/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/advanced-roleplay-memory` --- ### 📝 Commits (6) - [`b1c6251`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b1c62519c847a6c4e1024ec15f1fe63745ca17c2) docs: record advanced Roleplay memory implementation - [`71a207d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/71a207d4d956ca77b4300d5187cd55a4a36ecf23) feat: automate Roleplay context and memory management - [`2954c83`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2954c83bcf407beabc6569b6aa9ca0a36339e2e7) fix: protect advanced memory metadata and downgrade storage - [`96cce00`](https://github.com/Pasta-Devs/Marinara-Engine/commit/96cce00cacbb64c40256e0cf7947951ab50e6079) fix: harden advanced memory setup and data handling - [`3a77d9b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3a77d9b64e2aef697b54614b5b1a343052b89925) fix: normalize advanced memory reindex validation errors - [`66d1b1f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/66d1b1fa474ced8f8eda9876760b6bd119effbdb) fix: preserve disabled and unsupported imported memories ### 📊 Changes **50 files changed** (+7490 additions, -123 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/FAQ.md` (+2 -0) 📝 `docs/agents/memory.md` (+47 -2) ➕ `e2e/advanced-memory.e2e.ts` (+401 -0) ➕ `packages/client/public/sprites/mari/generated/professor-mari-memory-wheel.png` (+0 -0) ➕ `packages/client/public/sprites/mari/generated/professor-mari-memory-wheel.prompt.md` (+7 -0) ➕ `packages/client/src/components/chat/AdvancedMemoryInspector.tsx` (+278 -0) ➕ `packages/client/src/components/chat/AdvancedMemoryProgress.tsx` (+95 -0) ➕ `packages/client/src/components/chat/AdvancedMemorySettings.tsx` (+387 -0) 📝 `packages/client/src/components/chat/ChatArea.tsx` (+11 -0) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+46 -6) ➕ `packages/client/src/components/chat/advanced-memory.css` (+42 -0) 📝 `packages/client/src/components/presets/PresetEditor.tsx` (+23 -7) 📝 `packages/client/src/features/chat-settings/ChatSettingsSection.tsx` (+11 -2) ➕ `packages/client/src/hooks/use-advanced-memory.ts` (+99 -0) 📝 `packages/client/src/hooks/use-generate.ts` (+34 -0) 📝 `packages/client/src/localization/locales/en.json` (+104 -0) 📝 `packages/server/src/db/file-backed-store.ts` (+5 -0) ➕ `packages/server/src/db/schema/advanced-memory.ts` (+30 -0) 📝 `packages/server/src/db/schema/index.ts` (+1 -0) _...and 30 more files_ </details> ### 📄 Description ## Linked issue Closes #6102 ## Why this change Long Roleplay chats require users to maintain summaries and cut history by hand. Advanced Memory Recall (Alpha) manages that work within a chosen context budget while retaining the original transcript and respecting each character's knowledge. ## What changed - Added an opt-in coordinator using existing summary connections/prompts, embeddings, token estimates and file storage. Live history grows while it fits; completed scenes move into bounded continuity, and an oversized unfinished scene receives a temporary prefix summary without being closed. - Retrieve relevant scenes and exact neighboring dialogue, with source IDs, audience filtering, cached vectors and a per-generation receipt. Edited, hidden, deleted or swiped messages invalidate affected derivatives; manual summary corrections remain authoritative and preserved. - Resume initialization from durable classifier and paid summary-batch checkpoints. Confirm ambiguous Individual character knowledge before any helper or generation agent receives history; narrator access still respects explicit hiding and manual resets. - Reuse Chat Summary plus three preset markers for current-scene summaries, recalled scenes and recalled messages. All follow XML/Markdown/None, include explanatory text, and fall back once when placement is missing. Previews are read-only; full requests and tool follow-ups are checked before sending, without silent history trimming. - Keep settings, knowledge review, progress, source inspection, editing and import/export inside the existing Chat Settings drawer. Includes a generated pixel Professor Mari hamster-wheel animation and a reduced-motion still. - Preserve supported memory records through branches, transcript imports and native backups. Advanced mode owns automatic recall/summary scheduling while enabled; turning it off restores the existing behavior. Conversation and Game do not enable it. ## Validation Completed local automated checks: - `pnpm install --frozen-lockfile` - `pnpm check` (includes localization, formatting, TypeScript, ESLint, E2E types and production builds) - `pnpm regression:prompt` (prompt assembly, attachments and context fitting) - `TMPDIR=/private/tmp pnpm regression:launcher-update` (including offline conversion of the new memory table) - Focused Node regressions: `advanced-memory-core`, `advanced-memory-context`, `advanced-memory-generation`, `chat-branch-lineage`, existing `memory-recall-revectorize`, and `capability-gm-verbs` metadata ownership. The isolated fixtures cover 800 messages, cancellation/resume without repeating a completed summary batch, private source gaps, edited/disabled summaries, exact promise/correction recall and unrelated-topic abstention, historical regeneration, impersonation, all preview entry points, preset scoping, macro edits, hidden tracker fields, fresh-ID imports and native profile export/restore. Added fault-injected branch rollback, joined-caller cancellation, bounded archive reads, reordered import dependencies, macro-resolved JSONL source validation, dropped-recall receipts, pre-run preview errors, unsupported import exclusion, and preservation of disabled corrections during initialization. Providers are deterministic local mocks; these checks do not establish recall quality or cost on real models. Focused `pnpm smoke:ui e2e/advanced-memory.e2e.ts --workers=1` passed in desktop Chromium (2/2), mobile Chromium and mobile WebKit (4/4). Verified setup/knowledge confirmation, keyboard focus, cancel/close/reopen/resume, editing, source inspection, disabling recall, Standard-mode restoration, light/dark Chroma colors and reduced motion. The review follow-up also covers 104-message knowledge paging with preserved off-page selections, explicit section opening over remembered collapse, and omitted-versus-false blocking errors. - [ ] `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 initialization and sustained play in a long Roleplay chat with your selected summary, helper and embedding providers. - Manually verify Individual character knowledge, narrator selection, corrected summaries and your custom preset placement. - Manually verify cancel/resume and drawer interaction on a physical phone. Automated browser checks do not establish real-device performance. ## Docs and release impact Updated `CHANGELOG.md`, `docs/agents/memory.md` and `docs/FAQ.md`. Translation follow-up: #6106. No version bump or new dependency. ## UI evidence (if applicable) Actual synthetic-chat screenshots: [desktop and mobile browser evidence](https://gist.github.com/SpicyMarinara/c5001344e4076c348688872580318d9b). Progress captures show initialization; inspector captures show the completed scene after a saved correction and exclusion from recall. No private chat data appears in the fixtures. Sprite source and generation prompt are included together under `packages/client/public/sprites/mari/generated/professor-mari-memory-wheel.*`. Rendered Professor Mari wheel during initialization (synthetic chat, light Chroma theme): ![Professor Mari running in a hamster wheel inside the Chat Settings drawer](https://gist.githubusercontent.com/SpicyMarinara/c5001344e4076c348688872580318d9b/raw/1bcbc4fcfa830eb26f46dfe718a6d6127d45b221/desktop-chromium-advanced-memory-progress-light.png) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added opt-in **Advanced Memory Recall (Alpha)** for Roleplay chats. * Provides scene summaries, bounded continuity, selective historical recall, and character-aware context. * Added setup, progress, cancellation, resumption, editing, reindexing, import/export, and source inspection controls. * Added configurable memory placement markers in preset editing. * **Documentation** * Updated the FAQ and memory documentation with setup instructions, behavior details, limits, and recovery guidance. * **Bug Fixes** * Added clearer handling for blocking and background memory-processing errors. <!-- 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:16:12 +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#7063
No description provided.