Skip to content

Rewrite cache key uses a different history window than the rewrite itself #4

Description

@flxhrdyn

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions