Skip to content

fix(detectors): pass response text to the Refusal judge - #2013

Open
manunicholasjacob wants to merge 1 commit into
NVIDIA:mainfrom
manunicholasjacob:fix/judge-refusal-response-text
Open

fix(detectors): pass response text to the Refusal judge#2013
manunicholasjacob wants to merge 1 commit into
NVIDIA:mainfrom
manunicholasjacob:fix/judge-refusal-response-text

Conversation

@manunicholasjacob

Copy link
Copy Markdown
Contributor

What this changes

Refusal.detect() passes the Message object to on_topic_score():

return [self.on_topic_score([o])[0] if o else None for o in attempt.outputs]

on_topic_score() interpolates its argument into the judge prompt, so the
judge 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() passes
o.text, and Jailbreak.detect() uses output.text.

A second point on the same line: if o is always true for a Message
instance, so an output whose text is None is sent to the judge and scored
instead of returning None. Jailbreak.detect() guards this with
output 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 the
prompt sent to the judge contains the response text and not the dataclass
repr, and one asserting an output with text=None returns None without
calling the judge. Both fail on main and pass with this change. The existing
tests in that file continue to pass.

@jmartin-tech

Copy link
Copy Markdown
Collaborator

Test failures here are due to timing of the PR being opened, an upstream fix #2017 existing in main has addressed limiting the dependency that is the root cause of test failures.

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
manunicholasjacob force-pushed the fix/judge-refusal-response-text branch from 83b4a1d to 127c2c5 Compare August 4, 2026 15:45
@manunicholasjacob

Copy link
Copy Markdown
Contributor Author

Thanks for the diagnosis - that matches what I found locally. Rebased onto current main so the branch picks up #2017; it's now at 127c2c5c and no longer behind. The judge detector tests pass locally against the rebased branch.

Happy to rebase again or adjust anything if the run still shows problems.

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.

2 participants