judging: structured-mode fallback no longer fabricates a verdict from the reasoning text - #31
Open
ChrisW09 wants to merge 1 commit into
Open
judging: structured-mode fallback no longer fabricates a verdict from the reasoning text#31ChrisW09 wants to merge 1 commit into
ChrisW09 wants to merge 1 commit into
Conversation
parse_json_verdict signals 'not usable JSON' with (None, None, None), but _score_structured fell back to the GRADE regex whenever numeric was None — including when the JSON parsed fine and the grade was merely off-scale. The case-insensitive regex then ran over the raw JSON text, where it could match a 'grade: N' inside the reasoning string and return a fabricated in-scale verdict (e.g. actual grade 7 on a 1-5 scale replaced by an ok-flagged 3 quoted from the reasoning). Now the regex fallback runs only on the (None, None, None) sentinel; a parsed-but-off-scale grade stays an off-scale error rating with the grade and the judge's reasoning preserved for the audit trail. Fixes #14 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Fixes #14.
_score_structuredfell back to theGRADE:regex whenevernumeric is None, conflating "not usable JSON" with "JSON parsed fine, grade off-scale". In the second case the case-insensitive regex ran over the raw JSON text and could matchgrade: Ninside the reasoning string:previously produced an ok-flagged verdict of 3 — fabricated from the reasoning — even though the judge graded 7. In the milder case the off-scale value and reasoning were discarded in favor of "no GRADE marker".
The fallback now runs only on
parse_json_verdict's documented(None, None, None)"not JSON" sentinel. A parsed-but-off-scale grade becomes an off-scale error rating that keeps the actual grade and the judge's reasoning for the audit trail. Plain-text fallback for genuinely non-JSON responses is unchanged (test included).Test:
pytest packages/cafe-core/tests/test_judging.py— 18 passed.🤖 Generated with Claude Code