Skip to content

Commit 45b0172

Browse files
IM.codesclaude
andcommitted
fix(memory): relax trivial filter threshold + update broken tests
The < 2 units threshold was too strict: valid 2-word queries like "enterprise bug" were blocked. Change to: - units < 2 → trivial (single word/CJK char) - content chars < 4 → trivial (too short regardless of units) This allows "fix bug" (2 units, 6 chars) and "好的继续" (4 units, 4 chars) while still filtering "bug" (1 unit), "好的" (2 units but 2 chars), etc. Also update memory-search-semantic tests which used single-word queries ("bug") — change to "download bug" to match real-world usage. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b1729a1 commit 45b0172

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/context/memory-search.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,11 @@ export function isTrivialRecallQuery(text: string | undefined | null): boolean {
123123
// CJK: each ideograph/hangul/kana counts as a unit
124124
const cjkMatches = trimmed.match(/[\u3400-\u9FFF\uF900-\uFAFF\u3040-\u30FF\uAC00-\uD7AF]/gu);
125125
unitCount += cjkMatches?.length ?? 0;
126-
// <= 2 units is trivial (single CJK word like "好的" = 2 chars, but meaningless)
127-
if (unitCount <= 2) return true;
128-
// Require at least 4 non-whitespace/punctuation characters
126+
// Single unit (one word or one CJK char) is always trivial
127+
if (unitCount < 2) return true;
128+
// Require at least 4 non-whitespace/punctuation characters.
129+
// Catches "好的" (2 CJK, 2 chars) but allows "fix bug" (2 words, 6 chars)
130+
// and "enterprise bug" (2 words, 13 chars).
129131
const contentChars = trimmed.replace(/[\s\p{P}]/gu, '').length;
130132
if (contentChars < 4) return true;
131133
return false;

test/context/memory-search-semantic.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('memory-search semantic ranking', () => {
6363
});
6464

6565
const result = await searchLocalMemorySemantic({
66-
query: 'bug',
66+
query: 'download bug',
6767
repo: namespace.projectId,
6868
limit: 2,
6969
});

0 commit comments

Comments
 (0)