Skip to content

Memory store: return near-duplicate id on warn so the writing agent can adjudicate immediately #721

Closed

Description

@currentbits

Parent: #719

At store time the jaccard ≥0.4 warn path (memory-server/src/memory.js:555) silently enqueues a review row and tells the caller nothing. The writing agent is already an LLM — let it adjudicate on the spot, Mem0-style, without any extra model call.

  • memory_store's success response includes nearDuplicate: {id, title, jaccard} when the warn path fires.
  • MCP tool description for memory_store updated: on nearDuplicate, either supersede the existing entry (merge bodies), store with force: true if genuinely distinct, or do nothing if the existing entry already covers it.
  • Same for the semantic ≥0.9 enqueue path if the vector is already available synchronously (it is not today — embed is fire-and-forget; out of scope, janitor auto-resolution #TBD covers those).

Tests: memory-server/test/dedup.test.js — warn response shape; store with force still works.

Activity

  1. currentbits commented on Aug 26, 2026

    @currentbits
    OwnerAuthor

    Priority bump from research (#719 addendum 2): A-MEM's ablation (arXiv:2502.12110) shows write-time "evolution" — updating existing entries when a related new one lands — is the single highest-value curation mechanism (2x the contribution of linking on multi-hop F1). Our zero-cost implementation: the writing agent is already the LLM, so the store response should give it everything needed to evolve the existing entry on the spot:

    • return nearDuplicate: {id, title, jaccard, excerpt} (excerpt matters — the agent shouldn't need a second memory_get round-trip to decide)
    • tool description: prefer superseding the existing entry with a merged body when the new fact refines it; force: true only when genuinely distinct; nothing when already covered
    • per arXiv:2606.01435, the freshness rule is deterministic (newer wins) — the agent composes the merged body, but never has to judge which version is current
  2. added
    plan:doing
    and removed
    plan:todo
    on Aug 27, 2026
  3. currentbits commented on Aug 27, 2026

    @currentbits
    OwnerAuthor

    Implemented on coder/fork-memory-store-return-near-duplicate--5eeb34.

    Store success (Memory.store, MCP memory_store, POST /api/store): when the Jaccard warn path fires (>= 0.4, including force: true bypass of the >= 0.7 block), the payload is now { id, nearDuplicate: { id, title, jaccard, excerpt } }. Distinct writes still return { id } only. Excerpt is the existing neighbor's body (capped at 240 chars) so the writing agent can adjudicate without a second memory_get.

    MCP description tells the agent: on nearDuplicate, prefer memory_supersede with a merged body, force: true only if genuinely distinct, or do nothing if already covered.

    Semantic cosine >= 0.9 enqueue is still fire-and-forget embed (out of scope, as specified).

    Tests: memory-server/test/dedup.test.js (warn shape, force still works, distinct omits the field). server.test.js matches the tool description. node --test test/dedup.test.js — 11 pass.

  4. added
    plan:done
    and removed
    plan:doing
    on Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions