[GH-ISSUE #2862] [Feature]: Memory tool: Read-behind feature + When branching, memory chunk of missing messages should disappear + ability to modify memory chunks on the fly #1450

Closed
opened 2026-10-21 05:35:26 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Navgner on GitHub (Jun 24, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2862

Originally assigned to: @SpicyMarinara on GitHub.

What problem does this solve?

  1. Read-Behind / Lookback Memory:
    There was supposed to be a read-behind feature introduced a few updates ago, but I don't recall ever seeing it implemented. It is an essential tool to avoid wasting tokens on repetitive context. For example, if I have my active context limited to 30 messages, I want the memory tool to only process messages that fall outside of this limit. Perhaps this is already implemented and tied directly to the message limit?

  2. Memory Contamination Across Chat Branches:
    Sometimes I go far back in the chat history and use the branching feature to explore alternative paths. However, the memory chunks carry over from one branch to another, causing memory contamination.

Proposed solution

I have two feature requests to address these issues:

  1. Implement / Restore the Read-Behind Feature: Ensure the memory tool starts creating chunks of memory after the slid out of the active message limit.
  2. Branch Detection or Manual Editing: To prevent memory contamination when switching branches, we could either:
    • Implement message ID detection (Highly Recommended): If a message ID disappears/changes due to branching, the corresponding memory chunks should automatically be removed for the new chat path. This is the ideal solution to save users from unnecessary headaches.
    • Add manual chunk editing: Add the ability to manually edit or delete memory chunks that are no longer relevant to the current branch.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Navgner on GitHub (Jun 24, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2862 Originally assigned to: @SpicyMarinara on GitHub. ## What problem does this solve? 1. **Read-Behind / Lookback Memory:** There was supposed to be a read-behind feature introduced a few updates ago, but I don't recall ever seeing it implemented. It is an essential tool to avoid wasting tokens on repetitive context. For example, if I have my active context limited to 30 messages, I want the memory tool to only process messages that fall outside of this limit. Perhaps this is already implemented and tied directly to the message limit? 2. **Memory Contamination Across Chat Branches:** Sometimes I go far back in the chat history and use the branching feature to explore alternative paths. However, the memory chunks carry over from one branch to another, causing memory contamination. ## Proposed solution I have two feature requests to address these issues: 1. **Implement / Restore the Read-Behind Feature:** Ensure the memory tool starts creating chunks of memory after the slid out of the active message limit. 2. **Branch Detection or Manual Editing:** To prevent memory contamination when switching branches, we could either: * **Implement message ID detection (Highly Recommended):** If a message ID disappears/changes due to branching, the corresponding memory chunks should automatically be removed for the new chat path. This is the ideal solution to save users from unnecessary headaches. * **Add manual chunk editing:** Add the ability to manually edit or delete memory chunks that are no longer relevant to the current branch. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:35:26 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Jun 27, 2026):

  1. I think we already have this in place, but it might have gotten messed up during the refactor. I'll look into it.
  2. Makes sense, that's how it's supposed to work.
<!-- gh-comment-id:4816330705 --> @SpicyMarinara commented on GitHub (Jun 27, 2026): 1. I think we already have this in place, but it might have gotten messed up during the refactor. I'll look into it. 2. Makes sense, that's how it's supposed to work.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 27, 2026):

Fixed locally.

  • Memory chunking now treats the chat message limit as read-behind: background chunking and manual memory refresh skip the active prompt tail when contextMessageLimit is set.
  • Native memory chunks that overlap the active tail are pruned so recall does not duplicate still-visible context.
  • Native memory chunks are now validated against the current message log and invalidated from the first stale span, so branch/deletion/regeneration changes cannot keep old chunks attached to the new path.
  • The existing memory modal already supports deleting individual chunks; this fix makes the automatic cleanup path handle the branch-contamination case.
<!-- gh-comment-id:4816570517 --> @SpicyMarinara commented on GitHub (Jun 27, 2026): Fixed locally. - Memory chunking now treats the chat message limit as read-behind: background chunking and manual memory refresh skip the active prompt tail when contextMessageLimit is set. - Native memory chunks that overlap the active tail are pruned so recall does not duplicate still-visible context. - Native memory chunks are now validated against the current message log and invalidated from the first stale span, so branch/deletion/regeneration changes cannot keep old chunks attached to the new path. - The existing memory modal already supports deleting individual chunks; this fix makes the automatic cleanup path handle the branch-contamination case.
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#1450
No description provided.