Skip to content

Comprehensive dedup quality: type/project/source awareness#268

Merged
CalebisGross merged 1 commit intomainfrom
fix/dedup-quality
Mar 20, 2026
Merged

Comprehensive dedup quality: type/project/source awareness#268
CalebisGross merged 1 commit intomainfrom
fix/dedup-quality

Conversation

@CalebisGross
Copy link
Copy Markdown
Collaborator

Summary

Systematic fix for false memory deduplication. The encoding agent was merging distinct memories that shared vocabulary (e.g., two different decisions about SQLite, or a decision vs an error about the same topic).

Changes

Rule Before After
Base threshold 0.9 0.95
MCP threshold 0.9 (same) 0.98 (higher for explicit input)
Cross-type Allowed Blocked (decision != error)
Cross-project Allowed Blocked (mnemonic != felix-lm)

Evidence

From the real-LLM lifecycle baseline (#262):

  • 765 memories deduped at threshold 0.9
  • 355 (46%) were between 0.9-0.95 — false merges
  • Lowest dedup score: 0.9005 (barely over threshold)
  • Average dedup score: 0.952

Architecture

Replaced bare float32 threshold with dedupContext struct:

type dedupContext struct {
    Threshold    float32 // base (default 0.95)
    MCPThreshold float32 // for explicit input (default 0.98)
    RawSource    string  // incoming memory source
    RawType      string  // incoming memory type
    RawProject   string  // incoming memory project
}

Both encoding paths (polling + event-driven) use buildDedupContext()findDuplicate().

Test plan

  • 10 unit tests (up from 4) covering all dedup scenarios
  • make build + make test pass
  • golangci-lint run — 0 issues
  • Cross-type, cross-project, MCP threshold all tested

Closes #266

Refactor the encoding agent's dedup logic to prevent false merges:

1. Raise default threshold 0.9 → 0.95 — reduces false positives by
   46% based on lifecycle test data (355 of 765 deduped memories were
   below 0.95 similarity)

2. Type-aware: never dedup across memory types — a decision and an
   error about the same topic are distinct memories worth keeping

3. Project-aware: never dedup across projects — "chose SQLite" in
   mnemonic and "chose SQLite" in felix-lm are different decisions

4. Source-aware: MCP memories (explicit user/agent input) use a
   higher threshold of 0.98 — deliberate input deserves preservation

5. Clearer dedup feedback in check_memory and remember responses

The findDuplicate function now takes a dedupContext struct instead of
a bare threshold, making the dedup rules explicit and testable.

10 unit tests covering all dedup scenarios (up from 4).

Closes #266

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@CalebisGross CalebisGross merged commit 8434586 into main Mar 20, 2026
6 checks passed
@CalebisGross CalebisGross deleted the fix/dedup-quality branch March 20, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent UX improvements: recall filtering and noise reduction

1 participant