feat(memory): A-MEM dynamic note linking at write time (#1694)#1788
Merged
feat(memory): A-MEM dynamic note linking at write time (#1694)#1788
Conversation
After graph extraction writes entities, a fire-and-forget task re-embeds each new entity and queries the vector store for semantically similar existing entities. Matches above the configured threshold receive a unidirectional `similar_to` edge (source_id < target_id) tagged with cosine similarity score and timestamp. Improves multi-hop recall for queries spanning multiple sessions by linking semantically related memories beyond entity co-occurrence. - Add `NoteLinkingConfig` (nested under `[memory.graph.note_linking]`) with `enabled`, `similarity_threshold` (0.0-1.0, validated), `top_k`, `timeout_secs`; default disabled - Add `link_memory_notes()` in zeph-memory, runs inside the existing `spawn_graph_extraction` background task - Add `ExtractionResult` wrapper to cleanly pass entity IDs from extraction to linking without polluting `ExtractionStats` - 13 new tests: behavioral (self-skip, threshold filter, unidirectionality) + serde validation (NaN, Inf, out-of-range rejection)
This was referenced Mar 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements A-MEM dynamic memory note linking from NeurIPS 2025 paper.
similar_toedge (source_id < target_id) tagged with cosine score and timestampChanges
NoteLinkingConfigstruct nested under[memory.graph.note_linking]withenabled(defaultfalse),similarity_threshold(0.0–1.0, serde-validated, default 0.85),top_k(default 10),timeout_secs(default 5)link_memory_notes()inzeph-memoryruns inside the existingspawn_graph_extractionbackground task — no new spawns, caller never blockedExtractionResult { stats, entity_ids }replaces bareExtractionStatsreturn fromextract_and_storeto cleanly pass entity IDs to the linking stepTest plan
cargo +nightly fmt --check— cleancargo clippy --workspace --features full -- -D warnings— cleancargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins— 5605 passedPost-merge follow-up issues
link_memory_notesedges_createdstat (cosmetic)Closes #1694