Discovery
AdvancedRAGOptimizer._analyze_query_context() builds a QueryContext with expanded_queries: List[str] populated by _expand_query(). However, _retrieve_hybrid_results() only accepts query: str (the original query) and never receives or uses the QueryContext — so the expanded variants are computed and then silently discarded.
Evidence
advanced_rag_optimizer.py:611 — context is built with expanded queries:
context = self._analyze_query_context(query) # populates context.expanded_queries
advanced_rag_optimizer.py:615 — only the raw query string is passed to retrieval:
hybrid_results = await self._retrieve_hybrid_results(query, metrics)
# context is NOT passed — expanded_queries never used
_retrieve_hybrid_results() signature (line 643):
async def _retrieve_hybrid_results(self, query: str, metrics: RAGMetrics) -> List[SearchResult]:
The context variable is only consumed by:
_optimize_result_count() — just slices results, doesn't use expanded_queries
_log_search_completion() — logging only
_build_context_header() — string formatting only
_expand_query() generates up to 5 variants (e.g. "install → setup, deploy", "error → issue, problem") but none of them are ever searched.
Impact
- Query expansion has zero effect on retrieval quality despite being implemented
- Users searching for "install" never get results that only mention "setup" or "deploy"
- Troubleshooting queries like "error X" never retrieve docs mentioning "problem X"
- The
QueryContext.expanded_queries field is dead weight
Fix
Pass context into _retrieve_hybrid_results() and run additional semantic searches for each expanded_query, merging results with the primary search before hybrid scoring. Alternatively, run a single search with the expanded queries concatenated as context (if the KB supports it).
Affected File
autobot-backend/advanced_rag_optimizer.py — _retrieve_hybrid_results() and advanced_search()
Discovery
AdvancedRAGOptimizer._analyze_query_context()builds aQueryContextwithexpanded_queries: List[str]populated by_expand_query(). However,_retrieve_hybrid_results()only acceptsquery: str(the original query) and never receives or uses theQueryContext— so the expanded variants are computed and then silently discarded.Evidence
advanced_rag_optimizer.py:611—contextis built with expanded queries:advanced_rag_optimizer.py:615— only the rawquerystring is passed to retrieval:_retrieve_hybrid_results()signature (line 643):The
contextvariable is only consumed by:_optimize_result_count()— just slices results, doesn't useexpanded_queries_log_search_completion()— logging only_build_context_header()— string formatting only_expand_query()generates up to 5 variants (e.g. "install → setup, deploy", "error → issue, problem") but none of them are ever searched.Impact
QueryContext.expanded_queriesfield is dead weightFix
Pass
contextinto_retrieve_hybrid_results()and run additional semantic searches for eachexpanded_query, merging results with the primary search before hybrid scoring. Alternatively, run a single search with the expanded queries concatenated as context (if the KB supports it).Affected File
autobot-backend/advanced_rag_optimizer.py—_retrieve_hybrid_results()andadvanced_search()