[GH-ISSUE #5199] [Issue]: Roleplay Long-Term Memory recall is silently dropped when a custom preset marker is unmatched #2875

Closed
opened 2026-10-21 05:57:24 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (Aug 17, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5199

Originally assigned to: @Promansis on GitHub.

Summary

Long-Term Memory retrieves memories successfully in Roleplay chats using custom prompt presets, but the recalled text can be silently dropped before the provider request when the preset-owned runtime marker is not matched.

Expected behavior

When Long-Term Memory selects memories, the selected text should be delivered into the final model prompt, either at the configured custom-preset marker or through the normal fallback injection path. The injection receipt should record the confirmed delivery.

Actual behavior

On Engine 2.4.1, a Roleplay chat with a custom XML prompt preset selected 20 memories and serialized approximately 2.7-2.8K tokens, confirmed by recall_explanation debug events. The final prompt contained no memory text and no runtime marker, and GET /api/long-term-memory/last-injection/<chatId> returned {"memoryCount":0,"tokenCount":0,"memories":[]}. No warning or error was emitted.

Steps to reproduce

  1. Use Marinara Engine 2.4.1 with Long-Term Memory package v1.2.6.
  2. Create a Roleplay chat with a custom XML prompt preset containing an enabled section created through Agent Sections -> Long-Term Memory (Agent). The section uses {{agent::long-term-memory}} and {"type":"agent_data","agentType":"long-term-memory"}.
  3. Enable Long-Term Memory, use a vault with relevant memories, and send a fresh message using keywords that select memories.
  4. Check the debug recall_explanation event, the assembled prompt, and GET /api/long-term-memory/last-injection/<chatId>.

Environment

  • Marinara Engine version: 2.4.1, commit c0ce4d88
  • Long-Term Memory package: v1.2.6
  • Install type: unknown
  • OS + version: unknown
  • Browser or app shell: unknown

Logs, screenshots, or video

The associated debug log records embeddingsAvailable: true, 20 selected memories, approximately 2.7-2.8K serialized tokens, and lower-rank overflow for rejected candidates. The reporter also captured an assembled-prompt view showing no memory section, runtime token, macro text, or recalled content.

Additional context

Conversation mode with the same vault works, and a valid custom marker path passes the current prompt regression. The failure is in the Engine generation handoff: custom presets set presetOwnsAgentPlacement = true; if replaceRuntimeAgentSection returns false, the current code drops the recall and receipt instead of using appendSeparateAgentInjection.

Requested fix:

  • Log when a preset-owned Long-Term Memory marker cannot be replaced.
  • Append the recalled text through the normal fallback path and retain the injection receipt.
  • Add a regression for a fresh Roleplay custom marker and an unmatched marker.

Temporary workaround: use Roleplay without a custom prompt preset, or use Conversation mode.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Aug 17, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5199 Originally assigned to: @Promansis on GitHub. ## Summary Long-Term Memory retrieves memories successfully in Roleplay chats using custom prompt presets, but the recalled text can be silently dropped before the provider request when the preset-owned runtime marker is not matched. ## Expected behavior When Long-Term Memory selects memories, the selected text should be delivered into the final model prompt, either at the configured custom-preset marker or through the normal fallback injection path. The injection receipt should record the confirmed delivery. ## Actual behavior On Engine 2.4.1, a Roleplay chat with a custom XML prompt preset selected 20 memories and serialized approximately 2.7-2.8K tokens, confirmed by `recall_explanation` debug events. The final prompt contained no memory text and no runtime marker, and `GET /api/long-term-memory/last-injection/<chatId>` returned `{"memoryCount":0,"tokenCount":0,"memories":[]}`. No warning or error was emitted. ## Steps to reproduce 1. Use Marinara Engine 2.4.1 with Long-Term Memory package v1.2.6. 2. Create a Roleplay chat with a custom XML prompt preset containing an enabled section created through **Agent Sections -> Long-Term Memory (Agent)**. The section uses `{{agent::long-term-memory}}` and `{"type":"agent_data","agentType":"long-term-memory"}`. 3. Enable Long-Term Memory, use a vault with relevant memories, and send a fresh message using keywords that select memories. 4. Check the debug `recall_explanation` event, the assembled prompt, and `GET /api/long-term-memory/last-injection/<chatId>`. ## Environment - Marinara Engine version: 2.4.1, commit `c0ce4d88` - Long-Term Memory package: v1.2.6 - Install type: unknown - OS + version: unknown - Browser or app shell: unknown ## Logs, screenshots, or video The associated debug log records `embeddingsAvailable: true`, 20 selected memories, approximately 2.7-2.8K serialized tokens, and lower-rank overflow for rejected candidates. The reporter also captured an assembled-prompt view showing no memory section, runtime token, macro text, or recalled content. ## Additional context Conversation mode with the same vault works, and a valid custom marker path passes the current prompt regression. The failure is in the Engine generation handoff: custom presets set `presetOwnsAgentPlacement = true`; if `replaceRuntimeAgentSection` returns false, the current code drops the recall and receipt instead of using `appendSeparateAgentInjection`. Requested fix: - Log when a preset-owned Long-Term Memory marker cannot be replaced. - Append the recalled text through the normal fallback path and retain the injection receipt. - Add a regression for a fresh Roleplay custom marker and an unmatched marker. Temporary workaround: use Roleplay without a custom prompt preset, or use Conversation mode. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:57:24 +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#2875
No description provided.