mirror of
https://github.com/Pasta-Devs/Marinara-Agents.git
synced 2026-12-03 18:55:07 +07:00
[GH-ISSUE #1433] [Issue]: Long-Term Memory: a new branch doesn't recall memories from the history it shares with the original chat #729
Labels
No labels
agent: chess
agent: conversation-calls
agent: eightball
agent: haptic
agent: hierarchical-maps
agent: hierarchical-maps
agent: illustrator
agent: poker
agent: rock-paper-scissors
agent: tic-tac-toe
agent: uno
artifacts
bug
bugfix
build
catalog
ci
client
dependencies
docs
documentation
enhancement
feature
fixed-in-staging
in-pr
normal-scope
packages
pull-request
qol
regression
roadmap
scope-risk
server
soup
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Agents#729
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Promansis on GitHub (Oct 17, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1433
Originally assigned to: @Promansis on GitHub.
Summary
Engine describes a branch as "a copy of a chat that shares history up to a chosen point" (
docs/chats/branches.md). When it creates a branch, Engine copies everything tied to the copied messages. That includes every rolling summary whose messages all come before the branch point. Summaries that cross the branch point are left behind.Long-Term Memory doesn't follow this. A memory is saved to the single chat record (branch) it came from, and recall only matches that record. A new branch therefore recalls none of the memories made from its shared history, even though Engine copied the summaries those memories came from.
This issue makes a branch also recall memories that were built entirely from summaries it shares with the original. It changes recall only. Stored availability, saving and editing stay as they are, so memories that users have already assigned to a branch keep working without any change.
It should land before #1420. #1420 removes the per-branch tab from the place pickers, and the compatibility rules below apply to it too.
Affected package
long-term-memory1.4.43 (upstream/stagingdce3590bb).S=packages/long-term-memory/src/engine/packages/server/src/services/long-term-memoryS/chat-scope.ts:68resolveChatLtmWriteScopesaves tochatOnlyLtmScope(chat.id), which is one branch.S/generation-injection.ts:134builds the recall scope from the current chat (resolveChatLtmScope), which gives its own chat id and its conversation id.S/retrieval.ts:103-121filters chunks withmatchesLtmScope. A memory saved to branch A (chatIds: [A], no group id) never matches branch B.{ kind: "chat_summary", sourceId: <chat id>, entryId: <summary entry id> }(S/interop.ts:520-530).extracted_fromlink to it (S/draft-projector.ts:463).S/interop.ts:332already relies on branches sharing summary entry ids, to remove duplicates in the Sources preview.2039583ca, read only):packages/server/src/routes/chats.routes.ts:4845keeps only the summary entries whose messages were all copied.:4970copies those entries with the sameid.Expected behavior
In branch B, recall includes a memory saved to another branch of the same chat when every chat summary that memory came from is also one of B's summaries. This is the same test Engine uses for summaries.
Actual behavior
Branch B recalls nothing that was saved to the chat it came from, unless that memory was set to the whole chat ("All branches").
Steps to reproduce
This comes from reading the code; it hasn't been run live.
Minimal fix
New helper. Add a pure helper next to the scope helpers in
S/chat-scope.ts. It takes:summariesfromS/interop.ts:194);groupId);It returns the ids of memories that meet all of these:
extracted_fromlink;extracted_fromlink points to a chat-summary source note from this conversation, and that note'sentryIdis one of the current chat's summary entry ids.A link to a missing source note fails the test.
Retrieval.
S/retrieval.tsgets an optionalinheritedNoteIds?: ReadonlySet<string>input. The chunk filter becomesmatchesLtmScope(...) || inheritedNoteIds?.has(chunk.noteId). The status, mode, resolved andexclusiveCharacterIdsfilters still apply as before.Recall entry.
S/generation-injection.tsbuilds the set only when the chat has agroupIdand at least one summary entry, then passes it toretrieveLongTermMemory.getPackagePersistence().listChats(), filtered bygroupId.storage.listNotes(), which uses the cached vault snapshot.No Engine change is needed.
Compatibility: memories already assigned to branches
Many memories are saved to one branch (
chatIds: [<branch chat id>]). That is the default for everything imported from a chat, and users have also assigned some by hand with the availability editor's Branch tab. None of them may break.This issue
resolveChatLtmWriteScope, Sources destinations, draft apply, extraction update targets, transfers and the Vault filter.generation-injectionpassesinheritedNoteIds, and every otherretrieveLongTermMemorycaller is unchanged. Inherited memories are therefore read-only in the branch: extraction never picks them as update targets, so a branch can't change a memory that belongs to another branch.matchesLtmScopeandltmScopesOverlapin the sharedscope.tsstay as they are.#1420 (removing the per-branch tab) must keep these working
chatOnlyLtmScope), so new imports keep today's default.{ groupId, chatIds: group.chatIds }, which is what Sources' "All branches" does today.Regression proof
Add
tests/long-term-memory-branch-recall.regression.tsand add it to the "Run Long-Term Memory regressions" list in.github/workflows/ltm-browser.yml.Fixtures:
Also check:
recall.jsonare byte-identical after recall;Run the existing recall regressions as well:
runtime,reconciliation-recall,index-keys,routesandroutes-scope-identity.Environment
staging2039583ca)upstream/stagingdce3590bb)