AgentBreakerResult accepts out-of-schema judge verdict values
Steps to reproduce
Run the following against main at commit 3f50ea5ff9cd7050099940647c15c39b07a93392:
from garak.attempt import Conversation, Message, Turn
from garak.detectors.agent_breaker import AgentBreakerResult
class Judge:
def __init__(self, payload):
self.payload = payload
def generate(self, **_kwargs):
return [Message(text=self.payload)]
def verify(payload):
detector = object.__new__(AgentBreakerResult)
detector.evaluation_generator = Judge(payload)
conversation = Conversation(
[Turn(role="user", content=Message(text="judge this result"))]
)
print(detector._verify_once(conversation))
verify('{"success":"MAYBE","confidence":0.99,"reasoning":"x"}')
verify('{"success":"YES","confidence":"NaN","reasoning":"x"}')
verify('{"success":"YES","confidence":"Infinity","reasoning":"x"}')
verify('{"success":"YES","confidence":1.5,"reasoning":"x"}')
Current output:
(False, 0.99, 'x')
(True, nan, 'x')
(True, inf, 'x')
(True, 1.5, 'x')
The payloads containing "NaN" and "Infinity" are valid JSON strings, which are subsequently accepted by Python's float() conversion.
Expected behavior
The packaged AgentBreaker judge prompt declares success as YES, NO, or PARTIAL, and confidence as a value from 0.0 to 1.0. Values outside those domains should be treated as unparseable so the existing verification retry mechanism can retry and ultimately return None if necessary.
Current behavior
_verify_once() type-checks success, rejects boolean confidence, and then normalizes with .upper() and float(). It does not validate the success enum, numerical finiteness, or the documented confidence range.
This can silently turn an unknown success label or NaN into a miss, while infinity or an out-of-range confidence can be treated as a successful result. A nan value can also propagate into Attempt.notes and be emitted as the non-standard JSON constant NaN.
garak version
0.17.1.pre1, source commit 3f50ea5ff9cd7050099940647c15c39b07a93392.
Additional Information
- Operating system: Windows
- Python version: 3.12.5
- Install method: editable source checkout
- No target, model, API, GPU, or network access is required
- Focused parameterized tests reproduce the behavior deterministically
Related issue #2120 and PR #2121 added type validation for non-string success values and boolean confidence. They do not validate string enum values, non-finite numbers, or the confidence range, and this behavior remains reproducible after that merged change.
I found no open issue or pull request describing this value-domain validation gap, and no open PR currently modifies the AgentBreaker detector or its test file.
I'd like to pick this up if it's in scope. Following the contributing guide for unverified bugs, here's a test case first.
Reproduced on main at 3f50ea5 (Python 3.11.9, Windows). The judge prompt in garak/data/agent_breaker/prompts.yaml declares "success": "YES" or "NO" or "PARTIAL" and "confidence": 0.0 to 1.0, but _verify_once() only checks types. I added parametrised cases to TestMalformedVerdictValues in tests/detectors/test_detectors_agent_breaker.py:
successin["MAYBE", ""]should score unknownconfidencein[float("nan"), "NaN", float("inf"), "Infinity", "-Infinity", 1.5, -0.1]should score unknownconfidencein[0.0, 1.0]should stay a valid verdict (inclusive bounds)
Against current main:
python -m pytest tests/detectors/test_detectors_agent_breaker.py -k "out_of_domain_success or out_of_range_confidence or confidence_range_bounds"
9 failed, 2 passed
The 9 failures are the out-of-domain cases; the 2 passes are the bounds. Bare NaN/Infinity literals, which json.loads accepts, behave the same as the quoted strings.
The fix I have in mind stays inside the existing guarded block, in the same style as #2121: raise ValueError when the upper-cased success isn't one of the three labels, and when float(confidence) falls outside [0.0, 1.0] (the chained comparison also rejects nan and inf). Those verdicts then go through the existing retry path and end as None rather than a silent miss or a false hit. With that change the new cases pass, and tests/detectors/test_detectors_agent_breaker.py plus tests/probes/test_agent_breaker.py stay green (122 passed).
One behaviour change to flag: {"success": "YES", "confidence": -0.1} currently scores as a miss (below confidence_cutoff) and would become unknown. Happy to adjust if you'd prefer something else for that case.
AI assistance was used to investigate this and draft the change. Would a PR along these lines be welcome?
Hi, I'd like to pick this up. The fix looks like adding strict value validation (reject NaN/Infinity, out-of-range confidence) when parsing the judge verdict JSON in \AgentBreakerResult. I'll open a PR shortly.
Update: PR submitted — https://github.com/NVIDIA/garak/pull/2188 (reject non-finite or out-of-range confidence in AgentBreaker verdicts).
Thanks @Ewertonslv and @sanjio3 for independently reproducing this and sharing the additional test cases.
I opened this issue after reproducing the problem and had already prepared a local branch with regression tests and a minimal fix before these comments appeared. I have not pushed the branch or opened a PR because the issue is still marked needs-triage, and I wanted to wait for maintainer confirmation as requested by the contributing guide.
My current patch validates the documented YES / NO / PARTIAL success values and rejects non-finite or out-of-range confidence values through the existing retry path. I can also include regression coverage for the additional bare NaN and Infinity cases mentioned above.
To avoid duplicate PRs, I would like to proceed with the implementation once a maintainer confirms that the issue and proposed scope are appropriate. Maintainers, could you please confirm whether I should open the prepared PR?
I've closed my PR (#2188) to avoid duplication. @NaCr05, please go ahead with your prepared fix — happy to help review or provide the regression tests I had written if that's useful.
Hi maintainers, a brief follow-up on my September 13 comment: would you welcome a PR covering both the documented YES / NO / PARTIAL success values and finite confidence values within [0, 1], with invalid verdicts following the existing retry/unknown path?
I have a local patch and regression tests prepared. Since this issue is still marked needs-triage, I would appreciate confirmation of the scope before opening the PR. I'll refresh it against current main and rerun the relevant tests before submission. Thanks for your time!
Hi maintainers, a brief check-in on whether the verdict-validation scope above is suitable for a PR. The issue remains needs-triage, so I have kept the prepared fix local. If the documented success values and finite confidence in [0, 1] are the intended contract, I can refresh the patch and regression evidence before submission. Please let me know if this should be narrowed or deferred. Thank you!
AI-assisted follow-up, posted at the contributor's request.