Skip to content

Memory: auto-resolve the review queue (research + roadmap) #719

Closed

Description

@currentbits

Problem

The Memory tab's review queue accumulates manual items that the user must resolve by hand (Keep both / Mark reviewed / Invalidate older). The system produces manual work (write-time jaccard ≥0.4 enqueue, semantic ≥0.9 enqueue, janitor contradiction scan) but has no consumer except the human. Additionally four report-only lists (nearDupes, agingRuns, fatConventions, suspect agents) are computed by memory_maintenance but never rendered anywhere — only an agent that chooses to call the MCP tool ever sees them.

Research summary

Our system (memory-server/): every primitive for auto-resolution already exists — resolve(invalidate) tombstones (reversible), supersede merges, invalidateEntry expires runs, janitor runs every 6h. Missing: (1) a decision path for when a pair is safe to auto-invalidate (thresholds are tuned to enqueue, not adjudicate), (2) update resolution performs no merge, (3) dead pairs (one side superseded/invalidated) still need a manual noop, (4) report-only lists have no queue rows and no write paths.

External systems (Mem0, Zep/Graphiti, Letta sleep-time, Claude Code Auto Dream, Generative Agents) converge on:

  • Cheap layers first: exact-hash dedup, recency/access decay, constrain adjudication to top-k or same-entity-pair candidates.
  • Contradictions resolved at write time by an LLM judging ADD/UPDATE/DELETE/NOOP over top-k neighbors — nobody trusts a bare similarity threshold for contradiction.
  • Periodic sleep-time consolidation agent, dual-gated (≥24h elapsed AND activity threshold), merges/absolutizes/deletes-contradicted in one pass, sandboxed writes.
  • New information wins; losers are invalidated, not deleted (reversible, auditable).
  • Cosine ≥0.95 is the common "same thing" bar (Mem0 entity linking); 0.9 is "related", not "duplicate".

Roadmap

Child issues in dependency order:

  1. Deterministic janitor auto-resolution (no LLM): auto-noop dead pairs, age-out stale queue rows, auto-invalidate cosine ≥0.95 pairs, auto-expire ancient run entries.
  2. Write-time near-dup handoff: memory_store warn response includes the duplicate's id so the writing agent can supersede immediately — zero extra model calls.
  3. Sleep-time consolidation pass: a periodic background agent per project that consumes memory_maintenance + memory_distill, adjudicates the ambiguous remainder, merges via supersede, distills strategies. On-brand: an agent curating its own memory.
  4. Memory tab update: queue card shows only genuinely ambiguous pairs + an auto-resolution activity line; surface (or drop) the report-only lists.

Acceptance

  • Review queue open count trends to ~0 without user action; only genuinely ambiguous pairs remain.
  • All auto-resolutions are reversible (tombstone, not delete) and logged with the rule that fired.
  • No false-merge reports; auto-invalidate bar validated against the live store before enabling.

