Skip to content

Auto-capture: no idempotency key (Stop/PreCompact re-capture loop) + PreCompact/task_context hooks still bypass dedup #80

Description

@RobertSigmundsson

Context: surreal-memory in production for our agent swarm (Uruboros), via stdio MCP + Claude Code Stop/PreCompact auto-capture. Open cards; fix ready on our fork.

Since #69 the Stop hook has embedding-based semantic dedup — good. Two gaps remain:

  1. No idempotency key at the source. The Stop hook fires after every assistant turn and PreCompact on each compaction; both re-read an overlapping transcript tail and re-run analyze_text_for_memories, re-encoding identical fragments across turns. The embedding dedup in stop.py operates within a single candidate batch, so it does not stop the cross-turn re-capture loop (the same fragment persisted last turn is re-encoded this turn).
  2. PreCompact and task_context hooks have no dedup at allpre_compact.py and task_context.py still construct MemoryEncoder without any dedup pipeline.

Impact: the noisiest write path (auto-captured session summaries) accumulates near-duplicates — the memory-poisoning failure mode — on any host using the default Stop/PreCompact integration.

Fix we're offering (PR-ready on our fork, will align after our 2.11.0 rebase): an idempotency key at the source to break the re-capture loop; dedup wired into pre_compact + task_context; exact-content candidate lookup so exact dups can't escape the word-search window. On our deployment this dropped content_hash=0 fresh neurons from ~64% to ~0.25%.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions