Skip to content

FEAT: Add DecisionMatchesScorer for decision model responses - #4310

Open
Dev3 ^~^ (shashank03-dev) wants to merge 13 commits into
microsoft:mainfrom
shashank03-dev:feat/decision-matches-scorer
Open

Dev3 ^~^ (shashank03-dev) wants to merge 13 commits into
microsoft:mainfrom
shashank03-dev:feat/decision-matches-scorer

Conversation

@shashank03-dev

Copy link
Copy Markdown
Contributor

Related to #3246, part 1 of the split proposed in #3250.

Adds DecisionMatches, a condition naming the expected answer to one typed decision question, and DecisionMatchesScorer, which scores a LiteLLMDecisionTarget reply against it (noul with a threshold, choice by option name). Unlike DecisionScorer, which uses a decision model as a judge, this scores the decision model itself as the system under test, and seeds can carry a different expected answer per item.

Tests: 38,993 passed, 30 skipped, 3 xfailed; lint and full type checks pass; diff coverage 100%. Tests cover a SQLite round trip of the condition (True vs "true" keep their types), SDK-normalized DecisionsResponse replies, malformed and out-of-range answers, and a YAML seed run through PromptSendingAttack with a pass and a fail case.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Input validation accepts blank choices as failed attacks and allows extremely large probability integers to trigger uncaught OverflowError exceptions, compromising scoring reliability.

2 open issues
What changed in this PR

Adds scoring support for decision models as systems under test, implementing the first part of #3246 split from #3250. Each seed can specify its expected answer without using the decision model as a judge.

Changes:

  • Adds the typed DecisionMatches condition and public lazy exports.
  • Adds DecisionMatchesScorer for threshold-based noul answers and exact choice matches.
  • Adds validation, persistence, SDK-response, and attack-flow tests, plus documentation examples.
File Description
tests/​unit/​score/​test_decision_matches_scorer.py Tests scoring, validation, persistence, and seed-driven attacks.
tests/​unit/​models/​test_condition.py Tests condition validation and type-preserving round trips.
pyrit/​score/​true_false/​decision_matches_scorer.py Implements decision-answer matching and probability metadata.
pyrit/​score/​__init__.py Exports the new scorer lazily.
pyrit/​models/​score/​condition.py Defines the DecisionMatches condition.
pyrit/​models/​score/​__init__.py Exports the condition from scoring models.
pyrit/​models/​__init__.py Exposes the condition through the public models API.
doc/​code/​scoring/​1_true_false_scorers.py Documents usage with a decision-scoring example.
doc/​code/​scoring/​1_true_false_scorers.ipynb Adds the matching notebook example and output.

Review effort: Balanced

@shashank03-dev

Copy link
Copy Markdown
Contributor Author

hey Richard Lundeen (@richlundeen) #3250 regarding this which you asked for the 3 split I've 2 split implemented and for the last one I needed a bit of help from you , would you rather I make it a general converter that applies a sub-converter to the value at a JSON path, or keep it as DecisionStateConverter?
it would be easier for me to move on if I'd get to know about your opinion on this and lmk your pov so that I can work on it as you need.

@hannahwestra25 hannahwestra25 self-assigned this Nov 21, 2026
# Conflicts:
#	pyrit/models/__init__.py
#	pyrit/models/score/__init__.py
#	pyrit/models/score/condition.py
#	tests/unit/models/test_condition.py
…es-scorer

# Conflicts:
#	pyrit/score/__init__.py
@shashank03-dev

Copy link
Copy Markdown
Contributor Author

hannahwestra25 merged main to fix the pyrit/score/__init__.py conflict, no code changes. This is part 1 of the #3250 split. Could you take a look when you have time?

…es-scorer

# Conflicts:
#	doc/code/scoring/1_true_false_scorers.ipynb
#	doc/code/scoring/1_true_false_scorers.py
…ecision parser

DecisionMatchesScorer raised InvalidJsonException when a valid decision
response had no answer for the scored question, which LiteLLM produces when
the model refuses it. The attack then failed with no score. It now returns an
undetermined score that names the question and the answered questions.

DecisionScorer and DecisionMatchesScorer now read decision responses through
one module, pyrit/score/decision_response.py, so the range-first probability
check also stops DecisionScorer from overflowing on very large integers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@hannahwestra25 hannahwestra25 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing! I pushed a repair: a refused decision question now scores undetermined, and both decision scorers share one response parser.

…es-scorer

# Conflicts:
#	tests/unit/models/test_condition.py
auto-merge was automatically disabled December 4, 2026 09:22

Head branch was pushed to by a user without write access

@shashank03-dev

Copy link
Copy Markdown
Contributor Author

hannahwestra25 merged main on top of your fix to clear a conflict in test_condition.py (main added SatisfiesRubric tests in the same spot), kept both. No code changes. Ready to merge once CI finishes.

This branch has not been deployed

No deployments
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.

3 participants