Skip to content

fix(kb): Chat can keyword-search any saved document, not just the semantic index#29

Merged
SecureCloudGroup merged 1 commit into
mainfrom
fix-kb-search-any-doc
Jul 12, 2026
Merged

fix(kb): Chat can keyword-search any saved document, not just the semantic index#29
SecureCloudGroup merged 1 commit into
mainfrom
fix-kb-search-any-doc

Conversation

@SecureCloudGroup

Copy link
Copy Markdown
Owner

The bug

Chat couldn't find a document stored in Knowledge unless it was in the semantic index. kb_search ran semantic-only whenever an embed model was reachable — ranking purely over the embeddings table. A document that wasn't embedded yet was invisible to Chat, even when its content plainly matched:

  • reindex is a trickle (5 docs/tick), so a freshly-added doc isn't embedded for a while;
  • a doc added before an embed model was configured never got embedded;
  • the keyword scan of full content (KnowledgeBase.search) already exists but only ran as a fallback when embedding failed.

That's the "Chat can only search the index" you hit.

The fix

kb_search now always runs the keyword scan over every document's content — so a quick search reaches any stored document — and, when an embed model is reachable, merges in the semantic (meaning) hits for extra recall. Keyword matches come first, so an un-embedded doc stays visible; semantic augments rather than replaces. Still degrades to keyword-only (flagged degraded) when no embed model is reachable, exactly as before.

Also tightened the tool description so the model reaches for it to look things up.

Test

New regression test: with semantic available, an un-embedded doc is still found by keyword (fails on the old code, passes now). Full backend suite green (626), ruff clean.

Backend-only; independent of the schedules PRs.

…index

kb_search ran semantic-only whenever an embed model was reachable, ranking solely
over the embeddings index — so a document not yet embedded (reindex is a 5-docs/tick
trickle, or the doc predates configuring an embed model) was invisible to Chat, even
when its content plainly matched. The lexical keyword scan of full content only ran as
a fallback when embedding failed.

Now kb_search ALWAYS runs the keyword scan (reaches any stored document) and, when an
embed model is reachable, merges in the semantic (meaning) hits for extra recall —
keyword matches first so an un-embedded doc stays visible. Degrades to keyword-only
(flagged) when no embed model is reachable, as before.

Adds a regression test: with semantic available, an un-embedded doc is still found.
Full suite green (626).
@SecureCloudGroup SecureCloudGroup merged commit db34ec3 into main Jul 12, 2026
7 checks passed
@SecureCloudGroup SecureCloudGroup deleted the fix-kb-search-any-doc branch July 12, 2026 15:01
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.

1 participant