Skip to content

fix(agentic_rag): honor similarity_threshold in deduplicate_chunks#829

Open
andrewwhitecdw wants to merge 2 commits into
Agent-Field:mainfrom
andrewwhitecdw:andrewwhitecdw/fix/deduplicate-similarity
Open

fix(agentic_rag): honor similarity_threshold in deduplicate_chunks#829
andrewwhitecdw wants to merge 2 commits into
Agent-Field:mainfrom
andrewwhitecdw:andrewwhitecdw/fix/deduplicate-similarity

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

Bug: deduplicate_chunks accepted a similarity_threshold argument but only performed exact-match deduplication, so the threshold was silently ignored.

Fix: Compare chunks using Jaccard similarity over normalized token sets and only keep a chunk when it is below the threshold relative to every chunk already kept.

Test: Added regression tests covering exact duplicates, near-duplicates at the default threshold, threshold sensitivity, and empty input.

The deduplicate_chunks helper accepted a similarity_threshold parameter
but only performed exact-match deduplication. Use Jaccard similarity
over normalized token sets so the threshold is actually honored.

Signed-off-by: Andrew White <andrew.white@cdw.com>
Signed-off-by: Andrew White <andrewh@cdw.com>
@andrewwhitecdw
andrewwhitecdw requested review from a team and AbirAbbas as code owners July 24, 2026 18:42
@CLAassistant

CLAassistant commented Jul 24, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ santoshkumarradha
❌ andrewwhitecdw
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

3 participants