test(rag): direct coverage for knowledge_store_rag._run() (#442)#455
Open
mayoka0 wants to merge 1 commit into
Open
Conversation
…roject#442) The knowledge_store_rag processor is the primary retrieval entry point for Knowledge Store assistants, but only its helpers were covered. _run() itself — the guard branches, multi-KS fan-out, per-store error handling, and the context/source assembly — had no direct test. Adds tests/test_knowledge_store_rag.py (10 tests, test-only, no production changes), mirroring the patch-query_one_ks pattern of the existing test_query_rewriting_ks_rag.py: - guard branches: no assistant, empty RAG_collections, no user message, separator-only RAG_collections - success path: single-KS context + source assembly, raw_responses, assistant_data - query construction: last user message used; top_k and owner forwarded - multi-KS fan-out: every KS queried, contexts/sources aggregated - per-store error handling: a failing KS is skipped without sinking a healthy one; all-failing yields empty context - assembly edge: empty-text chunk is sourced but omitted from context Contributed by Mayoka Labs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #442.
What
Adds
backend/tests/test_knowledge_store_rag.py— a focused, test-only module that exercisesknowledge_store_rag._run()directly. Previously only the helpers (_ks_query_helpers,query_rewriting_ks_rag) were covered, leaving_run()'s guard branches, multi-KS fan-out, per-store error handling, and context/source assembly untested.No production code is touched.
Base branch
The
knowledge_store_rag.pyprocessor and its helpers live onfeat/ks-vector-indexing-label, notmain, so this PR targets that branch (the existingtests/test_query_rewriting_ks_rag.pylives there too). Happy to retarget if you'd prefer it elsewhere.Coverage (10 tests)
Mirrors the patch-
query_one_kspattern of the existingtest_query_rewriting_ks_rag.py(realAssistant,AsyncMockedquery_one_ks, realserialize_assistant/_extract_sources):RAG_collections, no user message, separator-onlyRAG_collectionsraw_responses,assistant_datatop_kandownerforwarded verbatimNote on the issue description
The issue mentions a
[N]-numbered context. The current_run()joins chunk texts with\n\n(no[N]prefixes), so the tests assert the actual combined-context + aligned-sources behaviour rather than numbering. If[N]numbering is the intended direction, that's a small production change I'm happy to follow up with in a separate PR.Testing
asyncio_mode = auto(perbackend/pytest.ini), so:All 10 pass locally.
— Contributed by Mayoka Labs