Skip to content

MAINT simplify how default adversarial and scorer targets are set in scenarios#1695

Draft
behnam-o wants to merge 5 commits intomicrosoft:mainfrom
behnam-o:scenario-targets
Draft

MAINT simplify how default adversarial and scorer targets are set in scenarios#1695
behnam-o wants to merge 5 commits intomicrosoft:mainfrom
behnam-o:scenario-targets

Conversation

@behnam-o
Copy link
Copy Markdown
Contributor

@behnam-o behnam-o commented May 6, 2026

Changes:

1- Use a common logic for resolving default adversarial and scorer targets in scenarios
2- Have a fallback mechanism that uses the target identified by OPENAI_CHAT_*** env variables. This allows someone to only define 1 endpoint and get a runnable scenario

@behnam-o behnam-o changed the title MAINT simplify how default scenario adversarial and scorer targets resolve MAINT simplify how default adversarial and scorer targets are set in scenarios May 6, 2026
from pyrit.registry import TargetRegistry


def get_default_scorer_target() -> PromptChatTarget:
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.

Love this, I had a similar thought

ValueError: If the registered target does not support multi-turn.
"""
return _get_default_chat_target(preferred_target_key="objective_scorer_chat")

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.

Do you think we should move get_default_objective_scorer here also?


def _get_default_objective_scorer(self) -> TrueFalseScorer:
# Deferred import to avoid circular dependency:
composite_scorer_questions_path = type(self).COMPOSITE_SCORER_QUESTIONS_PATH
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.

this is cool, but I wonder if it's hidden? Should we do a method override?

And we could potentially make it more flexible so that individual scenario can add more scorers to the composite

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.

idk. maybe it's good as is, I do like how it saves a bunch of code.

# Deferred import to avoid circular dependency.
from pyrit.setup.initializers.components.scorers import ScorerInitializerTags

entries = ScorerRegistry.get_registry_singleton().get_by_tag(tag=ScorerInitializerTags.DEFAULT_OBJECTIVE_SCORER)
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.

We potentially want to make more use of this ^^^

Because this has metrics to be the "best" objective scorer including composite scorers.

Comment thread .env_example
ADVERSARIAL_CHAT_KEY="xxxxx"
ADVERSARIAL_CHAT_MODEL="deployment-name"

# Objective Scorer chat target (used in scorers in scenarios)
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.

We may want to look at the scorer initializer, so we can make sure to do metrics for whatever the default is

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