Discovery
Issue #1382 (adaptive RAG query refinement) was closed as completed, but AdvancedRAGOptimizer.advanced_search_with_refinement() is never called from RAGService, any API handler, or any workflow in non-test production code. The AdaptiveRAGRefiner LLM-driven refinement loop is entirely dead.
Evidence
advanced_rag_optimizer.py:821 — method exists, is fully implemented:
async def advanced_search_with_refinement(
self, query: str, max_results: int = 10, enable_reranking: bool = True,
) -> Tuple[List[SearchResult], RAGMetrics, list]:
"""Run advanced_search with RLM-driven query refinement (#1382)."""
rlm/__init__.py:16 — AdaptiveRAGRefiner is exported:
from rlm.rag_refiner import AdaptiveRAGRefiner
Grep for advanced_search_with_refinement across all non-test files:
autobot-backend/advanced_rag_optimizer.py:821: (definition only — zero call sites)
RAGService.advanced_search() (the actual entry point) calls self.optimizer.advanced_search() directly, bypassing advanced_search_with_refinement() entirely.
What Was Intended
AdaptiveRAGRefiner evaluates retrieval results via LLM, scores relevance (0.0–1.0), and if results are insufficient, generates a refined query and re-searches — up to max_reflections rounds. This is a meaningful quality improvement: the LLM decides whether retrieved chunks actually answer the query.
Impact
Fix
Wire advanced_search_with_refinement() into RAGService._execute_search_with_timeout() (or as a wrapper around it), gated by a new RAGConfig flag enable_rlm_refinement: bool = False (opt-in, since it adds LLM latency per query).
Affected Files
autobot-backend/services/rag_service.py — call advanced_search_with_refinement() when config.enable_rlm_refinement is True
autobot-backend/services/rag_config.py — add enable_rlm_refinement: bool = False
autobot-backend/advanced_rag_optimizer.py — no change needed, method is already implemented
Related
Discovery
Issue #1382 (adaptive RAG query refinement) was closed as completed, but
AdvancedRAGOptimizer.advanced_search_with_refinement()is never called fromRAGService, any API handler, or any workflow in non-test production code. TheAdaptiveRAGRefinerLLM-driven refinement loop is entirely dead.Evidence
advanced_rag_optimizer.py:821— method exists, is fully implemented:rlm/__init__.py:16—AdaptiveRAGRefineris exported:Grep for
advanced_search_with_refinementacross all non-test files:RAGService.advanced_search()(the actual entry point) callsself.optimizer.advanced_search()directly, bypassingadvanced_search_with_refinement()entirely.What Was Intended
AdaptiveRAGRefinerevaluates retrieval results via LLM, scores relevance (0.0–1.0), and if results are insufficient, generates a refined query and re-searches — up tomax_reflectionsrounds. This is a meaningful quality improvement: the LLM decides whether retrieved chunks actually answer the query.Impact
AdaptiveRAGRefinerinrlm/rag_refiner.pyis unreachable from any live code pathFix
Wire
advanced_search_with_refinement()intoRAGService._execute_search_with_timeout()(or as a wrapper around it), gated by a newRAGConfigflagenable_rlm_refinement: bool = False(opt-in, since it adds LLM latency per query).Affected Files
autobot-backend/services/rag_service.py— calladvanced_search_with_refinement()whenconfig.enable_rlm_refinementis Trueautobot-backend/services/rag_config.py— addenable_rlm_refinement: bool = Falseautobot-backend/advanced_rag_optimizer.py— no change needed, method is already implementedRelated
expanded_queriesalso computed but never used in retrievalNeuralMeshRetrieveralso never wired intoRAGService