FIX TrueFalseResponseHandler: strip whitespace before validating verdict - #2389
Merged
Roman Lutz (romanlutz) merged 1 commit intoAug 14, 2026
Conversation
Contributor
Author
|
hannahwestra25 if you have a moment - this is the same small scorer-hardening class as #2388 (thanks again for merging that one). here the true/false response handler lowercases the verdict but doesn't strip it, so a judge returning a valid |
The true/false response handler lowercased the parsed score value but did
not strip it before checking membership in {"true", "false"}. A judge
returning a valid verdict with incidental surrounding whitespace - e.g.
'true\n', ' false', or 'True ' from a target that does not enforce the
JSON schema - was rejected as out-of-domain, discarding a usable score
(and triggering the JSON retry path).
Strip before lowercasing so incidental whitespace no longer invalidates an
otherwise-valid true/false verdict. Adds a parametrized regression test.
WatchTree-19
force-pushed
the
fix-truefalse-verdict-whitespace
branch
from
August 14, 2026 22:26
3759fed to
7171c95
Compare
Roman Lutz (romanlutz)
approved these changes
Aug 14, 2026
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.
Description
TrueFalseResponseHandler.parselowercases the parsed score value but does not strip it before checking membership in{"true", "false"}:raw_score_valuecomes straight fromstr(parsed_response[score_value_output_key]), so a judge that returns a valid verdict with incidental surrounding whitespace -"true\n"," false","True "- is rejected as out-of-domain. Targets that do not natively enforce the JSON schema can easily emit this, and the result is that a usable true/false judgment is thrown away (and the JSON retry path is triggered, burning a call).The numeric path already tolerates this, since
float("3.0 ")succeeds; only the string-compared true/false domain is whitespace-sensitive.Fix:
strip()beforelower()so incidental whitespace no longer invalidates an otherwise-valid verdict. The storedraw_score_valueremains the clean"true"/"false".Same class as #2133 (parse the raw score robustly before validating it).
Tests and Documentation
Added a parametrized regression test in
tests/unit/score/test_response_handler.pycovering"true "," false","True\n", and" FALSE "-> all now normalize to the expected verdict. Out-of-domain values (e.g."refusal") are still rejected.pytest tests/unit/score/test_response_handler.py tests/unit/score/test_self_ask_true_false.py tests/unit/score/test_general_true_false_scorer.py-> 46 passed.ruffandblackclean. No documentation changes needed (internal parsing behavior only).