Skip to content

Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More

fix(dedup): preserve comparison operators in exact-title matches (#6747)

Afloatbe6023934bc3
diff --git a/src/services/dedup/normalize.ts b/src/services/dedup/normalize.ts
index 591c0e8ef..c86445111 100644
--- a/src/services/dedup/normalize.ts
+++ b/src/services/dedup/normalize.ts
@@ -36,7 +36,7 @@ export function exactTitleMatch(a: string | null | undefined, b: string | null |
// Whole-title bold markup spanning words is presentation. Do not strip
// underscores from a single code token such as Python's __init__.
.replace(/^__([\s\S]*\s[\s\S]*)__$/u, '$1')
- .match(/[\p{L}\p{N}\p{M}._/\\:@#=<>+~-]+/gu) ?? [])
+ .match(/!==?|[\p{L}\p{N}\p{M}._/\\:@#=<>+~-]+/gu) ?? [])
// Keep the whole lexical token, including path roots and hyphens.
// Matching only an identifier fragment loses the distinguishing suffix
// in src/foo-bar and the leading separator in /src/config.ts.
@@ -48,7 +48,7 @@ export function exactTitleMatch(a: string | null | undefined, b: string | null |
// Compare complete symbol-bearing tokens, even when another symbol
// follows them (C++:). Pure prose hyphens and terminal colons need not
// become identifiers, but paths, drive letters and code symbols do.
- .filter(token => /^\.+$/u.test(token) || /[/\\]/.test(token) || (
+ .filter(token => /^(?:\.+|[<>=]+|!==?)$/u.test(token) || /[/\\]/.test(token) || (
/[\p{L}\p{N}]/u.test(token) && (
/[._@#=<>+~]/.test(token)
|| /[\p{L}\p{N}\p{M}]:+[\p{L}\p{N}\p{M}]/u.test(token)
diff --git a/tests/sqlite/dedup-code-identifiers.test.ts b/tests/sqlite/dedup-code-identifiers.test.ts
index c673e5fe5..78ac7a90f 100644
--- a/tests/sqlite/dedup-code-identifiers.test.ts
+++ b/tests/sqlite/dedup-code-identifiers.test.ts
@@ -28,6 +28,14 @@ const pairs = [
['Updated foo::bar::baz', 'Updated foo bar baz'],
['Called __init__', 'Called init'],
['__Updated user_name field__', 'Updated user name field'],
+ ['Cache enabled when retries > 0', 'Cache enabled when retries < 0'],
+ ['Retry when status >= 500', 'Retry when status <= 500'],
+ ['Retry when status > 500', 'Retry when status >= 500'],
+ ['Use value = expected', 'Use value != expected'],
+ ['Use value == expected', 'Use value === expected'],
+ ['Use value != expected', 'Use value !== expected'],
+ ['Use value!=expected', 'Use value==expected'],
+ ['Use value!==expected', 'Use value!=expected'],
] as const;
const thresholds = { cosineThreshold: 0.9, vetoThetaIdf: 1 };
@@ -79,6 +87,15 @@ describe('exact-title dedup preserves code identifiers', () => {
expect(repeat.mergedIntoExisting).toBe(true);
});
+ it('finds the matching condition after an opposite comparison sharing the title key', () => {
+ const negative = save('Cache enabled when retries < 0');
+ const positive = save('Cache enabled when retries > 0');
+ const repeat = save('CACHE ENABLED WHEN RETRIES > 0!');
+ expect(positive.id).not.toBe(negative.id);
+ expect(repeat.id).toBe(positive.id);
+ expect(repeat.mergedIntoExisting).toBe(true);
+ });
+
it('still merges case, surrounding punctuation and prose hyphenation variants', () => {
const first = save('On-Demand Checkpoint.');
expect(save('on demand checkpoint').id).toBe(first.id);