[PR #8592] [MERGED] feat(advanced-memory): store a Long-Term Memory block with scene summaries #8693

Closed
opened 2026-11-07 17:38:58 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8592
Author: @Promansis
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @Promansis

Base: staging ← Head: feature(advanced-memory)/ltm-memory-block


📝 Commits (3)

  • 1e626fb feat(advanced-memory): store a Long-Term Memory block with scene summaries (#8589)
  • bd8fe2e fix(advanced-memory): write the scene block with the recap and project the summary listing (#8589)
  • a1395f7 docs(advanced-memory): say the scene block is not audience-scoped (#8589)

📊 Changes

11 files changed (+436 additions, -21 deletions)

View changed files

📝 docs/development/optional-agent-packages.md (+31 -0)
📝 packages/server/src/db/schema/advanced-memory.ts (+2 -0)
📝 packages/server/src/services/advanced-memory.ts (+62 -10)
📝 packages/server/src/services/capability-packages/capability-persistence.service.ts (+67 -2)
📝 packages/server/src/services/generation/long-term-memory-runtime.ts (+19 -0)
📝 packages/shared/src/schemas/capability-package.schema.ts (+3 -1)
📝 packages/shared/src/types/capability-runtime.ts (+25 -0)
📝 scripts/regressions/advanced-memory-recovery.regression.ts (+7 -1)
📝 scripts/regressions/advanced-memory-summary.regression.ts (+145 -1)
📝 scripts/regressions/capability-package-lifecycle.regression.ts (+6 -5)
📝 scripts/regressions/capability-persistence-permissions.regression.ts (+69 -1)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #8589

Why this change

  • Advanced Memory already pays for a model call on every scene recap, but the Long-Term Memory package can't use that work. Its records aren't reachable from a package, and the recap is narrator prose, so turning it into memory needs a second model pass over text a model just wrote.
  • In a roleplay chat with both features on, two summary systems run and Long-Term Memory pulls facts from the chat a second time. This change lets the one scene summary call also return the package's own block. The package can then import it without a model call.

What changed

  • Packages can read Advanced Memory scene summaries (Capability API 1.391). persistence.listChatSummaries(chatId) now also returns advancedMemory: the chat's enabled, completed scene summaries in the order they were written (id, sceneId, kind, title, content, timeline, startMessageId, endMessageId, audienceCharacterIds, sourceFingerprint, updatedAt, memory). It uses the same chat-read permission. Constant, temporary, excerpt and recollection records are not listed.
  • Long-Term Memory can add its own block to the scene summary. long-term-memory:runtime can add an optional summaryMemoryInstruction(). When the chat lists Long-Term Memory as an active agent, the Engine adds that paragraph (capped at 4,000 characters) to each first-pass scene summary request and asks for a "memory" string in the same JSON reply. The Engine stores the string as returned and never parses it. A scene split into parts gets each part's block, joined by a blank line. The combine requests never see the blocks, and the stored recap (content) is unchanged.
  • The block is cleared when it may be stale. A hand edit, a delete, or a new reply without a block sets it to null. Records written before this change also read as null.
  • No change without the package. If Long-Term Memory isn't listed in the chat, or its runtime has no such method, the summary request is byte-identical to before. The new structured_memory column is internal (like summary_work): it isn't on the public record and isn't exported in transfers.
  • Docs: new "Capability API 1.391" section in docs/development/optional-agent-packages.md.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Agent-run local checks on 1e626fb48 (merged with upstream/staging 307d91bed):

  • pnpm check (Impeccable guard, localization, Prettier, lint/types, e2e and token-estimation types, production build): exit 0
  • node scripts/run-regressions.mjs --filter advanced-memory: 23/23 passed
  • node scripts/run-regressions.mjs --filter capability: 27/27 passed
  • node scripts/run-regressions.mjs --filter long-term-memory: 1/1 passed
  • Not run locally: full Node regression lane, pnpm smoke:ui (no UI change), container build

Manual verification notes

Still to verify by hand:

  • In a roleplay chat with Advanced Memory on and Long-Term Memory not listed, run a scene summary and confirm the request has no "memory" instruction (debug prompt log) and the recap looks as before.
  • With a Long-Term Memory build that implements summaryMemoryInstruction() listed in the chat, run a scene summary and confirm the request carries the paragraph, and listChatSummaries(chatId).advancedMemory[n].memory returns the block.
  • Edit that scene summary by hand (Fix) and confirm memory comes back as null.
  • Export the chat's Advanced Memory and confirm the transfer has no structured_memory.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Docs note: this edits docs/development/optional-agent-packages.md, which has translated copies on docs-i18n (for example es/development/optional-agent-packages.md). The translations are not updated in this PR; follow-up issue #8593 tracks them.

UI evidence (if applicable)

No UI changes.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8592 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `staging` ← **Head:** `feature(advanced-memory)/ltm-memory-block` --- ### 📝 Commits (3) - [`1e626fb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1e626fb48fb723c601eb488d63fe8fdf1a70a995) feat(advanced-memory): store a Long-Term Memory block with scene summaries (#8589) - [`bd8fe2e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bd8fe2e26d8a1776410a6fd52360cb48782acd06) fix(advanced-memory): write the scene block with the recap and project the summary listing (#8589) - [`a1395f7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a1395f7bf6945b93ccbb00251b52188929e23da8) docs(advanced-memory): say the scene block is not audience-scoped (#8589) ### 📊 Changes **11 files changed** (+436 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `docs/development/optional-agent-packages.md` (+31 -0) 📝 `packages/server/src/db/schema/advanced-memory.ts` (+2 -0) 📝 `packages/server/src/services/advanced-memory.ts` (+62 -10) 📝 `packages/server/src/services/capability-packages/capability-persistence.service.ts` (+67 -2) 📝 `packages/server/src/services/generation/long-term-memory-runtime.ts` (+19 -0) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+3 -1) 📝 `packages/shared/src/types/capability-runtime.ts` (+25 -0) 📝 `scripts/regressions/advanced-memory-recovery.regression.ts` (+7 -1) 📝 `scripts/regressions/advanced-memory-summary.regression.ts` (+145 -1) 📝 `scripts/regressions/capability-package-lifecycle.regression.ts` (+6 -5) 📝 `scripts/regressions/capability-persistence-permissions.regression.ts` (+69 -1) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #8589 ## Why this change - Advanced Memory already pays for a model call on every scene recap, but the Long-Term Memory package can't use that work. Its records aren't reachable from a package, and the recap is narrator prose, so turning it into memory needs a second model pass over text a model just wrote. - In a roleplay chat with both features on, two summary systems run and Long-Term Memory pulls facts from the chat a second time. This change lets the one scene summary call also return the package's own block. The package can then import it without a model call. ## What changed - **Packages can read Advanced Memory scene summaries (Capability API 1.391).** `persistence.listChatSummaries(chatId)` now also returns `advancedMemory`: the chat's enabled, completed scene summaries in the order they were written (`id`, `sceneId`, `kind`, `title`, `content`, `timeline`, `startMessageId`, `endMessageId`, `audienceCharacterIds`, `sourceFingerprint`, `updatedAt`, `memory`). It uses the same `chat-read` permission. Constant, temporary, excerpt and recollection records are not listed. - **Long-Term Memory can add its own block to the scene summary.** `long-term-memory:runtime` can add an optional `summaryMemoryInstruction()`. When the chat lists Long-Term Memory as an active agent, the Engine adds that paragraph (capped at 4,000 characters) to each first-pass scene summary request and asks for a `"memory"` string in the same JSON reply. The Engine stores the string as returned and never parses it. A scene split into parts gets each part's block, joined by a blank line. The combine requests never see the blocks, and the stored recap (`content`) is unchanged. - **The block is cleared when it may be stale.** A hand edit, a delete, or a new reply without a block sets it to `null`. Records written before this change also read as `null`. - **No change without the package.** If Long-Term Memory isn't listed in the chat, or its runtime has no such method, the summary request is byte-identical to before. The new `structured_memory` column is internal (like `summary_work`): it isn't on the public record and isn't exported in transfers. - Docs: new "Capability API 1.391" section in `docs/development/optional-agent-packages.md`. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Agent-run local checks on ``1e626fb48`` (merged with `upstream/staging` 307d91bed): - `pnpm check` (Impeccable guard, localization, Prettier, lint/types, e2e and token-estimation types, production build): exit 0 - `node scripts/run-regressions.mjs --filter advanced-memory`: 23/23 passed - `node scripts/run-regressions.mjs --filter capability`: 27/27 passed - `node scripts/run-regressions.mjs --filter long-term-memory`: 1/1 passed - Not run locally: full Node regression lane, `pnpm smoke:ui` (no UI change), container build ### Manual verification notes Still to verify by hand: - In a roleplay chat with Advanced Memory on and Long-Term Memory **not** listed, run a scene summary and confirm the request has no `"memory"` instruction (debug prompt log) and the recap looks as before. - With a Long-Term Memory build that implements `summaryMemoryInstruction()` listed in the chat, run a scene summary and confirm the request carries the paragraph, and `listChatSummaries(chatId).advancedMemory[n].memory` returns the block. - Edit that scene summary by hand (Fix) and confirm `memory` comes back as `null`. - Export the chat's Advanced Memory and confirm the transfer has no `structured_memory`. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Docs note: this edits `docs/development/optional-agent-packages.md`, which has translated copies on `docs-i18n` (for example `es/development/optional-agent-packages.md`). The translations are not updated in this PR; follow-up issue #8593 tracks them. ## UI evidence (if applicable) No UI changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:38:58 +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#8693
No description provided.