fix: preserve cited answers with standalone abstention markers - #10
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
INSUFFICIENT_EVIDENCEappears only as an exact standalone lineValidation
uv lock --checkandgit diff --checkpassedScope
No benchmark data, evaluation results, metrics, prompts, datasets, or generated reports were changed.
Greptile Summary
This PR adds a preprocessing step (
_remove_standalone_control_token) that stripsINSUFFICIENT_EVIDENCEmarker lines appearing on their own lines from LLM responses before citation validation, allowing mixed-output answers (where the model both hedges and provides cited content) to be surfaced rather than silently replaced with the validation error message. The citation validator and all other rejection paths are unchanged._remove_standalone_control_tokenthat returnsNone(reject) if the token appears mid-prose, or the cleaned text (token lines removed) if it only appears as standalone lines.Confidence Score: 5/5
Safe to merge — the change is narrowly scoped, the citation validator and all other rejection paths are untouched, and the new helper is fully covered by three precise tests plus a dashboard integration test.
The new _remove_standalone_control_token function correctly handles all reachable inputs: fast-path bypass when the token is absent, standalone-line removal, prose-embedded rejection, and the edge case where removal leaves an empty string (which the downstream citation validator rejects cleanly). The pure-abstention check in answer_question still runs first, so the == INSUFFICIENT_EVIDENCE_TOKEN path is unaffected. Tests cover acceptance, prose-embed rejection, uncited-after-removal rejection, and the dashboard rendering path.
Files Needing Attention: No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[LLM response] --> B[answer.strip → normalized_answer] B --> C{normalized_answer == INSUFFICIENT_EVIDENCE_TOKEN?} C -- Yes --> D[AnswerResult abstained=True NO_MATCH_MESSAGE] C -- No --> E[_remove_standalone_control_token] E --> F{Token found in answer?} F -- No --> G[return answer as-is] F -- Yes --> H{For each line: line.strip == token?} H -- Yes --> I[skip line] H -- No --> J{token in line?} J -- Yes --> K[return None] J -- No --> L[retain line] I --> H L --> H H -- all lines processed --> M[join + strip retained lines] G --> N{normalized_answer is None?} M --> N K --> N N -- Yes --> O[AnswerResult CITATION_VALIDATION_MESSAGE] N -- No --> P[_validate_and_number_citations] P --> Q{validated is None?} Q -- Yes --> O Q -- No --> R[AnswerResult valid cited answer]Reviews (1): Last reviewed commit: "fix: preserve cited answers with standal..." | Re-trigger Greptile