[GH-ISSUE #1840] [Feature]: Long-Term Memory: let recall return whole memories instead of ranked parts, as an option for other Agents #1781

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

Originally created by @Promansis on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1840

Originally assigned to: @Promansis on GitHub.

What problem does this solve?

long-term-memory:recall (SV-2, #1567) ranks memories against what the caller is about to write and returns only the parts that score best, cut to maxTokens. That is the right default for most callers, but Slurp and Noodle are about to use recall, and their users have very different setups (small vaults, local models, long or short memories). The maintainer wants the user to choose between ranked parts and whole memories, with whole memories as the default first, so we can check that memories reach the posts at all before tuning ranking. Today the only way to get whole memories is long-term-memory:storage (listNotes), which skips recall's privacy rules (subjects, mode, persona) and which we want to remove (tracker SN-6).

Tracker: SN-3 (and SN-2), unblocks SN-6.

Proposed package or change

One optional input on the recall service, whole, that returns whole memories under the same rules as ranked recall. long-term-memory only, patch bump. Nothing changes in the Engine, Slurp or Noodle.

Minimal fix

S = packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory.

 recall({ caller?, queryText, characterIds?, personaId?, mode?, maxTokens?, signal?, whole? })
   notes = listNotes(...) minus non-shareable, other types, other modes, memories not about the accounts   # unchanged
-  retrieveLongTermMemory(queryText, noteIds = notes, …)  -> parts, by relevance within a type
+  whole ? every memory's full text (all its sections), newest first within a type, no ranking
+        : retrieveLongTermMemory(…)  -> parts, by relevance within a type                       # unchanged default
   -> { version: 1, sections: [{ noteId, type, title?, text }] }
  • Input. whole: z.boolean().default(false) in recallInputSchema (S/services/recall.ts). queryText stays required in both modes, so a caller writes one call for both and an older LTM, which strips the unknown key, answers with ranked parts instead of null.
  • Whole mode. After the existing filters, sort the notes by SECTION_TYPES index, then by updatedAt newest first. A memory's text is chunkNoteSections(note) (S/recall/chunking.ts) texts joined by "\n"; a memory with no text is skipped. Add memories in that order while their estimated tokens fit maxTokens; a memory that doesn't fit is skipped (never cut), and later smaller ones can still fit. At most 20 sections. Use the token estimate recall already uses (estimateTokens in S/recall/budget.ts; export it rather than copy it). No retrieval call, so no embeddings are needed.
  • Unchanged. The switch, validation, null cases, abort handling, recordLtmPackageRead(…, "package_recall", caller, count) and the result shape. version stays 1: the new input is additive (the contract's own rule).
  • Contract. packages/long-term-memory/docs/ARCHITECTURE.md § "Services for Other Packages": document whole, its order (type, then newest first), the skip-don't-cut rule and that an older LTM ignores it and ranks.
  • CHANGELOG under ## Unreleased: "Other Agents that read memories, such as Slurp and Noodle, can ask for whole memories instead of the parts that fit what they are writing. The same memories are shared either way."

Regression proof

tests/long-term-memory-runtime.regression.ts, in the existing recall block (recallRoot, memories for char-a):

  • whole: true for char-a returns the same set of memory ids as ranked recall, in type order, each text equal to that memory's full section text;
  • two memories of one type come back newest first;
  • with maxTokens smaller than the largest memory but larger than a later one, the large memory is missing and the later one is present with its full text;
  • whole: true with the switch off gives null, and with mode: "conversation" against roleplay-only memories gives { version: 1, sections: [] }.

Each of these mutations fails an assertion: whole mode without the subject rule, cutting a memory to fit instead of skipping it, and oldest-first order.

Why should this be optional?

It is an input on an existing service inside an optional package, off unless a caller asks for it. The choice itself is a setting in each reading Agent (Slurp, Noodle). Long-Term Memory's "Other Agents can read memories" switch still stops every read.

Alternatives considered

  • Keep whole memories on long-term-memory:storage: it skips the subject, mode and persona rules, and it keeps a second service alive that SN-6 removes.
  • A separate recallWhole method: two methods to document and keep in step for one difference.
  • Raise maxTokens in ranked mode: recall still returns parts and still ranks against the query, so it is not "whole memories".

Additional context

Follows #1567 (SV-2) and #1805 (SN-1, the Sharing table). Slurp (issues/slurp-ltm-recall.md, SN-3) and Noodle (issues/noodle-ltm-recall.md, SN-2) send whole: true by default; both work against an LTM without this change, ranked. No file overlaps with those two items.

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.

Local trace

  • Mapped on upstream/staging 8c1a195ec (LTM 1.5.7). S/services/recall.ts is 116 lines; notes carry a top-level updatedAt (packages/long-term-memory/src/engine/packages/shared/src/features/agents/long-term-memory/schema/notes.ts:306).
  • Maintainer answer (joint note, question 3, 2026-10-29): "let it be user choosable? default to full so we can test first if it works at all". "Full" is read as whole memories through recall.
Originally created by @Promansis on GitHub (Oct 28, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1840 Originally assigned to: @Promansis on GitHub. ## What problem does this solve? `long-term-memory:recall` (SV-2, #1567) ranks memories against what the caller is about to write and returns only the parts that score best, cut to `maxTokens`. That is the right default for most callers, but Slurp and Noodle are about to use recall, and their users have very different setups (small vaults, local models, long or short memories). The maintainer wants the user to choose between ranked parts and whole memories, with whole memories as the default first, so we can check that memories reach the posts at all before tuning ranking. Today the only way to get whole memories is `long-term-memory:storage` (`listNotes`), which skips recall's privacy rules (subjects, mode, persona) and which we want to remove (tracker SN-6). Tracker: SN-3 (and SN-2), unblocks SN-6. ## Proposed package or change One optional input on the recall service, `whole`, that returns whole memories under the same rules as ranked recall. `long-term-memory` only, patch bump. Nothing changes in the Engine, Slurp or Noodle. ### Minimal fix S = `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory`. ```diff recall({ caller?, queryText, characterIds?, personaId?, mode?, maxTokens?, signal?, whole? }) notes = listNotes(...) minus non-shareable, other types, other modes, memories not about the accounts # unchanged - retrieveLongTermMemory(queryText, noteIds = notes, …) -> parts, by relevance within a type + whole ? every memory's full text (all its sections), newest first within a type, no ranking + : retrieveLongTermMemory(…) -> parts, by relevance within a type # unchanged default -> { version: 1, sections: [{ noteId, type, title?, text }] } ``` - **Input.** `whole: z.boolean().default(false)` in `recallInputSchema` (`S/services/recall.ts`). `queryText` stays required in both modes, so a caller writes one call for both and an older LTM, which strips the unknown key, answers with ranked parts instead of `null`. - **Whole mode.** After the existing filters, sort the notes by `SECTION_TYPES` index, then by `updatedAt` newest first. A memory's text is `chunkNoteSections(note)` (`S/recall/chunking.ts`) texts joined by `"\n"`; a memory with no text is skipped. Add memories in that order while their estimated tokens fit `maxTokens`; a memory that doesn't fit is skipped (never cut), and later smaller ones can still fit. At most 20 sections. Use the token estimate recall already uses (`estimateTokens` in `S/recall/budget.ts`; export it rather than copy it). No retrieval call, so no embeddings are needed. - **Unchanged.** The switch, validation, `null` cases, abort handling, `recordLtmPackageRead(…, "package_recall", caller, count)` and the result shape. `version` stays 1: the new input is additive (the contract's own rule). - **Contract.** `packages/long-term-memory/docs/ARCHITECTURE.md` § "Services for Other Packages": document `whole`, its order (type, then newest first), the skip-don't-cut rule and that an older LTM ignores it and ranks. - **CHANGELOG under `## Unreleased`**: "Other Agents that read memories, such as Slurp and Noodle, can ask for whole memories instead of the parts that fit what they are writing. The same memories are shared either way." ### Regression proof `tests/long-term-memory-runtime.regression.ts`, in the existing recall block (`recallRoot`, memories for `char-a`): - `whole: true` for `char-a` returns the same set of memory ids as ranked recall, in type order, each `text` equal to that memory's full section text; - two memories of one type come back newest first; - with `maxTokens` smaller than the largest memory but larger than a later one, the large memory is missing and the later one is present with its full text; - `whole: true` with the switch off gives `null`, and with `mode: "conversation"` against roleplay-only memories gives `{ version: 1, sections: [] }`. Each of these mutations fails an assertion: whole mode without the subject rule, cutting a memory to fit instead of skipping it, and oldest-first order. ## Why should this be optional? It is an input on an existing service inside an optional package, off unless a caller asks for it. The choice itself is a setting in each reading Agent (Slurp, Noodle). Long-Term Memory's "Other Agents can read memories" switch still stops every read. ## Alternatives considered - Keep whole memories on `long-term-memory:storage`: it skips the subject, mode and persona rules, and it keeps a second service alive that SN-6 removes. - A separate `recallWhole` method: two methods to document and keep in step for one difference. - Raise `maxTokens` in ranked mode: recall still returns parts and still ranks against the query, so it is not "whole memories". ## Additional context Follows #1567 (SV-2) and #1805 (SN-1, the Sharing table). Slurp (`issues/slurp-ltm-recall.md`, SN-3) and Noodle (`issues/noodle-ltm-recall.md`, SN-2) send `whole: true` by default; both work against an LTM without this change, ranked. No file overlaps with those two items. ## 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. ## Local trace - Mapped on upstream/staging 8c1a195ec (LTM 1.5.7). `S/services/recall.ts` is 116 lines; notes carry a top-level `updatedAt` (`packages/long-term-memory/src/engine/packages/shared/src/features/agents/long-term-memory/schema/notes.ts:306`). - Maintainer answer (joint note, question 3, 2026-10-29): "let it be user choosable? default to full so we can test first if it works at all". "Full" is read as whole memories through recall.
bsakaguchi 2026-11-07 16:36:38 +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-Agents#1781
No description provided.