[PR #5200] [MERGED] Fix dropped Long-Term Memory recall for unmatched preset markers #6673

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5200
Author: @Promansis
Created: 8/17/2026
Status: ✅ Merged
Merged: 8/17/2026
Merged by: @Promansis

Base: staging ← Head: fix/generation-ltm-marker-fallback


📝 Commits (4)

  • 44b94bf fix: preserve unmatched long-term memory recall
  • accdb8c Merge branch 'staging' into fix/generation-ltm-marker-fallback
  • 9163b20 fix: preserve cached long-term memory fallback
  • 513a2c7 Merge remote-tracking branch 'origin/fix/generation-ltm-marker-fallback' into fix/generation-ltm-marker-fallback

📊 Changes

3 files changed (+70 additions, -8 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/routes/generate.routes.ts (+16 -8)
📝 scripts/regressions/prompt.regression.ts (+53 -0)

📄 Description

Linked issue

Closes #5199

Why this change

  • Long-Term Memory can retrieve and serialize relevant memories successfully, then silently drop them when a Roleplay custom preset owns agent placement but its runtime marker is not found in the assembled prompt.
  • The same recall works without custom preset placement because that path already uses a separate fallback injection.

What changed

  • Fall back to the existing separate Long-Term Memory injection when runtime marker replacement fails.
  • Retain the context injection and receipt so confirmed provider delivery is recorded.
  • Preserve unmatched cached Long-Term Memory during regeneration/swipe and replay it through separate injection.
  • Log the non-fatal marker miss and add regression coverage for fresh fallback, cached regeneration, and route wiring.

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 completed by the coding agent on the pushed branch at 513a2c715:

  • pnpm check
  • pnpm regression:prompt
  • git diff --check

Manual verification notes

  • Manually verify a fresh Roleplay generation whose custom Long-Term Memory marker is matched still injects at the configured preset location.
  • Manually verify a fresh Roleplay generation whose marker is unmatched logs the fallback, includes recalled memory in the provider prompt, and records a nonzero injection receipt.
  • Manually verify regeneration/swipe replays the cached unmatched recall instead of dropping it.

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.md includes an Unreleased fix entry. No user documentation or version files changed.

UI evidence (if applicable)

Not applicable; this is a server-side prompt delivery fallback.

Summary by CodeRabbit

  • Bug Fixes

    • Long-term memory is now preserved when a custom preset cannot match its configured memory marker.
    • Memory recall falls back to a separate message instead of being silently omitted.
    • Recall context, tracking, and receipts remain recorded correctly, including during regeneration.
  • Tests

    • Added regression coverage for unmatched memory injections and fallback behavior.
  • Documentation

    • Updated the changelog to document the fix.

🔄 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/5200 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 8/17/2026 **Status:** ✅ Merged **Merged:** 8/17/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `staging` ← **Head:** `fix/generation-ltm-marker-fallback` --- ### 📝 Commits (4) - [`44b94bf`](https://github.com/Pasta-Devs/Marinara-Engine/commit/44b94bfc3ffa85bac9f4b4cf1ae318746b7fcf23) fix: preserve unmatched long-term memory recall - [`accdb8c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/accdb8cc0729e67179d435bf0fd2c0af9aca3437) Merge branch 'staging' into fix/generation-ltm-marker-fallback - [`9163b20`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9163b2069d10d70bd8059630bc1c66fa3d0abe2f) fix: preserve cached long-term memory fallback - [`513a2c7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/513a2c715e3365951038a1a8b6446d7f25c754ef) Merge remote-tracking branch 'origin/fix/generation-ltm-marker-fallback' into fix/generation-ltm-marker-fallback ### 📊 Changes **3 files changed** (+70 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+16 -8) 📝 `scripts/regressions/prompt.regression.ts` (+53 -0) </details> ### 📄 Description ## Linked issue Closes #5199 ## Why this change - Long-Term Memory can retrieve and serialize relevant memories successfully, then silently drop them when a Roleplay custom preset owns agent placement but its runtime marker is not found in the assembled prompt. - The same recall works without custom preset placement because that path already uses a separate fallback injection. ## What changed - Fall back to the existing separate Long-Term Memory injection when runtime marker replacement fails. - Retain the context injection and receipt so confirmed provider delivery is recorded. - Preserve unmatched cached Long-Term Memory during regeneration/swipe and replay it through separate injection. - Log the non-fatal marker miss and add regression coverage for fresh fallback, cached regeneration, and route wiring. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` Commands completed by the coding agent on the pushed branch at `513a2c715`: - `pnpm check` - `pnpm regression:prompt` - `git diff --check` ### Manual verification notes - Manually verify a fresh Roleplay generation whose custom Long-Term Memory marker is matched still injects at the configured preset location. - Manually verify a fresh Roleplay generation whose marker is unmatched logs the fallback, includes recalled memory in the provider prompt, and records a nonzero injection receipt. - Manually verify regeneration/swipe replays the cached unmatched recall instead of dropping it. ## Docs and release impact - [ ] No docs changes needed - [x] 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.md` includes an Unreleased fix entry. No user documentation or version files changed. ## UI evidence (if applicable) Not applicable; this is a server-side prompt delivery fallback. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Long-term memory is now preserved when a custom preset cannot match its configured memory marker. - Memory recall falls back to a separate message instead of being silently omitted. - Recall context, tracking, and receipts remain recorded correctly, including during regeneration. - **Tests** - Added regression coverage for unmatched memory injections and fallback behavior. - **Documentation** - Updated the changelog to document the fix. <!-- 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:12:37 +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#6673
No description provided.