mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #8359] [Feature]: Skip built-in memory recall when Long-Term Memory is on, and put its text in the conversation memories slot #8293
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#8293
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 26, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/8359
Originally assigned to: @Promansis on GitHub.
What problem does this solve?
When the Long-Term Memory agent is on for a chat, a turn can get memories from two systems at once:
memory_chunkstranscript search, injected byinjectMemoryRecallContext. It is on by default in conversation mode and scene chats, and opt-in for roleplay.recallLongTermMemory).Nothing dedupes the two. In a conversation chat with Long-Term Memory on, the prompt carries the built-in block in the
memoriesslot and the Long-Term Memory block as a separate agent injection. Often they describe the same past events in two formats. The turn also runs two embedding passes over the same history.Advanced Memory already avoids this in roleplay and game:
!advancedMemoryEnabledgates built-in recall in the generate route, and thememory-recall-exclusivityregression keeps the two settings apart. Long-Term Memory has no such rule.Regenerate is uneven too. Long-Term Memory recall skips regenerated turns (
!input.regenerateMessageId), but built-in recall does not. A regenerated reply in a Long-Term Memory chat therefore gets a different memory source from the reply it replaces.Proposed solution
When Long-Term Memory is active for a chat's turn, Long-Term Memory replaces built-in recall in the prompt. Chats without it are unchanged. This is a host-only change to the generate route; the package needs no change for it.
References are to
packages/server/src/routes/generate.routes.tsat5b7d81b83.One predicate. Name the existing check once:
longTermMemoryActive = chatEnableAgents && chatActiveAgentIds.includes("long-term-memory"). It is already evaluated early, at about line 3254, where the runtime section is made eligible.Skip built-in prompt recall when it is true. This covers both
injectMemoryRecallContextprompt paths in the "Memory recall" block (about lines 5779-5830):memoriesslot path;!advancedMemoryEnabled.The following stay unchanged:
conversationImportantMemoryBlock;chunkAndEmbedMessages), so built-in recall still works if Long-Term Memory is turned off later;access_vectorspath. It passesmessages: [], feeds only custom agents and never reaches the main prompt. The same goes for its twin inroutes/generate/retry-agents-route.ts.Conversation mode: put Long-Term Memory's text in the
memoriesslot.memoriesslot (conversationContextMacroSlots.memories): callrecallLongTermMemoryinside that block. Join its text afterconversationImportantMemoryBlockintoconversationMemoriesBlockValue, so{{#if memories}}and the deferred relocation decode (#3448) see it. Then skip the later injection at about line 7792 for that turn.agentSignal,roleplayTimeline,agentWhisperNames,conversationRecallHistoryandpromptCharacterIds.Regenerate. The built-in skip uses
longTermMemoryActivewithout the regenerate clause, so a regenerated turn never falls back to built-in recall. For regenerated turns, the proposal is:includeRecallHistory(about line 4158) relaxed the same way.recordLongTermMemoryPromptAccepted: leave the receiptundefinedon regenerate, as today, so the package's usage counts are not doubled.Regression. Put the decision in a small exported helper, in the style of
resolveRetryAgentContextPolicy. Inputs: chat mode, Long-Term Memory active, Advanced Memory enabled, recall setting, vectorizer available, hasmemoriesslot, regenerate. It returns which recall runs and where Long-Term Memory's text goes. Add ascripts/regressions/case for:memoriesslot: slot placement;Second part (small, same area). Add
persistence.listChatSummaries(chatId)toservices/capability-packages/capability-persistence.service.ts. It would return the chat's day, week, rolling (summaryEntries) and game-session summaries (gamePreviousSessionSummaries). The shapes are inpackages/shared/src/types/chat.ts. Long-Term Memory reads these today from raw chat metadata throughgetChat. A declared method would turn that into a contract the package can test against.Alternatives considered
enableMemoryRecalloff when the agent is turned on). Long-Term Memory is turned on per chat through the agent list, not a chat setting. Rewriting the user's recall setting would also stick after Long-Term Memory is turned off. A per-turn gate leaves the setting alone.Additional context
engine.minto the Engine release that ships this change. Until then, a chat that uses both would recall the transcript twice.generate.routes.tsis still being split (#7686). If the memory-recall block moves first, the steps above apply to wherever it lands.memoriesslot. The same turn with it off shows today's built-in block. A regenerated turn with it on shows no built-in block.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: