[GH-ISSUE #1272] [Issue]: LTM recall: graph links can never inject a memory, so the graph weight does nothing #647

Closed
opened 2026-10-20 17:29:20 +07:00 by bsakaguchi · 1 comment
Owner

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

Originally assigned to: @Promansis on GitHub.

Summary

The graph lane cannot change which memories are recalled. A graph match scores at most half its lane weight, and every recall preset keeps that under the default 0.35 threshold, so a memory is never injected because it is linked to a memory that matched. The graph weight therefore has no effect in any preset. In the custom style, a weight below 0.7 does nothing, and a weight of 0.7 or more lets every one-hop neighbour through, relevant or not. This issue proposes letting a linked memory borrow relevance from the memory it is linked to, and asks for a prototype measurement before the change ships.

Follow-up to #1258 and #1264, which left graph scoring as is and deferred this until the BM25 and keyword lanes that seed the graph were fixed. #1264 shipped in 1.4.16.

Affected package

long-term-memory 1.4.18:

  • graph.ts, retrieval.ts, ranking.ts under packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/
  • constants.ts under packages/long-term-memory/src/engine/packages/shared/src/features/agents/long-term-memory/
  • tests/long-term-memory-index-keys.regression.ts

Expected behavior

  • A memory linked to a memory that is recalled can be recalled through that link, even when the link is its only signal.
  • The graph weight changes results, and setting it to 0 turns linked recall off.
  • Links do not flood the prompt. A link from a memory that was not recalled adds nothing, and the memory cap still applies.
  • Debug shows which recalled memory a graph pick came through.

Actual behavior

  1. A graph-only match can never pass.
    • A graph hit scores 1 / (distance + 1): 0.5 at one hop and 0.33 at two (graph.ts:92).
    • Relevance is the strongest lane score × the lane weight (ranking.ts:61).
    • The preset graph weights give these ceilings: balanced 0.105 → 0.053, broad 0.21 → 0.105, story 0.42 → 0.21, exact 0.
    • All of these are under the 0.35 default. This is deliberate since #1258. constants.ts:278-298 documents it, and tests/long-term-memory-index-keys.regression.ts:356-369 pins it.
  2. The graph weight has no effect.
    • Outside the threshold, the graph lane only influences the fused order, and that matters only when the memory cap is full.
    • At the defaults, about 2–3 memories pass per turn against a cap of 12.
    • In the 1.4.15 evaluation below, every graph weight from 0 to 0.5 gave identical selections.
    • In custom, a weight of 0.7 or more makes every one-hop neighbour clear 0.35. The weight is therefore either inert or a switch that admits all neighbours.
  3. Raising the graph score alone is not the fix.
    • The graph score is only hop distance, so it barely separates relevant from irrelevant memories (AUC 0.56, where 0.5 is chance).
    • Rescaling it would inject linked noise along with linked context.
  4. Seeds ignore what actually matched.
    • The graph starts from the top 5 notes of the BM25 lane and the top 5 of the keyword lane (retrieval.ts:188-189).
    • This applies even when those lanes' weights are 0 or their hits failed the threshold.
    • Vector and direct hits never seed it, although vector has the highest weight in balanced, broad and story.
  5. Graph hits do not record where they came from. viaNoteId is the note that was reached, not the seed it was reached from (graph.ts:95). Neither Debug nor an evaluation can tell which matched memory a graph hit is linked to.

What this costs (1.4.15 evaluation; see Additional context):

  • The graph lane reached 51 labelled relevant memories.
  • For 10 of them (about 20%), it was the only lane with a signal; every other lane scored below 0.3.
  • These are the linked memories the graph lane exists for, and they cannot be injected today.

Steps to reproduce

  1. Create memory A with a distinctive keyword. Create memory B with no shared words or meaning, and link it from A.
  2. With the default balanced style and threshold, send a chat turn that matches A only, with debug logging on.
  3. A is injected and B is not. B's only signal is the graph, so its relevance is at most 0.5 × 0.105 ≈ 0.053.
  4. Switch to custom and set the graph weight anywhere from 0 to 0.69: B stays out. At 0.7 or more, B and every other one-hop neighbour of the seed notes pass the threshold.

Environment

  • Marinara Engine version: 2.5.0
  • Package version: long-term-memory 1.4.18 (upstream/staging 6685887b5)
  • Install type: source (code reading plus a local evaluation running the package's real retrieval code)
  • OS + version: not platform-specific
  • Browser or app shell: any

Logs, screenshots, or video

Not applicable. References above are against 6685887b5.

Additional context

Evidence:

  • The evaluation ran 22 hand-written 4-message chat windows over two memory sets of a real vault: 18 labelled, plus 4 off-topic.
  • It used the vault's own MiniLM index and the real 1.4.15 retrieval code.
  • #1264 has since changed the BM25 and keyword lanes that seed the graph, so these numbers must be re-measured on 1.4.18 before tuning.
  • The windows and labels are hand-written and cover only 2 memory sets, so treat the numbers as directional.

Proposed approach (prototype first):

  1. Record the seed. expandLtmGraph returns the seed note and hop distance each hit came from. Debug can then show the memory a graph pick came through, and the evaluation can measure the change.
  2. Seed from recalled memories. Seed the graph from candidates that pass the threshold in any lane, instead of the top BM25 and keyword notes.
  3. Borrow relevance. A graph hit's relevance becomes the seed's relevance × a decay. As a starting point, use about 0.8 for one hop, and lower or none for two hops. A memory linked to one that clearly passed can then pass too, while a link from a memory that did not pass adds nothing. The graph weight should keep a clear meaning: for example, it could become the decay itself, or scale it, with 0 turning linked recall off.
  4. Prototype before shipping.
    • Run it on the labelled evaluation against 1.4.18 for several decay values and for one vs two hops.
    • Report F1, precision, recall of essential memories, and off-topic memories per window.
    • Watch especially for an off-topic memory that passes and pulls in its neighbours.
    • Ship only if linked-memory recall improves without a net loss in precision. Otherwise record the result here and close.
  5. Tests.
    • Replace the "graph-only neighbours stay under the default threshold" assertion.
    • Add regressions for these cases:
      • a neighbour of a recalled memory passes;
      • a neighbour of a memory that was not recalled does not;
      • a graph weight of 0 disables linked recall;
      • the memory cap still bounds graph picks.
  6. Release note. Recall can now include linked memories at the default settings, and a saved custom graph weight may behave differently.

Related: #1258, #1264, #1265.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Oct 8, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1272 Originally assigned to: @Promansis on GitHub. ## Summary The graph lane cannot change which memories are recalled. A graph match scores at most half its lane weight, and every recall preset keeps that under the default 0.35 threshold, so a memory is never injected because it is linked to a memory that matched. The graph weight therefore has no effect in any preset. In the `custom` style, a weight below 0.7 does nothing, and a weight of 0.7 or more lets every one-hop neighbour through, relevant or not. This issue proposes letting a linked memory borrow relevance from the memory it is linked to, and asks for a prototype measurement before the change ships. Follow-up to #1258 and #1264, which left graph scoring as is and deferred this until the BM25 and keyword lanes that seed the graph were fixed. #1264 shipped in 1.4.16. ## Affected package `long-term-memory` 1.4.18: - `graph.ts`, `retrieval.ts`, `ranking.ts` under `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/` - `constants.ts` under `packages/long-term-memory/src/engine/packages/shared/src/features/agents/long-term-memory/` - `tests/long-term-memory-index-keys.regression.ts` ## Expected behavior - A memory linked to a memory that is recalled can be recalled through that link, even when the link is its only signal. - The graph weight changes results, and setting it to 0 turns linked recall off. - Links do not flood the prompt. A link from a memory that was not recalled adds nothing, and the memory cap still applies. - Debug shows which recalled memory a graph pick came through. ## Actual behavior 1. **A graph-only match can never pass.** - A graph hit scores `1 / (distance + 1)`: 0.5 at one hop and 0.33 at two (`graph.ts:92`). - Relevance is the strongest lane score × the lane weight (`ranking.ts:61`). - The preset graph weights give these ceilings: balanced 0.105 → 0.053, broad 0.21 → 0.105, story 0.42 → 0.21, exact 0. - All of these are under the 0.35 default. This is deliberate since #1258. `constants.ts:278-298` documents it, and `tests/long-term-memory-index-keys.regression.ts:356-369` pins it. 2. **The graph weight has no effect.** - Outside the threshold, the graph lane only influences the fused order, and that matters only when the memory cap is full. - At the defaults, about 2–3 memories pass per turn against a cap of 12. - In the 1.4.15 evaluation below, every graph weight from 0 to 0.5 gave identical selections. - In `custom`, a weight of 0.7 or more makes every one-hop neighbour clear 0.35. The weight is therefore either inert or a switch that admits all neighbours. 3. **Raising the graph score alone is not the fix.** - The graph score is only hop distance, so it barely separates relevant from irrelevant memories (AUC 0.56, where 0.5 is chance). - Rescaling it would inject linked noise along with linked context. 4. **Seeds ignore what actually matched.** - The graph starts from the top 5 notes of the BM25 lane and the top 5 of the keyword lane (`retrieval.ts:188-189`). - This applies even when those lanes' weights are 0 or their hits failed the threshold. - Vector and direct hits never seed it, although vector has the highest weight in balanced, broad and story. 5. **Graph hits do not record where they came from.** `viaNoteId` is the note that was reached, not the seed it was reached from (`graph.ts:95`). Neither Debug nor an evaluation can tell which matched memory a graph hit is linked to. **What this costs** (1.4.15 evaluation; see Additional context): - The graph lane reached 51 labelled relevant memories. - For 10 of them (about 20%), it was the only lane with a signal; every other lane scored below 0.3. - These are the linked memories the graph lane exists for, and they cannot be injected today. ## Steps to reproduce 1. Create memory A with a distinctive keyword. Create memory B with no shared words or meaning, and link it from A. 2. With the default `balanced` style and threshold, send a chat turn that matches A only, with debug logging on. 3. A is injected and B is not. B's only signal is the graph, so its relevance is at most 0.5 × 0.105 ≈ 0.053. 4. Switch to `custom` and set the graph weight anywhere from 0 to 0.69: B stays out. At 0.7 or more, B and every other one-hop neighbour of the seed notes pass the threshold. ## Environment - Marinara Engine version: 2.5.0 - Package version: long-term-memory 1.4.18 (`upstream/staging` 6685887b5) - Install type: source (code reading plus a local evaluation running the package's real retrieval code) - OS + version: not platform-specific - Browser or app shell: any ## Logs, screenshots, or video Not applicable. References above are against 6685887b5. ## Additional context **Evidence:** - The evaluation ran 22 hand-written 4-message chat windows over two memory sets of a real vault: 18 labelled, plus 4 off-topic. - It used the vault's own MiniLM index and the real 1.4.15 retrieval code. - #1264 has since changed the BM25 and keyword lanes that seed the graph, so these numbers must be re-measured on 1.4.18 before tuning. - The windows and labels are hand-written and cover only 2 memory sets, so treat the numbers as directional. **Proposed approach (prototype first):** 1. **Record the seed.** `expandLtmGraph` returns the seed note and hop distance each hit came from. Debug can then show the memory a graph pick came through, and the evaluation can measure the change. 2. **Seed from recalled memories.** Seed the graph from candidates that pass the threshold in any lane, instead of the top BM25 and keyword notes. 3. **Borrow relevance.** A graph hit's relevance becomes the seed's relevance × a decay. As a starting point, use about 0.8 for one hop, and lower or none for two hops. A memory linked to one that clearly passed can then pass too, while a link from a memory that did not pass adds nothing. The graph weight should keep a clear meaning: for example, it could become the decay itself, or scale it, with 0 turning linked recall off. 4. **Prototype before shipping.** - Run it on the labelled evaluation against 1.4.18 for several decay values and for one vs two hops. - Report F1, precision, recall of essential memories, and off-topic memories per window. - Watch especially for an off-topic memory that passes and pulls in its neighbours. - Ship only if linked-memory recall improves without a net loss in precision. Otherwise record the result here and close. 5. **Tests.** - Replace the "graph-only neighbours stay under the default threshold" assertion. - Add regressions for these cases: - a neighbour of a recalled memory passes; - a neighbour of a memory that was not recalled does not; - a graph weight of 0 disables linked recall; - the memory cap still bounds graph picks. 6. **Release note.** Recall can now include linked memories at the default settings, and a saved `custom` graph weight may behave differently. Related: #1258, #1264, #1265. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:29:20 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@Promansis commented on GitHub (Oct 8, 2026):

Prototype result on 1.4.18 (6685887b5): not shipping. Balanced weights, threshold 0.35, cap 12, 23 hand-written 4-message windows over two memory sets of a real vault (19 labelled, 4 off-topic), short and padded-long. Seeds were the memories injected without the graph lane; a linked memory scored max(own relevance, seed relevance × decay^hops), and the existing budget and serializer chose the result.

  • Decay 0–0.75: no change.
  • 0.8, one hop: short windows +1 relevant / +3 unrelated, precision 0.795 → 0.750, essential recall unchanged; long windows unchanged.
  • 0.9, one hop: short +4 / +13, long +3 / +18 (precision 0.795 → 0.661 and 0.604 → 0.486).
  • 1.0, two hops: short +10 / +47, long +11 / +62.

Most unrelated additions came through broadly linked world and character memories. Links from timeline memories were under half relevant. No tested setting improved linked recall without lowering precision, so the gate fails. Package code is unchanged; a different graph policy is being investigated.

<!-- gh-comment-id:6063067430 --> @Promansis commented on GitHub (Oct 8, 2026): Prototype result on 1.4.18 (6685887b5): not shipping. Balanced weights, threshold 0.35, cap 12, 23 hand-written 4-message windows over two memory sets of a real vault (19 labelled, 4 off-topic), short and padded-long. Seeds were the memories injected without the graph lane; a linked memory scored max(own relevance, seed relevance × decay^hops), and the existing budget and serializer chose the result. - Decay 0–0.75: no change. - 0.8, one hop: short windows +1 relevant / +3 unrelated, precision 0.795 → 0.750, essential recall unchanged; long windows unchanged. - 0.9, one hop: short +4 / +13, long +3 / +18 (precision 0.795 → 0.661 and 0.604 → 0.486). - 1.0, two hops: short +10 / +47, long +11 / +62. Most unrelated additions came through broadly linked world and character memories. Links from timeline memories were under half relevant. No tested setting improved linked recall without lowering precision, so the gate fails. Package code is unchanged; a different graph policy is being investigated.
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#647
No description provided.