Repository navigation
FIX: keep the response handler's metadata in SelfAskLikertScorer - #2925
Merged
Roman Lutz (romanlutz) merged 1 commit intoSep 30, 2026
Merged
Roman Lutz (romanlutz) merged 1 commit into
Roman Lutz (romanlutz) merged 1 commit into
Conversation
`_convert_score` assigned `score.score_metadata` outright, replacing the dict that `UnvalidatedScore.to_score` had just installed from the judge's reply. Any metadata the response handler parsed was therefore dropped from the persisted score, leaving only `likert_value`. `response_handler` is a documented argument, so a caller-supplied handler that reports metadata could never have it survive. The sibling float-scale scorers -- `SelfAskScaleScorer`, `SelfAskGeneralFloatScaleScorer` and `InsecureCodeScorer` -- all leave the parsed metadata in place for the same payload. Extending the dict instead of replacing it matches them, and matches the merge idiom used elsewhere in the score package.
Roman Lutz (romanlutz)
approved these changes
Sep 30, 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
SelfAskLikertScorerdrops the metadata that the response handler parsed out of the judge's reply.UnvalidatedScore.to_scoreinstalls the parsed metadata on theScore(pyrit/models/score/score.py:406), and then_convert_scorereplaces that dict:So a judge that reports its own metadata loses it, and only
likert_valuesurvives on the persisted score:Both rows are the same payload through two scorers in the same family. The other two siblings,
SelfAskGeneralFloatScaleScorerandInsecureCodeScorer, also keep it.response_handleris a documented argument of this scorer, so a caller-supplied handler that reports metadata could never have it survive. The fix extends the dict instead of replacing it, which is the merge idiom already used intrue_false/regex/agent_threat_rules_scorer.py:207andtrue_false/wildguard_scorer.py:360. The loss also propagates:FloatScaleThresholdScorerforwardsaggregate_score.metadatainto the score it builds, so the keys are missing there too.Tests and Documentation
Test:
pytest tests/unit/score/test_self_ask_likert.py -q— the new case fails onea9d0b43withassert {'likert_value': 3} == {'verdict_confidence': 0.9, 'raw_judge_output': 'level 3', 'likert_value': 3}and passes on this branch, where the file reads 44 passed. The two existing metadata assertions at:102and:129use replies with nometadatakey, so they pass either way — with nothing to merge, the result is still exactly{"likert_value": N}.pytest tests/unit/score tests/unit/scenario -qgives 4199 passed, 43 skipped.ruff checkandruff format --checkare clean on both changed files. Not run:ty(its pre-commit hook needs the project's--extra allvenv), and JupyText (no notebooks or documentation pages changed).Details
unvalidated.score_metadatais typeddict | None, so the merge guards forNonethe same way the sibling call sites do (**(x.score_metadata or {})).This also applies to the judgment-replay path, which routes through the same
_convert_score.