-
Notifications
You must be signed in to change notification settings - Fork 1
Guide: Deduplication
When two memories are very similar, thatch surfaces them as duplicate candidates. The agent decides whether to merge, keep both, or mark them as distinct. Thatch never merges or deletes memories on its own.
The dedup cycle is agent-driven:
-
Find pairs.
thatch_find_duplicatessearches for memory pairs whose cosine similarity exceeds the threshold (default 0.85). Pairs already reviewed viathatch_dedup_mark_checkedare skipped. Related pairs are grouped into clusters: a cluster of 3+ labels usually means one topic fragmented across entries that should be consolidated. -
Classify. The agent loads the
thatch-dedup-classifierskill, reads both memories, and decides the relationship:- Duplicate: same information, merge into one.
- Supplement: related but distinct, keep both.
- Contradiction: conflicting information, resolve.
- Unrelated: similar wording, different topic, mark and ignore.
-
Reconcile. For duplicates, the agent merges by updating one memory with
overwrite: trueand deleting the other withthatch_memory_forget. For contradictions, the agent resolves the conflict and updates. For supplements and unrelated pairs, no changes needed. -
Record verdict. The agent calls
thatch_dedup_mark_checkedwith the pair labels and the verdict. This stopsfind_duplicatesfrom re-reporting the pair.
Verdicts are not permanent. Overwriting either memory with
overwrite: true clears all verdicts involving that memory.
Deleting a memory with thatch_memory_forget also clears its
verdicts. This means a merged pair can re-flag if the merge creates
a new similarity with a different memory.
This is intended. A merge changes the content, which may create new duplicate relationships that should be reviewed.
The dedup cycle is not automatic. It fires when:
- The agent calls
thatch_find_duplicatesdirectly (you ask, or the hygiene report motivates it). - The hygiene report at session start shows duplicate candidates,
prompting the agent to run
find_duplicatesand work through them. - The write-time similarity warning fires on
thatch_memory_remember, alerting the agent to near-duplicate entries.
- Similarity is cosine only. Two memories can say the same thing in different words and not be flagged. Two memories with similar wording but different meaning can false-flag.
- The 0.85 threshold is hardcoded. There is no configuration for it.
- The agent drives the cycle. Thatch never merges or deletes memories
on its own. If the agent does not call
thatch_find_duplicates, duplicates accumulate. - Verdicts are cleared when either memory is updated. A merged pair can re-flag if the merge creates a new similarity with a different memory. This is intended, but it means dedup is not a one-time fix.
See hygiene.md for the hygiene report and memory.md for the memory tools.
User
- Guide: Behavior Engine
- Guide: Cli
- Guide: Code Review
- Guide: Commands
- Guide: Cross Session Chat
- Guide: Deduplication
- Guide: Default Behaviors
- Guide: Extraction
- Guide: Hygiene
- Guide: Memory
- Guide: Notifications
- Guide: Prediction Engine
- Guide: Overview
- Guide: Setup
- Guide: Skills
- Guide: Watchers
Developer
Dev Feature Guides
- Feature: Behavior Engine
- Feature: Cicd
- Feature: Cli
- Feature: Commands
- Feature: Compaction Recovery
- Feature: Cross Session Chat
- Feature: Database
- Feature: Deduplication
- Feature: Extraction
- Feature: Hygiene
- Feature: Memory Store
- Feature: Multi Host
- Feature: Notifications
- Feature: Nudge Pipeline
- Feature: Opencode Plugin
- Feature: Prediction Engine
- Feature: Qa System
- Feature: Overview
- Feature: Repo Identity
- Feature: Session Lifecycle
- Feature: Setup
- Feature: Sideband
- Feature: Watchers