Activity

  1. currentbits commented on Aug 26, 2026

    @currentbits
    OwnerAuthor

    Addendum: GBrain (garrytan/gbrain) findings

    Reviewed GBrain (Garry Tan's production agent brain, 155K pages) plus a code-grounded independent review. It is the most battle-tested example of the sleep-time pattern and confirms the roadmap, with four design refinements worth stealing:

    1. The dream cycle is a named, ordered phase graph, not one free-form agent run. runCycle composes phases — sync, fact extraction, transcript synthesis, pattern detection, fact consolidation, take grading, calibration, orphan checks, purge — each under locks, each declared deterministic or LLM. Refinement for Memory: periodic sleep-time consolidation agent (dual-gated, memory-tools only) #722: define our consolidation pass as a phase manifest (deterministic janitor rules first, LLM adjudication second, distill last) so each phase is individually testable and skippable, instead of one big prompt.
    2. Contradiction detection ships as an eval-shaped tool with a persistent cache. gbrain eval suspected-contradictions samples retrieval pairs, applies a layered date pre-filter (cheap gate before any model call), then a query-conditioned LLM judge, and caches verdicts so pairs are never re-judged. Refinement for Memory janitor: deterministic auto-resolution of dead/stale/certain queue rows #720/Memory: periodic sleep-time consolidation agent (dual-gated, memory-tools only) #722: our review_queue open-pair unique index already gives us the "never re-judge" property — keep it, and add a date/type pre-filter before the LLM pass so it only sees plausible candidates.
    3. Promotion path: repeated facts consolidate into stronger artifacts ("takes") with confidence, validity windows, and supersession fields. Our analogue: run entries → strategy/knowledge via distill (Memory: periodic sleep-time consolidation agent (dual-gated, memory-tools only) #722 phase 3), and supersession already exists. GBrain validates the shape.
    4. Dedup is layered: content hash (exact), cosine threshold (near), idempotency keys (reruns free). We have all three analogues (title+body jaccard, vectors, open-pair unique index).

    Cautions from the independent review that apply to us: LLM-derived writes need provenance + reversible tombstones (we have this); background maintenance should be a visible operational contract (our janitor snapshot at /health is the seed — extend it with consolidation-pass results); don't let ambient capture bypass an authority boundary (not our problem today — our writes are already agent-initiated).

    Not borrowing: Postgres/pgvector scale, 100+ ops, schema packs, hosted multi-user OAuth — our SQLite + 15-op MCP server is the right size for a desktop app's project memory.

  2. currentbits commented on Aug 26, 2026

    @currentbits
    OwnerAuthor

    Addendum 2: academic systems + OSS memory servers

    Two more research tracks: recent papers (A-MEM, MemoryBank, MemoryOS, Nemori, EverMemOS, Hindsight, HippoRAG, benchmarks) and practical OSS servers (reference MCP memory, basic-memory, supermemory, cognee, OpenClaw/Hermes native, LangMem). Full notes in thread. Net effect on the roadmap:

    Findings that change design decisions

    1. Deterministic freshness beats LLM judgment (arXiv:2606.01435, the strongest negative result found): version/timestamp-aware resolution outperforms LLM-mediated conflict resolution by 10-21pp on FactConsolidation. Spend the LLM budget on finding conflicting pairs, not on judging which wins — resolution is max-timestamp (newer wins). This simplifies Memory janitor: deterministic auto-resolution of dead/stale/certain queue rows #720/Memory: periodic sleep-time consolidation agent (dual-gated, memory-tools only) #722: our "invalidate the older entry" rule is the right default; LLM adjudication is only needed for merge-body composition and genuinely ambiguous pairs.
    2. A-MEM write-time evolution (arXiv:2502.12110, NeurIPS 2025): one LLM call per write deciding an action per neighbor; ablation shows this "evolution" step is where most of the value is (multi-hop F1 45.9→31.2 without it). Our Memory store: return near-duplicate id on warn so the writing agent can adjudicate immediately #721 is the zero-extra-cost version: the calling agent is the LLM, so returning near-dup context at store time gets us A-MEM-style evolution without a server-side model. Priority of Memory store: return near-duplicate id on warn so the writing agent can adjudicate immediately #721 goes up.
    3. LangMem manager pass (langmem) is the cleanest published algorithm for Memory: periodic sleep-time consolidation agent (dual-gated, memory-tools only) #722: one background LLM call over {new writes + similar existing} emitting typed create/update/delete instructions. Supermemory's typed outcomes (updates/extends/derives + isLatest flip, old fact kept) is the same shape. Adopt typed outcomes for the consolidation pass.
    4. Promotion by proven recall (OpenClaw dreaming: minScore + minRecallCount + minUniqueQueries; MemoryOS heat): entries earn salience by being retrieved, not by being written. We already track access_count and decay it; consider folding access counts into bootstrap ranking so never-recalled entries sink out of CLAUDE.md/AGENTS.md templating too (config doctor currently sorts by importance only — worth a look in Memory tab: auto-resolution activity line, queue card shows only ambiguous pairs #723 scope).
    5. Nemori boundary insight (arXiv:2508.03341): consolidation quality is dominated by where you cut raw material. Our threads/runs are already natural episode boundaries — distills should run per-thread, not over arbitrary batches. Already the design; now validated.

    Anti-patterns we already avoid (keep avoiding)

    • Append-only observation stacking without delete discipline (reference MCP server's Solenta X launch trailer #1 user complaint) — our supersede/tombstone paths cover this.
    • Reads that don't expose stable IDs (supermemory: forgetting became impossible) — our entries always carry ids; keep it that way in every new surface.
    • LLM extraction on every write (cognee 2 calls/chunk, supermemory instant-dream cost) — batch-and-consolidate wins; our zero-LLM write path stays.
    • Full-store re-injection per turn (OpenClaw: 20-30% of input tokens) — our capped bootstrap (20/10/15 caps, 800-char bodies) is the right shape.

    Refined acceptance metrics for the roadmap (from LongMemEval / MemoryAgentBench):

    • Contradiction-recall: seed synthetic corrections into a test project ("use X" → later "actually use Y"); assert retrieval surfaces Y and X is tombstoned. This becomes a memory-server test.
    • False-merge rate: 5-10% sampled audit of auto-invalidated pairs; primary safety metric.
    • Abstention precision/recall: % of auto-resolutions correct, and % of genuinely ambiguous pairs that remain in the queue for humans (the queue should hold exactly the ambiguous set — not zero, not everything).
    • Operational: dedup ratio, curation LLM cost per pass (A-MEM reference budget ~1,200 tokens/write; our batch pass should be far below that amortized).

    Explicitly rejected for our scale: PPR/graph-walk retrieval (HippoRAG — append-only, no supersession anyway), RL-learned memory policies (Mem-α), read-time KV compression (EM-LLM/LongMem — wrong layer), belief-revision formalism (arXiv:2603.17244 — nice vocabulary: our queue states map to contraction vs revision, but too heavyweight to implement).

  3. added
    plan:done
    and removed
    plan:doing
    on Sep 8, 2026
  4. currentbits commented on Sep 8, 2026

    @currentbits
    OwnerAuthor

    Roadmap is complete: #720 janitor auto-resolve, #721 write-time near-dup id, #722 sleep-time consolidation, and #723 memory-tab activity line are all plan:done and in tree.

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