[GH-ISSUE #1362] [Feature]: LTM graph: store links between events so linked recall has more to follow #696

Closed
opened 2026-10-20 17:29:49 +07:00 by bsakaguchi · 0 comments
Owner

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

Originally assigned to: @Promansis on GitHub.

What problem does this solve?

Since 1.4.30 (#1360, #1361), LTM recalls a near-miss memory through an explanatory link from a memory it already recalled. The rule can only follow links that extraction stores, and extraction stores few useful ones.

In a measured real vault (1.4.18 era, 197 notes, 266 stored links):

  • 205 of the 266 links were extracted_from links to source notes. Source notes have no chunks, so the recall graph drops them. The recall graph kept 182 nodes and 61 edges, and 87 nodes (48%) had no edge at all.
  • Every edge ran from a state note (character, relationship, thread or world) to a timeline event. There were no event→event links, no event→participant links and no paid_off_in links, although extraction has offered planted_in and paid_off_in since 1.3.33 (#1138).
  • In the evaluation behind #1360, explanatory links found relevant memories that recall missed. With this few edges, any retrieval-only graph rule has a low ceiling.

Why extraction stores so few, at upstream/staging a468f18e6 (evidence-unit-extraction.ts under packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/):

  • Only units with claimKind: "change" must link to an event, and a timeline event must link only to its source note with extracted_from (serverEnforcedLinkRules, lines 81-92).
  • A link target must be the source note or a unit from the same response (same rules). An event can never link to an event from an earlier extraction batch.
  • involves is not in allowedTimelineRelations (lines 1231-1241), so an event cannot name its participants.
  • isExplanatoryLink (graph.ts:54-65) does not follow event↔event links even when they exist.

Proposed package or change

Minimal fix, in order:

  1. Check first. Re-extract one existing chat on 1.4.30 and count stored links by stored-on type, relation and target type. If event→event caused_by and thread paid_off_in → event links already appear in useful numbers, skip step 2.
  2. Ask for causes between events in the same response. Add one prompt rule: when one event in the response directly caused another, the later event links to the earlier one with caused_by. caused_by is already in the timeline relation set (lines 71-79) and same-response targets are already allowed, so this should need no schema change. Confirm that in the compiler test.
  3. Follow those links. In isExplanatoryLink, also allow caused_by between two timeline_event notes, and paid_off_in from a thread to a timeline_event. The seed rule and the 0.2 own-relevance floor from #1360 stay as they are.
  4. Gate. Rerun the #1360 evaluation (all three sets, short and long windows) on a re-extracted vault. Ship only if F1 rises and off-topic injections don't. Add a regression beside tests/long-term-memory-index-keys.regression.ts:367.

Not in the minimal fix:

  • Event→participant involves links. In the measured vault the two main characters appear in about 83% of recallable notes, so these links would connect nearly everything through two hub notes. They need a degree cap or hub damping first. Follow-up.
  • Event links across extraction batches. These need existing event ids offered as link targets, which changes the extraction contract. Follow-up if step 4 shows that same-response links are too few.
  • Existing vaults. They gain new links only after re-extraction. No backfill here.

Why should this be optional?

It changes only the existing optional long-term-memory package. No Engine change. A graph weight of 0 (the exact preset) still turns linked recall off.

Alternatives considered

  • Links derived from name mentions: rejected for the hub reason above.
  • Following every link type: measured in #1272 rounds 1-3 and rejected. World planted_in → event and event → character caused_by links added no relevant memories in any round.

Additional context

  • Builds on #1360 / #1361 (1.4.30) and #1138 (1.3.33). Background: #1272.
  • The evaluation uses a real vault, so only aggregate counts are reported here.

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.
Originally created by @Promansis on GitHub (Oct 13, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1362 Originally assigned to: @Promansis on GitHub. ## What problem does this solve? Since 1.4.30 (#1360, #1361), LTM recalls a near-miss memory through an explanatory link from a memory it already recalled. The rule can only follow links that extraction stores, and extraction stores few useful ones. In a measured real vault (1.4.18 era, 197 notes, 266 stored links): - 205 of the 266 links were `extracted_from` links to source notes. Source notes have no chunks, so the recall graph drops them. The recall graph kept 182 nodes and 61 edges, and 87 nodes (48%) had no edge at all. - Every edge ran from a state note (character, relationship, thread or world) to a timeline event. There were no event→event links, no event→participant links and no `paid_off_in` links, although extraction has offered `planted_in` and `paid_off_in` since 1.3.33 (#1138). - In the evaluation behind #1360, explanatory links found relevant memories that recall missed. With this few edges, any retrieval-only graph rule has a low ceiling. Why extraction stores so few, at `upstream/staging` a468f18e6 (`evidence-unit-extraction.ts` under `packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/`): - Only units with `claimKind: "change"` must link to an event, and a timeline event must link only to its source note with `extracted_from` (`serverEnforcedLinkRules`, lines 81-92). - A link target must be the source note or a unit from the same response (same rules). An event can never link to an event from an earlier extraction batch. - `involves` is not in `allowedTimelineRelations` (lines 1231-1241), so an event cannot name its participants. - `isExplanatoryLink` (`graph.ts:54-65`) does not follow event↔event links even when they exist. ## Proposed package or change Minimal fix, in order: 1. **Check first.** Re-extract one existing chat on 1.4.30 and count stored links by stored-on type, relation and target type. If event→event `caused_by` and thread `paid_off_in` → event links already appear in useful numbers, skip step 2. 2. **Ask for causes between events in the same response.** Add one prompt rule: when one event in the response directly caused another, the later event links to the earlier one with `caused_by`. `caused_by` is already in the timeline relation set (lines 71-79) and same-response targets are already allowed, so this should need no schema change. Confirm that in the compiler test. 3. **Follow those links.** In `isExplanatoryLink`, also allow `caused_by` between two `timeline_event` notes, and `paid_off_in` from a `thread` to a `timeline_event`. The seed rule and the 0.2 own-relevance floor from #1360 stay as they are. 4. **Gate.** Rerun the #1360 evaluation (all three sets, short and long windows) on a re-extracted vault. Ship only if F1 rises and off-topic injections don't. Add a regression beside `tests/long-term-memory-index-keys.regression.ts:367`. Not in the minimal fix: - **Event→participant `involves` links.** In the measured vault the two main characters appear in about 83% of recallable notes, so these links would connect nearly everything through two hub notes. They need a degree cap or hub damping first. Follow-up. - **Event links across extraction batches.** These need existing event ids offered as link targets, which changes the extraction contract. Follow-up if step 4 shows that same-response links are too few. - **Existing vaults.** They gain new links only after re-extraction. No backfill here. ## Why should this be optional? It changes only the existing optional `long-term-memory` package. No Engine change. A graph weight of 0 (the `exact` preset) still turns linked recall off. ## Alternatives considered - **Links derived from name mentions:** rejected for the hub reason above. - **Following every link type:** measured in #1272 rounds 1-3 and rejected. World `planted_in` → event and event → character `caused_by` links added no relevant memories in any round. ## Additional context - Builds on #1360 / #1361 (1.4.30) and #1138 (1.3.33). Background: #1272. - The evaluation uses a real vault, so only aggregate counts are reported here. ## 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.
bsakaguchi 2026-10-20 17:29:49 +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#696
No description provided.