[PR #6472] [MERGED] fix: bound Advanced Memory recall for main Roleplay replies #7193

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

📋 Pull Request Information

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

Base: staging ← Head: codex/sept20-memory-recall-runtime


📝 Commits (2)

  • d067532 chore: start focused advanced memory recall fix (#6471)
  • 8416a46 fix: bound main Roleplay recall and defer scene archiving

📊 Changes

20 files changed (+726 additions, -528 deletions)

View changed files

📝 CHANGELOG.md (+4 -1)
📝 docs/agents/memory.md (+12 -9)
📝 e2e/advanced-memory.e2e.ts (+63 -0)
📝 packages/client/src/components/chat/AdvancedMemorySettings.tsx (+15 -0)
📝 packages/client/src/components/chat/ChatRoleplaySurface.tsx (+5 -3)
📝 packages/client/src/components/chat/RoleplayHUD.tsx (+13 -1)
📝 packages/client/src/components/chat/RoleplayHUDActionsMenu.tsx (+23 -2)
📝 packages/client/src/localization/locales/en.json (+5 -2)
📝 packages/server/src/routes/generate.routes.ts (+8 -93)
📝 packages/server/src/routes/generate/dry-run-route.ts (+7 -2)
📝 packages/server/src/services/advanced-memory.ts (+141 -106)
📝 packages/server/src/services/prompt/advanced-memory-prompt.ts (+3 -3)
📝 packages/shared/src/types/advanced-memory.ts (+1 -0)
📝 scripts/regressions/advanced-memory-context.regression.ts (+2 -0)
📝 scripts/regressions/advanced-memory-core.regression.ts (+10 -12)
📝 scripts/regressions/advanced-memory-generation.regression.ts (+13 -29)
📝 scripts/regressions/advanced-memory-history-start.regression.ts (+2 -2)
📝 scripts/regressions/advanced-memory-post-generation.regression.ts (+228 -263)
➕ scripts/regressions/advanced-memory-recall.regression.ts (+170 -0)
📝 scripts/regressions/advanced-memory-summary.regression.ts (+1 -0)

📄 Description

Linked issue

Closes #6471

Why this change

Advanced Memory could prepare and index history before a main reply, making generation appear stalled, and select repeated chunks without a meaningful scene limit. Recalled content needs to identify where the current turn begins and stay out of agent requests.

What changed

  • Recall up to 3 relevant scenes by default, configurable in existing memory settings. Pair each recap with one bounded excerpt under a grouped message range, and state the live range and last user-message number.
  • Reuse the prepared archive for normal recall. Bound optional query embedding to 1.5 seconds with a text-matching fallback.
  • Run recall only for main Roleplay generation. Agent requests, manual agent reruns and auxiliary generations receive no returned recall blocks; prompt inspection remains read-only.
  • Check for scene endings after the saved main reply at the configured standalone interval. Prepare closed scenes only when a scene ending is detected, independently of ordinary agents.
  • Show background progress, errors and recovery as Advanced Recall in the top-left Agents menu, including with agents disabled. Reuse the existing progress controls and retain saved memories.

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:

  • All 7 Advanced Memory regression suites pass, including full 1,000-message history, visibility, resume, scene limits, paired excerpts, agent isolation and post-generation cadence.
  • The scene-limit regression fails against the old service (4 scenes returned with a limit of 3) and passes with this change.
  • Real HTTP streaming handshake passes through both OpenAI-compatible Chat Completions and OpenAI + GPT-6-Astra Responses routing: the client receives a token before the local mock provider finishes. No paid provider call was made; this verifies routing and streaming, not live OpenAI latency.
  • Initial local CodeRabbit review completed. Its valid auxiliary-generation visibility finding is fixed and covered. Kept the deliberate 1.5-second optional-embedding deadline and an independent 4-second regression ceiling instead of increasing latency or coupling the performance assertion to implementation.
  • Full pnpm check passes, including lint, localization, TypeScript and production builds. The follow-up local CodeRabbit review completed with zero findings. The production container built and returned HTTP 200 from /api/health.
  • The broader prompt suite exposed an obsolete assertion for the old recall introduction; #6473 corrects it and all three prompt suites pass locally.
  • Browser checks could not launch because the required Playwright binaries are absent locally. No successful UI run is claimed.

Manual verification notes

Published now at the maintainer's request so they can merge and test; subsequent valid CodeRabbit findings will be handled in a separate PR. Human checkboxes remain unchecked.

Manually verify on desktop and iPhone: the scene limit saves, a main reply streams, agents receive no recalled blocks, and a detected scene ending appears as Advanced Recall in the Agents menu. Verify mobile/light/dark layout and error/resume controls. Existing saved summaries should be reusable without resetting memory.

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
  • Version/release files updated (only if this PR includes a version bump)

Updated the Unreleased changelog and docs/agents/memory.md. Translation follow-up: #6467. No version bump or archive reset.

UI evidence (if applicable)

Local browser evidence is unavailable because the required Playwright binaries are absent. This PR was published early at the maintainer's explicit request.


🔄 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/6472 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/20/2026 **Status:** ✅ Merged **Merged:** 9/20/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `codex/sept20-memory-recall-runtime` --- ### 📝 Commits (2) - [`d067532`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d067532d3a39608c0027af052bb404f5ce95af2e) chore: start focused advanced memory recall fix (#6471) - [`8416a46`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8416a460313bff04859974ff6abf4088ea091124) fix: bound main Roleplay recall and defer scene archiving ### 📊 Changes **20 files changed** (+726 additions, -528 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+4 -1) 📝 `docs/agents/memory.md` (+12 -9) 📝 `e2e/advanced-memory.e2e.ts` (+63 -0) 📝 `packages/client/src/components/chat/AdvancedMemorySettings.tsx` (+15 -0) 📝 `packages/client/src/components/chat/ChatRoleplaySurface.tsx` (+5 -3) 📝 `packages/client/src/components/chat/RoleplayHUD.tsx` (+13 -1) 📝 `packages/client/src/components/chat/RoleplayHUDActionsMenu.tsx` (+23 -2) 📝 `packages/client/src/localization/locales/en.json` (+5 -2) 📝 `packages/server/src/routes/generate.routes.ts` (+8 -93) 📝 `packages/server/src/routes/generate/dry-run-route.ts` (+7 -2) 📝 `packages/server/src/services/advanced-memory.ts` (+141 -106) 📝 `packages/server/src/services/prompt/advanced-memory-prompt.ts` (+3 -3) 📝 `packages/shared/src/types/advanced-memory.ts` (+1 -0) 📝 `scripts/regressions/advanced-memory-context.regression.ts` (+2 -0) 📝 `scripts/regressions/advanced-memory-core.regression.ts` (+10 -12) 📝 `scripts/regressions/advanced-memory-generation.regression.ts` (+13 -29) 📝 `scripts/regressions/advanced-memory-history-start.regression.ts` (+2 -2) 📝 `scripts/regressions/advanced-memory-post-generation.regression.ts` (+228 -263) ➕ `scripts/regressions/advanced-memory-recall.regression.ts` (+170 -0) 📝 `scripts/regressions/advanced-memory-summary.regression.ts` (+1 -0) </details> ### 📄 Description ## Linked issue Closes #6471 ## Why this change Advanced Memory could prepare and index history before a main reply, making generation appear stalled, and select repeated chunks without a meaningful scene limit. Recalled content needs to identify where the current turn begins and stay out of agent requests. ## What changed - Recall up to 3 relevant scenes by default, configurable in existing memory settings. Pair each recap with one bounded excerpt under a grouped message range, and state the live range and last user-message number. - Reuse the prepared archive for normal recall. Bound optional query embedding to 1.5 seconds with a text-matching fallback. - Run recall only for main Roleplay generation. Agent requests, manual agent reruns and auxiliary generations receive no returned recall blocks; prompt inspection remains read-only. - Check for scene endings after the saved main reply at the configured standalone interval. Prepare closed scenes only when a scene ending is detected, independently of ordinary agents. - Show background progress, errors and recovery as **Advanced Recall** in the top-left Agents menu, including with agents disabled. Reuse the existing progress controls and retain saved memories. ## 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: - All 7 Advanced Memory regression suites pass, including full 1,000-message history, visibility, resume, scene limits, paired excerpts, agent isolation and post-generation cadence. - The scene-limit regression fails against the old service (4 scenes returned with a limit of 3) and passes with this change. - Real HTTP streaming handshake passes through both OpenAI-compatible Chat Completions and **OpenAI + GPT-6-Astra Responses** routing: the client receives a token before the local mock provider finishes. No paid provider call was made; this verifies routing and streaming, not live OpenAI latency. - Initial local CodeRabbit review completed. Its valid auxiliary-generation visibility finding is fixed and covered. Kept the deliberate 1.5-second optional-embedding deadline and an independent 4-second regression ceiling instead of increasing latency or coupling the performance assertion to implementation. - Full `pnpm check` passes, including lint, localization, TypeScript and production builds. The follow-up local CodeRabbit review completed with zero findings. The production container built and returned HTTP 200 from `/api/health`. - The broader prompt suite exposed an obsolete assertion for the old recall introduction; #6473 corrects it and all three prompt suites pass locally. - Browser checks could not launch because the required Playwright binaries are absent locally. No successful UI run is claimed. ### Manual verification notes Published now at the maintainer's request so they can merge and test; subsequent valid CodeRabbit findings will be handled in a separate PR. Human checkboxes remain unchecked. Manually verify on desktop and iPhone: the scene limit saves, a main reply streams, agents receive no recalled blocks, and a detected scene ending appears as Advanced Recall in the Agents menu. Verify mobile/light/dark layout and error/resume controls. Existing saved summaries should be reusable without resetting memory. ## 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 - [ ] Version/release files updated (only if this PR includes a version bump) Updated the Unreleased changelog and `docs/agents/memory.md`. Translation follow-up: #6467. No version bump or archive reset. ## UI evidence (if applicable) Local browser evidence is unavailable because the required Playwright binaries are absent. This PR was published early at the maintainer's explicit request. --- <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:23 +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#7193
No description provided.