Skip to content

fix(session-search): route short CJK OR queries to LIKE - #20499

Closed
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:fix/session-search-short-cjk-or
Closed

fix(session-search): route short CJK OR queries to LIKE#20499
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:fix/session-search-short-cjk-or

Conversation

@LeonSGP43

Copy link
Copy Markdown
Contributor

Summary

Fixes #20494.

search_messages() already avoids trigram FTS for single 1-2 character CJK queries because SQLite trigram cannot match them. Boolean queries like 广西 OR 桂林 OR 漓江 OR 旅游 slipped through because the code checked the total CJK character count across the whole query, selected trigram, and returned no hits.

This PR:

  • checks CJK term length per non-operator token before choosing trigram FTS
  • routes boolean CJK queries with any too-short term through the existing LIKE fallback
  • applies simple OR/AND semantics across LIKE clauses while preserving existing filters

Verification

  • scripts/run_tests.sh tests/test_hermes_state.py -k 'CJK or cjk' -> 19 passed, 4 warnings
  • scripts/run_tests.sh tests/test_hermes_state.py -> 212 passed, 4 warnings
  • git diff --check

Overlap Check

I checked open PRs for 20494, session_search, CJK, and trigram. The active nearby PRs are broader session-search/schema work (#20238, #20239), but I did not find a direct fix for this short-token boolean CJK routing bug. This patch is limited to hermes_state.py search routing and targeted regression tests.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists labels May 6, 2026
@teknium1

Copy link
Copy Markdown
Contributor

This looks implemented on current main, so this PR can be closed as already fixed. This is an automated hermes-sweeper review.

Evidence:

  • hermes_state.py:3219 now performs the per-token CJK length check for non-operator tokens, so OR-combined 1–2 character CJK terms no longer get sent to trigram FTS.
  • hermes_state.py:3284 routes those short/mixed CJK queries through the LIKE fallback and builds one LIKE condition per non-operator token joined with OR, while preserving filters.
  • tests/test_hermes_state.py:1254 adds regression coverage for 广西 OR 桂林 OR 漓江 OR 旅游, and tests/test_hermes_state.py:1276 verifies the source-filter behavior on that path.
  • The proving commit is 058c50816c70c5f9a1253a87776d50e8df4c5dcf (fix(session): route OR-combined short CJK tokens to LIKE fallback (#20494)), included in v2026.5.16.

@teknium1 teknium1 closed this Jun 11, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session_search returns 0 hits for OR-combined ≤2-char CJK queries (trigram picked but can't match)

3 participants