Skip to content

Keep Memory useful, current, and safe as it grows #658

Open

Description

@dcramer

Junior should retain useful knowledge across Conversations without accumulating redundant facts, losing important details, or restoring removed information. This issue tracks the Memory quality and lifecycle roadmap, including consolidation, expiry, deletion, index repair, and evaluation. The goal is measurable improvement in task results, not just fewer stored records.

Current Baseline

Source was inspected at 7be403183 on 2026-09-23. This replaces stale claims in the original issue while preserving its unresolved work.

  • Expiry filtering and opportunistic archive batches now exist. The first archive work is recorded in fix(memory): Archive expired memories opportunistically #663; fix(memory): Deduplicate memory writes #665 is also linked in the original discussion. A periodic Memory-wide lifecycle job remains missing.
  • The current kinds are preference, procedure, and knowledge; extraction and writes carry these kinds. The old eight-kind taxonomy and “everything is knowledge” diagnosis no longer apply.
  • Exact duplicate checks normalize whitespace and require the same kind, access scope, and subject. Semantic duplicate review and supersession run only for user preferences. Procedures and knowledge have no equivalent write-time review. See createScopedMemory and Passive capture writes near-duplicate knowledge #1218.
  • Shared procedures use their origin Conversation as their subject. This can prevent equal facts learned in different Conversations from matching the exact duplicate gate. Origin, subject, and access need separate treatment.
  • Extraction asks the model to skip existing facts after a broad top-10 search. Recall selects relevant memories but does not explicitly require each selected record to add distinct information. See process-session.ts and recall.ts.
  • Archived records can be recreated with an old write key. Retry lookup follows only one supersession link. Existing storage tests confirm archived recreation and the absence of semantic review for non-preference memories. These contracts need deliberate revision before broad consolidation.
  • Embedding writes still suppress failures. Repair on some repeated writes and aggregate embedding coverage do not replace failure diagnostics or a bounded repair job. Preserve this unresolved work from the original issue.

Target Behavior

  • Retain one supported representation of a fact while keeping related but distinct procedures separate.
  • Preserve source references, ownership, conditions, exceptions, versions, and observation times through updates.
  • Resolve supported corrections without treating the latest extraction time as proof of truth. Keep unresolved conflicts explicit.
  • Recall distinct useful facts at the point they help the task, including during a Turn where evaluation supports it.
  • Honor removal across retries and derived copies. Distinguish a new explicit request to remember a fact from replay of an old extraction.
  • Keep access boundaries intact. Never combine private records from different Users or promote private content into public memory.
  • Bound background work, storage growth, model spend, and index repair. Keep semantic consolidation, expiry, user removal, and physical deletion as separate operations.

Proposed Roadmap

This is the agreed direction to evaluate, not a claim that the design is implemented or that its quality is established.

  • Establish a labeled baseline for duplicate, complementary, conflicting, stale, and distinct memories. Include difficult non-duplicates, not only easy merge cases.
  • Prevent new procedure and knowledge duplicates through candidate-level review. Improve extraction search under Focus extraction hybrid pre-search queries #1247. Similarity can find candidates; it must not alone authorize removal. This replaces the original hard cosine-deletion proposal.
  • Improve recall selection so redundant records do not consume the prompt budget. Preserve useful exceptions and distinct facts about the same topic.
  • Define source relations, replacement history, durable retry outcomes, and removal behavior. Handle repeated supersession, concurrent writes, user removal during review, and rollback after later changes.
  • Add bounded nightly consolidation in dry-run mode. Review changed records plus a rotating backlog. Record decisions and cost without changing active state.
  • Enable conservative, reversible application after evaluation. First select an existing complete record and supersede redundant records. Add generated synthesis and cross-Conversation consolidation only when evidence and subject handling preserve all material details and origins.
  • Complete lifecycle operations: expired backlog cleanup, embedding failure diagnostics, missing/stale embedding repair, and explicit retention rules for superseded content, evidence, caches, and removal markers.
  • Evaluate task-aware recall through Research action-conditioned mid-run memory recall #1342. Keep this distinct from write quality and nightly maintenance.

Explicit removal and expiry filtering must not wait for the nightly job. Do not delete a record merely because it is old or rarely recalled. Physical cleanup must follow a defined retention policy; consolidating active records is not itself storage reclamation.

Acceptance And Evaluation

A representative case is four overlapping definitions of “deslop.” The target is one complete supported definition, with specific terminology-refactor and eval-cleanup procedures left separate. Confirm ownership, source context, and all qualifiers before applying that consolidation.

  • Compare current behavior, recall-only duplicate suppression, candidate-level write review, and write review plus nightly consolidation.
  • Measure unique relevant facts per prompt, answer quality, correction handling, abstention, lost details, harmful merges, cost, latency, and backlog age.
  • Exercise repeated updates and repeated maintenance runs. Unchanged input should not cause repeated rewrites or make old facts appear newly observed.
  • Test access boundaries, source removal, retry replay, replacement chains, overlapping workers, partial failures, missing embeddings, and rollback through real Junior integration wiring.
  • Use model-based evals for semantic decisions and final answer quality. Keep source content and review prompts out of logs and traces.
  • Require no known access leak or removed-fact recreation, no harmful merge in the critical suite, and no material task-quality regression before automatic application.
  • Compare against simple baselines and leading memory systems using the same workloads, models, and cost budgets. Include Junior tasks and long-term memory benchmarks. Best-in-class reliability is the first milestone; a state-of-the-art quality claim requires comparative results.

Four focused existing PGlite storage tests passed during investigation. They verify current exact deduplication, preservation of distinct facts with identical embeddings, non-preference review behavior, and archived recreation. They do not validate this proposal. Corpus-wide rates, operating budgets, retention periods, and safe semantic-review thresholds remain to be measured or decided.

Related Work And Consolidation

This issue is the umbrella. Keep the focused issues open; their distinct scope and evidence are not duplicates to discard.

Prior Art

  • Mem0: separate extraction from per-fact update review.
  • Letta: perform memory work outside foreground conversation.
  • Graphiti/Zep: retain source links and distinguish recorded time from fact validity.
  • Hindsight: evidence-backed consolidation and duplicate review of consolidated records; per-session grouping can obstruct cross-session consolidation.
  • LongMemEval: evaluate knowledge updates, temporal reasoning, and abstention as well as retrieval.

These inform the design; they do not establish its performance. No graph database, giant profile summary, or unrestricted autonomous memory editor is required for the first milestone.

Original investigation: View Session in Sentry.

via David Cramer.

--

View Junior Session [Sentry]

Activity

  1. added
    enhancement
    on Jun 28, 2026
  2. dcramer commented on Jun 28, 2026

    @dcramer
    MemberAuthor

    First pass of archive done in #663

  3. dcramer commented on Jun 29, 2026

    @dcramer
    MemberAuthor
  4. changed the title [-]Operationalize memory lifecycle: expiry, dedup, supersession[/-] [+]Keep Memory useful, current, and safe as it grows[/+] on Sep 23, 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

    enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions