[Feature] Retrieval should prioritize knowledge base over web search when both are enabled
Current behavior
When a chat/IM session enables web search together with knowledge bases, retrieval runs both in parallel and merges results into a single ranked list (retrievalSourceMixed), with cross-source score comparison and no source priority. The classified intent (e.g. kb_search) does not gate web results.
Problem
For enterprise KB-QA scenarios this inverts expectations: for a question the KB clearly answers (e.g. "who is responsible for ops?"), SEO-optimized generic web pages routinely outrank the KB's own documents, so the bot answers from the web — or even claims it "cannot search the knowledge base" — while the correct answer exists in the KB. Users must disable web search entirely to get reliable KB answers, losing the hybrid capability.
Suggested options (any one would help)
- Cascade fallback: search the KB first; invoke web search only when KB top scores fall below a threshold.
- Source-priority weighting: when KB results pass a confidence bar, suppress or down-weight web results in the merged ranking.
- Intent gating: when query intent is classified as
kb_search, restrict targets to KB; use web only forweb_searchintent.
Happy to contribute a PR once a direction is agreed.
Environment
WeKnora main @ 2026-09, IM channel (WeCom) with web_search_enabled=true on the builtin quick-answer agent; observed via pipeline logs (stage=Search ... web_enabled=true + web results ranked above KB chunks).
Living Memory should keep source, scope, freshness, and retrieval intent attached to each result, so a knowledge-base answer is not treated as interchangeable with a web hit. Proactive Execution can use a typed cascade: answer from eligible KB evidence first, fall back to web only when the threshold is unmet, and show the source decision plus re-check condition. That preserves hybrid search without silently widening authority. Maker note: Klik is pre-launch, exploring Living Memory and approval-aware Proactive Execution: https://pre.hiklik.ai/?utm_source=github&utm_medium=issue_comment&utm_campaign=retrieval_provenance&utm_content=weknora_source_priority_20260902
Hi @YG52052051, are you currently working on this issue? If not, I’d be happy to take it.
My preferred approach is option 1, a KB-first cascade: search the knowledge base first and invoke web search only when KB evidence is insufficient. I’ll keep the change backward-compatible and add regression tests for KB-hit, KB-miss, and mixed-source cases.
Maintainers, would this direction be acceptable?
@/tmp/draft-comment-2984.md