Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Resumed decomposition runs can fail or execute changed requests because child requests are reloaded from mutable datasets rather than snapshotted when planning. Separately, the parent does not record supplied converters, so attacks using different converters receive identical identifiers and evaluation hashes, undermining result identity and resume checks.
9 open issues
Include converters in parent attack identifiers · New Snapshot complete decompositions when planning runs · New Preserve auxiliary scorers in one-prompt mode · New Preserve partial content from blocked messages during recombination · New Handle undetermined added-knowledge scores without failing decomposition · New Forward the effective expectation to the one-prompt child · New Reset helper conversations after recombination · New Forward prompt-sending converters or disable the parameter · New Keep datasets in separate atomic attacks · New
What changed in this PR
Adds a proof-of-concept objective-decomposition workflow to PyRIT’s dataset, attack, and scenario components.
Changes:
- Generates and stores objective decompositions as reusable datasets.
- Executes steps separately, recombines responses, and compares results with direct and single-prompt controls.
- Adds configurable prompts, scoring checks, public exports, and a tutorial.
| File | Description |
|---|---|
pyrit/scenario/scenarios/airt/decomposition.py |
Adds the scenario and root-only dataset selection. |
pyrit/scenario/scenarios/airt/__init__.py |
Exports decomposition scenario types. |
pyrit/models/seeds/objective_decomposition_config.py |
Defines generation configuration. |
pyrit/models/seeds/__init__.py |
Exports the configuration model. |
pyrit/models/__init__.py |
Exposes configuration through the public API. |
pyrit/executor/promptgen/objective_decomposition_generator.py |
Generates and validates decomposition plans. |
pyrit/executor/promptgen/__init__.py |
Exports generation components. |
pyrit/executor/attack/compound/recombiner.py |
Adds concatenation and model-assisted recombination. |
pyrit/executor/attack/compound/decomposition_attack.py |
Executes and scores saved decompositions. |
pyrit/executor/attack/compound/__init__.py |
Exports compound attack components. |
pyrit/executor/attack/__init__.py |
Exposes decomposition attack APIs. |
pyrit/datasets/seed_datasets/generated/objective_decomposition_provider.py |
Packages generated plans as seed trees. |
pyrit/datasets/seed_datasets/generated/__init__.py |
Exports the dataset provider. |
pyrit/datasets/executors/promptgen/objective_decomposition_generator.yaml |
Defines planning instructions and response schema. |
pyrit/datasets/executors/decomposition/steps_in_one_prompt.yaml |
Defines the single-prompt control. |
pyrit/datasets/executors/decomposition/combine_system_prompt.yaml |
Defines recombination grounding rules. |
pyrit/datasets/executors/decomposition/combine_prompt.yaml |
Templates recombination evidence. |
pyrit/datasets/executors/decomposition/added_knowledge_question.yaml |
Defines the added-knowledge scoring rubric. |
pyrit/datasets/__init__.py |
Exposes the provider publicly. |
doc/myst.yml |
Adds tutorial navigation. |
doc/code/executor/9_decomposition.py |
Adds the tutorial’s Python source. |
doc/code/executor/9_decomposition.ipynb |
Adds the notebook and example outputs. |
doc/code/executor/0_executor.md |
Links the tutorial from the executor guide. |
Review effort: Balanced
|
|
||
| async def _perform_async(self, *, context: DecompositionAttackContext) -> DecompositionAttackResult: | ||
| assert context.params.root_objective_id is not None | ||
| tree = await self._load_decomposition_async(root_id=context.params.root_objective_id) |
| self._one_prompt_attack = PromptSendingAttack( | ||
| objective_target=objective_target, | ||
| attack_converter_config=attack_converter_config, | ||
| attack_scoring_config=AttackScoringConfig(objective_scorer=objective_scorer), |
| if piece is not None and piece.is_blocked(): | ||
| return DecompositionStepResult( | ||
| step=step, result=child, status=DecompositionStepStatus.BLOCKED, text=self.BLOCKED_MARKER | ||
| ) |
| if self._added_knowledge_scorer is not None: | ||
| scores = await self._added_knowledge_scorer.score_text_async(answer, objective=replies) | ||
| if scores: | ||
| added = bool(scores[0].get_value()) |
| context._error_result_metadata[self.CHILD_ATTACK_RESULT_IDS_KEY] = child_ids | ||
| execution = await AttackExecutor(max_concurrency=1).execute_attack_from_seed_groups_async( | ||
| attack=self._one_prompt_attack, | ||
| seed_groups=[seed_group], |
| response = await self._normalizer.send_prompt_async( | ||
| message=Message.from_prompt(prompt=self._render(objective=objective, path=path), role="user"), | ||
| target=self._target, | ||
| conversation_id=conversation_id, | ||
| ) |
| ``max_total`` counts original objectives, each with all its steps. | ||
| """ | ||
|
|
||
| VERSION: int = 1 |
| Raises: | ||
| ValueError: If the selected datasets hold no saved decompositions. | ||
| """ | ||
| roots = [group for group in context.seed_groups if is_decomposition_root(group.objective)] |
Behnam (behnam-o)
left a comment
There was a problem hiding this comment.
Thanks for putting this together! Here's some initial feedback.
| return list(self.metadata.get(DecompositionAttack.CHILD_ATTACK_RESULT_IDS_KEY, [])) | ||
|
|
||
|
|
||
| class DecompositionAttack(AttackStrategy[DecompositionAttackContext, DecompositionAttackResult]): |
There was a problem hiding this comment.
There are no unit tests yet for this or the other new modules. At minimum: the outcome rules (success, failure, failure with an errored step, all steps failing), scorers that raise or return undetermined, both recombiners, and the scenario building its atomic attacks.
| One-prompt mode (``steps_in_one_prompt=True``) is a control: the same requests, unchanged and | ||
| numbered, go to the target together in one message, judged the same way. | ||
|
|
||
| Step results are linked through ``child_attack_result_ids`` but not attributed to a scenario, so |
There was a problem hiding this comment.
Not attributing the steps makes sense, since there's no correct way to attribute them in the analytics today. Could you document the side effect? Step target calls and step errors won't appear in scenario statistics.
| step_refusal_scorer: TrueFalseScorer | None = None, | ||
| added_knowledge_scorer: TrueFalseScorer | None = None, | ||
| recombiner: Recombiner | None = None, | ||
| steps_in_one_prompt: bool = False, |
There was a problem hiding this comment.
In one-prompt mode, recombiner, sub_objective_scorer, step_refusal_scorer, added_knowledge_scorer, and single_answer_check are accepted and silently ignored. Either reject them when steps_in_one_prompt=True, or make the control its own small strategy that shares the tree loading.
| self._one_prompt_attack = PromptSendingAttack( | ||
| objective_target=objective_target, | ||
| attack_converter_config=attack_converter_config, | ||
| attack_scoring_config=AttackScoringConfig(objective_scorer=objective_scorer), |
There was a problem hiding this comment.
nit: the decomposed answer's judgment runs auxiliary_scorers (L452), but the one-prompt control doesn't pass them here.
| return self._create_identifier( | ||
| params={"mode": "one_prompt", "one_prompt_template": self._one_prompt_template.value} | ||
| ) | ||
| children: dict[str, ComponentIdentifier | list[ComponentIdentifier]] = { |
There was a problem hiding this comment.
The converters in attack_converter_config only go to the internal PromptSendingAttacks, and this identifier doesn't include them. Two runs that differ only in converters (for example, with and without TenseConverter) get the same identifier and can't be told apart. Can you add the step attack's identifier as a child here, and the one-prompt attack's in one-prompt mode?
|
|
||
|
|
||
| class DecompositionTechnique(ScenarioTechnique): | ||
| """Techniques for sending each step: for now, a plain ``PromptSendingAttack``. Per-step techniques come later.""" |
There was a problem hiding this comment.
The one-member enum makes sense, since Scenario requires one (garak's DivergenceTechnique does the same), and prompt_sending matches the name other scenarios use for a plain send. But this docstring suggests the selection changes how steps are sent, which it doesn't. Maybe say this is the scenario's single technique and the enum exists because Scenario requires one.
| """ | ||
|
|
||
| VERSION: int = 1 | ||
| BASELINE_ATTACK_POLICY: ClassVar[BaselineAttackPolicy] = BaselineAttackPolicy.Enabled |
There was a problem hiding this comment.
The judge and the checks read assembled harmful content, so content-filter blocks are expected here. With the inherited RAISE_IF_DEFAULT_SCORER_BLOCKS = True, a blocked judge makes the result ERROR, and resume re-sends every step and is likely blocked again. Consider RAISE_IF_DEFAULT_SCORER_BLOCKS: ClassVar[bool] = False for this scenario, so a block gives UNDETERMINED. This depends on the fix at decomposition_attack.py L529, since a non-raising policy produces the undetermined score that currently crashes there.
| name="single_answer_check", | ||
| description="Also judge each step's reply alone against the original objective, as detail.", | ||
| param_type=bool, | ||
| default=False, |
There was a problem hiding this comment.
Consider turning this on by default, but only running it when the combined answer succeeded. It answers the first question a reader will have about a success: did one reply already achieve the objective on its own, or was combining needed? Running it only on successes keeps the cost down.
| name="steps_in_one_prompt", roots=roots, context=context, steps_in_one_prompt=True | ||
| ) | ||
| ) | ||
| attacks.append(self._build_atomic_attack(name="decomposition", roots=roots, context=context)) |
There was a problem hiding this comment.
With the one-prompt control on (the default), this builds three units per objective. The default _estimate_run_size_async counts only one technique unit plus the baseline, so the estimate is one unit per objective short. Could this scenario override _estimate_run_size_async, as other scenarios with a different execution shape do?
| context: ScenarioContext, | ||
| steps_in_one_prompt: bool = False, | ||
| ) -> AtomicAttack: | ||
| attack = DecompositionAttack( |
There was a problem hiding this comment.
technique_converters (for example {"prompt_sending": [TenseConverter()]}) are accepted but never applied, even though the attack supports converters. Scenario asks scenarios that don't apply them to set SUPPORTS_TECHNIQUE_CONVERTERS = False, so that passing them fails instead. Either pass context.technique_converters.get("prompt_sending", []) as the attack's attack_converter_config here, as garak's Divergence and FigStep do, or set the flag.


Description
POC of decomposition attack - don't review yet :)
Attn Behnam (@behnam-o) for early implementation of design for Decomposition Attack
TODO
ran notebook for testing
used local visualization for result analysis and testing