feat(memory): detect and surface conflicting entries on write#88
Merged
Conversation
- Add ConflictThreshold config (default 0.35) for the conflict detection zone - Entries with cosine distance between DedupThreshold and ConflictThreshold are flagged as conflicts but still stored (no silent overwrites) - StoreResult.Conflicts lists each conflict with both entry IDs and texts - Expired entries are excluded from conflict detection - Refactor findDuplicate into findSimilar returning both dups and conflicts - 7 new tests: similar-not-identical, exact-dup, far-apart, multiple conflicts, still-stores, no-embedding, expired-ignored Closes #77 Co-authored-by: Ona <no-reply@ona.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When a new memory entry is semantically similar to an existing one — but not similar enough to be a duplicate — Distill now flags it as a conflict and returns both entries to the caller.
Why
When new context contradicts something already in memory, Distill previously stored both silently. The agent then operated with conflicting information, producing inconsistent behavior. Now the caller knows about the conflict and can resolve it (supersede the old entry, expire the new one, or keep both).
How it works
Two thresholds define three zones:
Conflicts are surfaced, not blocked. The entry is always stored.
Changes
Config.ConflictThreshold— configurable conflict zone boundary (default: 0.35)StoreResult.Conflicts— list ofConflictstructs withNewID,NewText,ExistingID,ExistingText,DistancefindDuplicate→findSimilarreturning both duplicates and conflictsUsage
The caller can then resolve with
POST /v1/memory/supersedeto replace the old entry.Closes #77