Skip to content

judging: structured-mode fallback no longer fabricates a verdict from the reasoning text - #31

Open
ChrisW09 wants to merge 1 commit into
mainfrom
fix/structured-fallback
Open

judging: structured-mode fallback no longer fabricates a verdict from the reasoning text#31
ChrisW09 wants to merge 1 commit into
mainfrom
fix/structured-fallback

Conversation

@ChrisW09

Copy link
Copy Markdown
Collaborator

Fixes #14.

_score_structured fell back to the GRADE: regex whenever numeric 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 match grade: N inside the reasoning string:

{"reasoning": "strictly I would give grade: 3, but overall", "grade": 7}   # 1–5 rubric

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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

judging: structured-mode fallback can fabricate an in-scale verdict from text inside the reasoning field

1 participant