Skip to content

FEAT: Adding PyRITInitializer parameters#1456

Open
rlundeen2 wants to merge 8 commits intoAzure:mainfrom
rlundeen2:users/rlundeen/2026_03_10_initializer_tags
Open

FEAT: Adding PyRITInitializer parameters#1456
rlundeen2 wants to merge 8 commits intoAzure:mainfrom
rlundeen2:users/rlundeen/2026_03_10_initializer_tags

Conversation

@rlundeen2
Copy link
Contributor

Previously, initializer configuration (like target tags) was passed through constructor arguments, which didn't
translate cleanly to YAML config or CLI usage. This unifies the approach so parameters flow the same way regardless
of entry point.

This change adds a uniform params system for PyRIT initializers that works consistently across YAML config, CLI, and the
programmatic API.

What changed:

  • New InitializerParameter dataclass for initializers to declare their supported parameters (name, description,
    required, default)
  • initialize_async() now accepts an optional params: dict[str, list[str]] argument
  • Parameter values are lists of strings, mapping naturally to YAML lists, CLI comma-separated values, and direct
    API usage
  • CLI supports name:key=val1,val2 syntax (e.g., --initializers target:tags=default,scorer)
  • Validation rejects unknown params and enforces required params
  • TargetInitializer and ScorerInitializer migrated from constructor-based tags to the new params system
  • InitializerMetadata now exposes supported_parameters for discoverability
  • Backward-compatible with old-style initializers that don't accept params

rlundeen2 and others added 7 commits March 10, 2026 15:57
Add a dict[str, str] params system for PyRIT initializers that works
uniformly across YAML config, CLI, and the programmatic API.

Key changes:
- Add InitializerParameter dataclass for declaring supported params
- Add params: dict[str, str] | None to initialize_async signature
- Migrate TargetInitializer/ScorerInitializer from constructor tags to
  params-based (tags as comma-separated string)
- Update ConfigurationLoader to set _params instead of constructor kwargs
- Update FrontendCore with _initializer_configs and name:key=val;key2=val2
  CLI syntax for passing params
- Add param validation (ValueError on unknown/missing required params)
- Backward-compatible with old-style initializer scripts (no params arg)
- Update InitializerMetadata with supported_parameters for discovery
- Add comprehensive tests (294 passing)
- Update documentation and .pyrit_conf_example

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…list[str]]

Each parameter value is now a list of strings, which maps naturally to:
- YAML: native list syntax under args
- CLI: comma-separated values (tags=default,scorer -> ['default', 'scorer'])
- Programmatic API: direct list passing

This eliminates the need for comma-separated string parsing inside
initializers and provides a cleaner, more uniform API.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add name:key=val1,val2 syntax hints to --initializers help in shell.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Simple name: "simple" → {"name": "simple"}
- Name with params: "target:tags=default,scorer" → {"name": "target", "args": {"tags": "default,scorer"}}

For multiple params, separate with semicolons: "name:key1=val1;key2=val2"
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe this is not common and I don't have a solution for this but this has the potential to get long esp if a user has many initializers with many tags

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Potentially! But I hope people use the config, and also I could see this shortening things in some cases (e.g. something that would otherwise take several initializers can use an argument).

Run Command Options:
--initializers <name> ... Built-in initializers to run before the scenario
--initializers <name> ... Built-in initializers (supports name:key=val1,val2 syntax)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused by that syntax. Do you have an example?

Copy link
Contributor

Choose a reason for hiding this comment

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

Found target:tags=default,scorer below. But what if there are multiple?

Comment on lines 40 to -38
# - simple
# - name: airt
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be name: simple?

Also, why is airt removed?

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