mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #8589] [Feature]: Let Advanced Memory return a structured memory block for Long-Term Memory and expose its records to packages #8415
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#8415
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 31, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/8589
Originally assigned to: @Promansis on GitHub.
What problem does this solve?
Advanced Memory already pays a model call for every scene recap. The Long-Term Memory package cannot use that work:
persistence.listChatSummaries(1.387) returns day, week, rolling and game-session summaries from chat metadata;advanced_memory_recordsis not part of it.## timeline_event/Summary: ...blocks are machine-readable.Since #8359 Long-Term Memory replaces built-in recall in chats that list it. A roleplay chat with both Advanced Memory and Long-Term Memory on therefore runs two summary systems, and the second one has to extract from the chat again.
Proposed solution
Host-only. When Long-Term Memory is registered and active for the chat, the one Advanced Memory scene summary call also returns a structured block, the record stores it, and packages can read it. Scenes only: a continuity record is the compacted recap of messages the scene records already cover and is rewritten as the window moves, so it carries nothing new and would be re-imported on every rewrite. Nothing else about Advanced Memory changes, and the request is byte-identical when Long-Term Memory is not registered.
References are to Engine
307d91bed. S =packages/server/src, SH =packages/shared/src.S/services/advanced-memory.ts(prompt assembly, about lines 1893-1915), whenlongTermMemoryRuntimeAvailable()and the chat lists Long-Term Memory (thelongTermMemoryActivepredicateresolveMemoryRecallPolicyalready uses), append the package's instruction to the Advanced Memory tail and change the output line to{"summary":"historical recap","memory":"..."}. The instruction text comes from the package:LongTermMemoryRuntimeService(S/services/generation/long-term-memory-runtime.ts:17) gains an optionalsummaryMemoryInstruction?(): string | null. No method ornullmeans no block and no change to the request. Onlyscenesummaries ask for it;continuity,temporary,excerpt,recollectOnlyandaudienceOnlypaths do not. It follows the existing pattern foraudienceandrecollections: one reply, one more key.structured_memoryonadvanced_memory_records(S/db/schema/advanced-memory.ts, next tosummary_work). In the single-output parse (about line 2140) readtryParseJsonRecord(outputs[0])?.memorywhen it is a string and save it with the record;contentkeepsparseChatSummaryResult(...).summaryexactly as today. For multi-batch runs, ask for the block in first-pass batches only and store the batch blocks joined with a blank line; combine passes do not ask for it. The shorten check (about line 2192) measuressummaryonly, so a block never triggers a shortening pass. The column is internal likesummaryWork: not on the publicAdvancedMemoryRecord, and left out oftransferRecordSchemainS/services/advanced-memory-transfer.tson export and import.manualOverride), setstructured_memoryto null. The package then extracts from the edited prose with its model path instead of importing units the user may have corrected away.CapabilityChatSummaries(SH/types/capability-runtime.ts:389) withadvancedMemory: CapabilityAdvancedMemorySummary[]and fill it inlistChatSummaries(S/services/capability-packages/capability-persistence.service.ts:561) under the samechat-readpermission: enabled, completedscenerecords of the chat, each as{ id, kind, title, content, timeline, startMessageId, endMessageId, audienceCharacterIds, sourceFingerprint, updatedAt, memory }wherememoryis the stored block ornull. Not included:summaryWork, embeddings, dependencies,continuity,temporary,excerpt,recollection.SH/schemas/capability-package.schema.ts(block at 1496-1500), and a section after "Capability API 1.387: read a chat's summaries" indocs/development/optional-agent-packages.md(line 1832) showing the new field and the runtime method.advanced-memory-summary.regression.ts: the tail carries the instruction only when a runtime withsummaryMemoryInstructionis registered and the chat lists the package; a reply withmemorystores it and leavescontentunchanged; a reply without it stores null; shortening ignores the block; Fix nulls it.capability-persistence-permissions.regression.ts:advancedMemorypresent underchat-read, denied without it, andmemoryround-trips as stored. Transfer export has nostructured_memory.Minimal fix
Alternatives considered
advanced_memory_recordsdirectly. Packages have no table access, by design.Additional context
advanced_memorysource, imports records whosememoryblock is present without a model call, falls back to its existing summary extraction when it isnull, and raisesengine.minto the Engine release that ships this."memory"key in the request and the stored block inlistChatSummaries(...).advancedMemory[0].memory; the same scene without the package registered sends today's request unchanged and storesnull.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@Promansis commented on GitHub (Oct 31, 2026):
Package side: Pasta-Devs/Marinara-Agents#1964.
@Promansis commented on GitHub (Oct 31, 2026):
Decisions from the maintainer: the package owns the block format (
summaryMemoryInstruction), Fix clears the stored block, and continuity records are included only if the implementer confirms they are stable once written (not rewritten each turn); otherwise scenes only.@Promansis commented on GitHub (Oct 31, 2026):
Correction to the decision above: scenes only. Continuity is the compacted recap of messages the scene records already cover and is rewritten as the window moves, so it carries nothing new for the package. The body is updated.