You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All scenarios inherit from `Scenario` (ABC) and must:
14
14
15
15
1.**Define `VERSION`** as a class constant (increment on breaking changes)
16
-
2.**Optionally declare `BASELINE_ATTACK_POLICY`** (defaults to `BaselineAttackPolicy.Enabled` — a baseline `PromptSendingAttack` is prepended and callers can opt out per run via `initialize_async(include_baseline=False)`):
16
+
2.**Optionally declare `BASELINE_ATTACK_POLICY`** (defaults to `BaselineAttackPolicy.Enabled` — a baseline `PromptSendingAttack` is prepended and callers can opt out per run by setting `include_baseline=False` in the run params, see "Run Parameters" below):
17
17
-`BaselineAttackPolicy.Disabled` — baseline supported but off by default (e.g. `Jailbreak`, where templates dominate the run).
18
-
-`BaselineAttackPolicy.Forbidden` — baseline is meaningless for this scenario's comparison axis (e.g. `AdversarialBenchmark`, which compares against gold-standard answers). Explicit`include_baseline=True` raises `ValueError`.
18
+
-`BaselineAttackPolicy.Forbidden` — baseline is meaningless for this scenario's comparison axis (e.g. `AdversarialBenchmark`, which compares against gold-standard answers). Supplying`include_baseline=True` raises `ValueError`.
19
19
3.**Pass `strategy_class`, `default_strategy`, and `default_dataset_config` to `super().__init__()`:**
20
20
21
21
```python
@@ -81,6 +81,34 @@ Requirements:
81
81
-`super().__init__()` called with `version`, `strategy_class`, `default_strategy`, `default_dataset_config`, `objective_scorer`
82
82
- complex objects like `adversarial_chat` or `objective_scorer` should be passed into the constructor.
83
83
84
+
## Run Parameters
85
+
86
+
Run-time inputs (target, strategies, dataset config, concurrency, labels, baseline flag) are **not** arguments to `initialize_async`. They flow through a single parameter bag (`self.params`), populated by `set_params_from_args` from the merged CLI / config / programmatic arguments. `initialize_async` takes no arguments and reads everything from the bag:
The base `Scenario` declares the common run inputs once in `_common_scenario_parameters()`: `objective_target` (a `RegistryReference` — resolved by name or supplied as an instance), the `opaque` live objects `scenario_strategies` / `strategy_converters` / `dataset_config` / `memory_labels` (passed by identity, never coerced or deep-copied), and the scalars `max_concurrency` / `max_retries` / `include_baseline`.
94
+
95
+
### Declaring custom parameters — add via `additional_parameters`
96
+
97
+
The base `Scenario` composes `supported_parameters()` as `_common_scenario_parameters() + additional_parameters()`. To add your own parameters, override **`additional_parameters()`** and return just your extras — the common inputs are included for you, so there's no `super()` call to forget:
-**Add (common case):** override `additional_parameters` and return `[Parameter(...)]`
108
+
-**Remove / replace a common input (rare):** override `supported_parameters` directly and compose against `super()`, e.g. `return [p for p in super().supported_parameters() if p.name != "dataset_config"]`
109
+
110
+
Dropping a common input is not silent: `set_params_from_args` rejects any value supplied for an undeclared parameter, so the registry/CLI/programmatic path fails loudly. If a scenario resolves its strategies differently (e.g. pairing attacks with converters), override the `_resolve_scenario_strategies` hook rather than `initialize_async` (see `RedTeamAgent`).
111
+
84
112
## Dataset Loading
85
113
86
114
Datasets are read from `CentralMemory`.
@@ -272,6 +300,8 @@ New scenarios must be registered in `pyrit/scenario/__init__.py` as virtual pack
272
300
## Common Review Issues
273
301
274
302
- Accessing `self._objective_target` or `self._scenario_strategies` before `initialize_async()`
303
+
- Overriding `supported_parameters()` without composing against `super()` (silently drops the common run inputs)
304
+
- Adding arguments back onto `initialize_async` instead of declaring them via `supported_parameters()` and reading from `self.params`
0 commit comments