mirror of
https://github.com/Pasta-Devs/Marinara-Agents.git
synced 2026-12-03 18:55:07 +07:00
[GH-ISSUE #1364] [Issue]: LTM recall: each turn re-scans the whole vault, and any edit re-embeds every memory #698
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#698
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 13, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1364
Originally assigned to: @Promansis on GitHub.
Summary
Every recall re-reads, re-validates and re-hashes the whole vault, and any vault change re-embeds every memory. On 1.4.8 with 2,000 memories, recall took 1.7-1.9 s with an up-to-date index and 5.0 s after editing one tag, using an instant fake embedder. The code paths are unchanged at 1.4.30. #1328 deferred this work until it was measured at realistic vault sizes.
Affected package
long-term-memory1.4.30 (upstream/staginga468f18e6), underpackages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/:rebuild.ts:rebuildLongTermMemoryIndexes(line 119; embedding at 135) andloadOrRebuildLongTermMemoryIndexes(line 190; freshness check at 211-218)source-processing.ts:386and:567: rebuilds after extractionindex-state.ts:170andmutation-transaction.ts:96,:111,:146: the index revision and dirty flagroutes.ts:476(editor saves) andreconciliation.ts:932(draft accept)Expected behavior
Actual behavior
recall.json(vectors included), lists every memory, re-chunks them all and hashes the result to check freshness (rebuild.ts:204-218).rebuild.ts:135). No vectors are reused. A chunk'ssourceHashalso covers tags, scope and status, so it can't serve as an embedding cache key.routes.ts:476) and inside the draft and vault locks on draft accept (reconciliation.ts:932).source-processing.ts:386,:567), even when the commit applied none of them. Source memories are not indexed, so that rebuild changes nothing.index-state.tskeeps a revision number and a dirty flag, whichmutation-transaction.tsupdates on every mutation, but recall never reads them.Measured on 1.4.8 (real package modules, 2,000 synthetic memories, 384-dimension vectors, instant fake embedder):
recall.jsonsizeA real embedder makes the rebuild case slower.
Steps to reproduce
Environment
>=2.4.1 <4.0.0)upstream/staginga468f18e6)Logs, screenshots, or video
See the measurement table above. No private data is involved; the vault was synthetic.
Additional context
Minimal fix, in order:
rebuildLongTermMemoryIndexes, read the previousrecall.jsonwhen it parses and has the samespaceId. Store a hash of each chunk's embedded text as a new optionaltextHashon each embedding entry, and embed only chunks whose text hash is new. In every other case (no old index, a malformed one, a different embedding space), embed everything, as now.source-processing.ts:386and:567, rebuild only when the commit changed memories.mutation-transaction.ts. Keep the full hash check on each process's first recall, so files edited outside the package are still caught after a restart.Regressions: editing one tag re-embeds only that memory's chunks; changing the embedding space re-embeds everything; extraction that applies nothing does not rebuild; a mutation invalidates the cached index.
Notes:
textHashis a new field, and the index schema is strict. After a downgrade, an older package reads the index as malformed and rebuilds it once. The index is derived data, so nothing is lost.rebuild.ts:233-234).Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: