File: backend/app/rag_pipeline.py:153-154 and 179-180
rewrite_query/rewrite_query_async compute the rewrite-cache key using format_history(history, max_items=1) (only the latest turn), but generate the actual rewritten query using format_history(history) (last 5 turns, default).
Failure scenario: Two different conversations whose latest message happens to be identical but whose earlier turns differ hash to the same rewrite_cache_key. The second conversation is silently served the first conversation's cached standalone query, an unrelated retrieval context.
See docs/rag-audit-findings.md (item 4).
File:
backend/app/rag_pipeline.py:153-154and179-180rewrite_query/rewrite_query_asynccompute the rewrite-cache key usingformat_history(history, max_items=1)(only the latest turn), but generate the actual rewritten query usingformat_history(history)(last 5 turns, default).Failure scenario: Two different conversations whose latest message happens to be identical but whose earlier turns differ hash to the same
rewrite_cache_key. The second conversation is silently served the first conversation's cached standalone query, an unrelated retrieval context.See
docs/rag-audit-findings.md(item 4).