agentmemory icon indicating copy to clipboard operation
agentmemory copied to clipboard

Repeated POST /agentmemory/consolidate runs write reworded duplicate memories

Open Rex57 opened this issue 1 month ago • 0 comments

Current-main boundary

On main 007a1a7 (0.9.30), POST /agentmemory/consolidate runs mem::consolidate. Each run regroups the same high-importance observations by concept and asks the LLM for up to 10 new memories. Nothing records that a group was already consolidated, and the only duplicate check is an exact, case-insensitive title match. The LLM rewords titles between runs, so every run stores new copies of the same facts.

Reproduction and results (from the code path)

  1. Start with a store that has at least 10 observations with importance ≥ 5 sharing concepts, and an LLM provider.
  2. Call POST /agentmemory/consolidate twice with no new observations in between.
  3. Result: the second run returns the same consolidated count and writes that many new memories, built from the same sourceObservationIds as the first run but with different titles.

Observed on a real store: five manual runs over four weeks left 80 memories that were 10 topics × 8 copies; they had to be deleted by hand.

Within one run there is a second gap (#747): the title check searches the memory list read at the start of the run, so two concept groups in the same run can also create two memories with the same title.

Required behavior

  • A concept group whose top observations already produced a current memory (same sourceObservationIds) is skipped without an LLM call.
  • When a group changed, the memory built from overlapping observations evolves (new version, supersedes the old one) even if the LLM picked a different title.
  • Memories created earlier in the same run take part in both checks.

Acceptance checks

  • Two runs with unchanged observations: the second run writes no memory and makes no provider call.
  • A run after one new observation joins a group: one evolved memory, previous version isLatest: false.
  • Two groups in one run that produce the same title: one memory.

Source and existing work

api::consolidate, mem::consolidate.

Related: #747 (in-run title check uses a stale list), #1008 and PR #1041 (the route's 500 error text). The scheduled consolidate-pipeline does not call mem::consolidate; only this REST route does.

Environment: agentmemory 0.9.30, Node v26.10.0, macOS 27.0.1 (arm64).

Rex57 avatar Oct 08 '26 06:10 Rex57