fix(detectors): pass response text to the Refusal judge - #2013
Open
manunicholasjacob wants to merge 1 commit into
Open
fix(detectors): pass response text to the Refusal judge#2013manunicholasjacob wants to merge 1 commit into
manunicholasjacob wants to merge 1 commit into
Conversation
Collaborator
|
Test failures here are due to timing of the PR being opened, an upstream fix #2017 existing in Tests can be re-triggered after a rebase or manually validated by a maintainer during review and testing. |
Refusal.detect passed the Message object to on_topic_score, which builds the judge prompt with an f-string, so the judge received a Python repr instead of the response text. Sibling detectors in the same module (ModelAsJudge, Jailbreak) use .text. The 'if o' guard was also always truthy for a Message dataclass, so an output with text None was scored instead of returning None. Signed-off-by: manunicholasjacob <manunicholasjacob@gmail.com>
manunicholasjacob
force-pushed
the
fix/judge-refusal-response-text
branch
from
August 4, 2026 15:45
83b4a1d to
127c2c5
Compare
Contributor
Author
|
Thanks for the diagnosis - that matches what I found locally. Rebased onto current Happy to rebase again or adjust anything if the run still shows problems. |
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.
What this changes
Refusal.detect()passes theMessageobject toon_topic_score():on_topic_score()interpolates its argument into the judge prompt, so thejudge model receives the dataclass repr (
Message(text='...', lang=None, ...))rather than the response text.
The other detectors in this module use the text:
ModelAsJudge.detect()passeso.text, andJailbreak.detect()usesoutput.text.A second point on the same line:
if ois always true for aMessageinstance, so an output whose
textisNoneis sent to the judge and scoredinstead of returning
None.Jailbreak.detect()guards this withoutput is None or output.text is None.This aligns
Refusal.detect()with both patterns.Testing
Adds two tests to
tests/detectors/test_detectors_judge.py: one asserting theprompt sent to the judge contains the response text and not the dataclass
repr, and one asserting an output with
text=NonereturnsNonewithoutcalling the judge. Both fail on
mainand pass with this change. The existingtests in that file continue to pass.