Harden bounded RAG repair diagnostics - #12
Merged
Conversation
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.
Summary
This follow-up hardens the RAG answer path after #11 while retaining its useful diagnostics and evaluation reporting.
--include-raw-responsesis an explicit opt-inVerification
Exact candidate:
1edb00e12e580352d06837851f13044639133859uv lock --checkpassedgit diff --checkpassedClean 30-case Ollama benchmark
Provenance recorded
git_dirty=falseat the exact candidate commit.The abstention result covers the benchmark's five explicit unsupported topics only: parking, wheelchair accessibility, reservations, Wi-Fi, and delivery fees. It should not be generalized beyond those cases.
Raw response diagnostics were disabled in the benchmark report and no raw-response fields were serialized.
Notes
This PR does not deploy the application or change any portfolio content.
Greptile Summary
This PR hardens the RAG answer path by allowing one bounded repair attempt for both premature abstentions (
"clean_abstention"added toREPAIRABLE_FAILURE_REASONS) and citation failures, while preserving valid initial abstentions when repair itself fails. Raw model responses are now excluded from evaluation reports by default and require an explicit--include-raw-responsesopt-in.answer_questionnow retriesINSUFFICIENT_EVIDENCEresponses once with a re-evaluation prompt; if repair returns a valid cited answer the abstention is overridden, otherwise the original abstention is preserved.run_rag_evaluationdistinguishesmodel_abstention_confirmed_after_repair,model_abstention_preserved_after_failed_repair, andmodel_abstention_after_repairfor repair-path abstentions, and addsretrieved_source_missing_idas an explicit data-integrity outcome.build_evaluation_reportemitsschema_version: 3withraw_responses_includedand repair-count fields;_report_markdownusesreport.get(\"diagnostics\", …)to render legacy v2 reports without crashing.Confidence Score: 5/5
Safe to merge; the repair logic is well-bounded, the abstention-preservation path is tested, and the raw-response opt-in correctly defaults to off.
All new code paths through
answer_questionare exercised by unit tests, the schema v3 / v2 fallback is verified, and the--include-raw-responsesgate is covered end-to-end in the CLI test. The one new finding —"model_abstention"being an unreachable branch — is a dead-code consequence of the intended design change, not a runtime defect.Files Needing Attention: evaluation.py — the
"model_abstention"outcome branch inrun_rag_evaluationis now unreachable from productionanswer_questionresults; worth either removing or documenting as intentionally reserved.Important Files Changed
"clean_abstention"added to REPAIRABLE_FAILURE_REASONS so premature abstentions now get one repair attempt; the repair prompt no longer echoes the rejected response; the combined abstention guard preserves valid initial abstentions correctlyretrieved_source_missing_id;raw_responses_includedflag gates raw fields from serialized observations;_report_markdowngets a safe fallback for schema v2 reports; the"model_abstention"outcome branch is now unreachable dead codeSequenceModelrefactored from variadic*args+list.pop(0)to singlelist[str]+iter(); new tests cover false-abstention repair, citation repair, confirmed/preserved abstention paths and benchmark topics; three prior paths remain uncovered (noted in previous review)retrieved_source_missing_idclassification, preserved initial abstention, and confirmed-after-repair abstention; existing abstention-after-repair test is retained--include-raw-responsesdefault/opt-in and verifies raw fields are absent by default and present when opted in--include-raw-responsesstore-true flag to theevaluatesubparser and threads the value intobuild_evaluation_report--include-raw-responsesopt-in, and raw-response privacy guidanceFlowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[answer_question] --> B{matches found?} B -- No --> C[empty_retrieval] B -- Yes --> D{source IDs valid?} D -- No --> E[retrieved_source_missing_id] D -- Yes --> F[invoke model] F --> G{initial response valid?} G -- Yes --> H[answered] G -- No --> I{initial_failure_reason in REPAIRABLE_FAILURE_REASONS?} I -- No --> J[CITATION_VALIDATION_MESSAGE no repair] I -- Yes --> K[invoke repair model] K --> L{repair response valid?} L -- Yes --> M[answered_after_repair] L -- No --> N{initial OR repair == clean_abstention?} N -- initial AND repair == clean_abstention --> O[model_abstention_confirmed_after_repair] N -- initial == clean_abstention only --> P[model_abstention_preserved_after_failed_repair] N -- repair == clean_abstention only --> Q[model_abstention_after_repair] N -- No --> R[citation_validation_rejection_after_repair]Reviews (2): Last reviewed commit: "test: preserve repair outcome diagnostic..." | Re-trigger Greptile