File: backend/app/rag_pipeline.py, _run_rag_pipeline_with_query (contrast with the guard at line 493 in the streaming path)
The synchronous /query path never checks whether retrieved_docs/reranked_docs is empty before formatting the prompt and calling the LLM. format_docs([]) yields an empty context string, and the prompt is still sent to the LLM, which may hallucinate an answer instead of returning the "not found" message the streaming endpoint explicitly returns for the same condition.
Failure scenario: The same question via /query vs /query/stream behaves inconsistently when nothing relevant is retrieved.
See docs/rag-audit-findings.md (item 5).
File:
backend/app/rag_pipeline.py,_run_rag_pipeline_with_query(contrast with the guard at line 493 in the streaming path)The synchronous
/querypath never checks whetherretrieved_docs/reranked_docsis empty before formatting the prompt and calling the LLM.format_docs([])yields an empty context string, and the prompt is still sent to the LLM, which may hallucinate an answer instead of returning the "not found" message the streaming endpoint explicitly returns for the same condition.Failure scenario: The same question via
/queryvs/query/streambehaves inconsistently when nothing relevant is retrieved.See
docs/rag-audit-findings.md(item 5).