Skip to content

MAINT: Unify scenario initialize_async's into common parameter bag#2132

Merged
rlundeen2 merged 5 commits into
microsoft:mainfrom
rlundeen2:rlundeen2-scenario-registry-init
Jul 9, 2026
Merged

MAINT: Unify scenario initialize_async's into common parameter bag#2132
rlundeen2 merged 5 commits into
microsoft:mainfrom
rlundeen2:rlundeen2-scenario-registry-init

Conversation

@rlundeen2

Copy link
Copy Markdown
Contributor

Unifies how scenarios receive configuration by collapsing initialize_async's typed keyword arguments into the single param-bag path already used for scenario-specific parameters.

What changed

  • The base Scenario declares the common, run-resolved inputs (objective_target, scenario_strategies, dataset_config, memory_labels, include_baseline) as a default parameter list surfaced from supported_parameters(); subclasses extend rather than replace it.
  • The registry sets every value — common and scenario-specific — through the one set_params_from_args -> resolve_declared_params path, then calls an argument-free initialize_async. initialize_async reads its inputs from self.params instead of its own signature.
  • objective_target names are resolved to instances at the registry layer (via TargetRegistry) before the scenario is initialized, with a clearer error when a name isn't registered.
  • The ScenarioContext boundary is unchanged — only the source of the common inputs moves (param bag, not a typed signature).

This is Phase F of the scenario-simplification effort. Design and rationale (including the newly added Phase H tracking two pre-existing adaptive-scenario bugs found while validating this work): https://gist.github.com/rlundeen2/d2fa5f91eb411ba9b1d0bbf98412f700

Also folds in a fix for pyrit_scan --start-server hanging any caller that captured its output (the detached backend inherited the parent's stdout) and re-validates the affected doc/ notebooks.

rlundeen2 and others added 3 commits July 7, 2026 16:51
Make Scenario.initialize_async argument-free by reading all common run
inputs from a single param bag (self.params), and share the param-bag
create-and-configure flow between the scenario and initializer registries.
Resolve objective_target names against TargetRegistry the same way the
constructor path resolves converter/scorer references, removing the
confusing "must be a PromptTarget instance" rejection. Update scanner and
registry/scenario docs plus tests to the new API.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Fix pyrit_scan --start-server hanging any caller that captures its
output: the detached pyrit_backend inherited the parent's stdout, so
the pipe never reached EOF. Redirect the child's stdout/stderr to a
temp log file (pyrit_backend.log) and reference it in the error paths.

Re-execute and clean up the affected doc notebooks, add server
start/stop cells to 1_pyrit_scan, and align target-catalog model_var
names in the initializer + .env_example.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…gistry-init

# Conflicts:
#	tests/unit/scenario/airt/test_cyber.py
#	tests/unit/scenario/airt/test_scam.py
#	tests/unit/scenario/garak/test_doctor.py

@behnam-o behnam-o 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.

looks good. some little comments

Comment thread pyrit/scenario/scenarios/airt/scam.py Outdated
Comment thread pyrit/setup/initializers/targets.py
Comment thread pyrit/scenario/core/scenario.py
rlundeen2 and others added 2 commits July 8, 2026 17:05
…async

Address PR review: replace the super().supported_parameters() + [...]
override pattern with an additional_parameters() hook the base composes
into supported_parameters (common inputs + additional), so the common
"just add a parameter" case can't silently drop the common inputs.
supported_parameters remains overridable as the escape hatch for
removing/replacing a common input. Mark initialize_async @Final since no
subclass overrides it.

Migrate Scam, TextAdaptive, and AdversarialBenchmark onto the new hook,
update the scenario instructions and 2_custom_scenario_parameters doc,
and add tests for the compose/remove paths.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…gistry-init

# Conflicts:
#	doc/code/scenarios/3_adaptive_scenarios.ipynb
#	doc/code/scenarios/3_adaptive_scenarios.py
#	pyrit/scenario/scenarios/foundry/red_team_agent.py
#	tests/unit/scenario/foundry/test_red_team_agent.py
@rlundeen2 rlundeen2 added this pull request to the merge queue Jul 9, 2026
Merged via the queue into microsoft:main with commit 7d828ed Jul 9, 2026
52 of 53 checks passed
@rlundeen2 rlundeen2 deleted the rlundeen2-scenario-registry-init branch July 9, 2026 00:45
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