Skip to content

feat(memory): A-MEM dynamic note linking at write time (#1694)#1788

Merged
bug-ops merged 2 commits intomainfrom
research-memory-a-mem-dynamic
Mar 14, 2026
Merged

feat(memory): A-MEM dynamic note linking at write time (#1694)#1788
bug-ops merged 2 commits intomainfrom
research-memory-a-mem-dynamic

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 14, 2026

Summary

Implements A-MEM dynamic memory note linking from NeurIPS 2025 paper.

  • After graph extraction writes entities, a fire-and-forget task re-embeds each new entity name and searches the vector store for semantically similar existing entities
  • Matches above the configured similarity threshold receive a unidirectional similar_to edge (source_id < target_id) tagged with cosine score and timestamp
  • Improves multi-hop recall for queries that span multiple sessions by linking semantically related memories beyond entity co-occurrence

Changes

  • NoteLinkingConfig struct nested under [memory.graph.note_linking] with enabled (default false), similarity_threshold (0.0–1.0, serde-validated, default 0.85), top_k (default 10), timeout_secs (default 5)
  • link_memory_notes() in zeph-memory runs inside the existing spawn_graph_extraction background task — no new spawns, caller never blocked
  • ExtractionResult { stats, entity_ids } replaces bare ExtractionStats return from extract_and_store to cleanly pass entity IDs to the linking step
  • 13 new tests: behavioral (self-skip, threshold filter, unidirectionality) + serde validation (NaN/Inf/out-of-range rejection)

Test plan

  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace --features full -- -D warnings — clean
  • cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins — 5605 passed

Post-merge follow-up issues

  • GAP-01: strengthen self-skip test (secondary entity_id guard path untested)
  • GAP-02: add threshold rejection test in link_memory_notes
  • IMPL-01: fix inflated edges_created stat (cosmetic)
  • PERF-02: batch embed calls (N+1 sequential HTTP round-trips)
  • PERF-03: batch Qdrant search (N+1 sequential searches)

Closes #1694

bug-ops added 2 commits March 14, 2026 22:33
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)
@github-actions github-actions bot added documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes core zeph-core crate enhancement New feature or request size/XL Extra large PR (500+ lines) labels Mar 14, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 14, 2026 21:35
@bug-ops bug-ops merged commit e6a9c5c into main Mar 14, 2026
15 checks passed
@bug-ops bug-ops deleted the research-memory-a-mem-dynamic branch March 14, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request memory zeph-memory crate (SQLite) rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

research(memory): A-MEM dynamic memory note linking at write time (NeurIPS 2025)

1 participant