Repository navigation
FIX: Record turn, retry and request limits in attack identifiers - #4823
Open
barkha1research-ai wants to merge 11 commits into
Open
barkha1research-ai wants to merge 11 commits into
barkha1research-ai wants to merge 11 commits into
Conversation
Signed-off-by: Barkha <340367068+barkha1research-ai@users.noreply.github.com>
Signed-off-by: Barkha <340367068+barkha1research-ai@users.noreply.github.com>
Signed-off-by: Barkha <340367068+barkha1research-ai@users.noreply.github.com>
…fier Signed-off-by: Barkha <340367068+barkha1research-ai@users.noreply.github.com>
Signed-off-by: Barkha <340367068+barkha1research-ai@users.noreply.github.com>
Signed-off-by: Barkha <340367068+barkha1research-ai@users.noreply.github.com>
Signed-off-by: Barkha <340367068+barkha1research-ai@users.noreply.github.com>
Signed-off-by: Barkha <340367068+barkha1research-ai@users.noreply.github.com>
Signed-off-by: Barkha <340367068+barkha1research-ai@users.noreply.github.com>
Signed-off-by: Barkha <340367068+barkha1research-ai@users.noreply.github.com>
Signed-off-by: Barkha <340367068+barkha1research-ai@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the changes that distinguish attacks by execution limits.
No open issues 🎉
What changed in this PR
Distinguishes attacks with different execution limits so adaptive selection, cached results, and resume grouping no longer treat them as equivalent.
Changes:
- Records non-default turn, backtrack, retry, and request limits in attack identifiers.
- Resolves constructor defaults through inheritance, preserving default-configuration hashes.
- Adds regression tests for identifiers, evaluation hashes, and atomic grouping.
| File | Description |
|---|---|
tests/unit/scenario/core/test_atomic_attack.py |
Tests retry-sensitive evaluation hashes and group IDs. |
tests/unit/executor/attack/single_turn/test_prompt_sending.py |
Tests retry identity across three attack classes. |
tests/unit/executor/attack/multi_turn/test_red_teaming.py |
Tests turn-limit and scoring-mode identity. |
tests/unit/executor/attack/multi_turn/test_crescendo.py |
Tests turn and backtrack identity. |
tests/unit/executor/attack/multi_turn/test_chunked_request.py |
Tests request-limit identity. |
tests/unit/executor/attack/core/test_attack_strategy.py |
Tests default resolution and inherited settings. |
pyrit/executor/attack/single_turn/prompt_sending.py |
Records non-default retry limits. |
pyrit/executor/attack/multi_turn/red_teaming.py |
Records non-default turn limits and scoring mode. |
pyrit/executor/attack/multi_turn/crescendo.py |
Records non-default turn and backtrack limits. |
pyrit/executor/attack/multi_turn/chunked_request.py |
Records non-default chunk size and total length. |
pyrit/executor/attack/core/attack_strategy.py |
Adds inheritance-aware filtering of default parameters. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #4822.
CrescendoAttack,RedTeamingAttack,PromptSendingAttackandChunkedRequestAttackdid not record the settings that limit how often they call the objective target, so attacks that differ only in those settings shared a hash and an eval hash. The adaptive scenario, its epsilon-greedy selector andget_cached_results_for_techniquematch on that eval hash, so they treated a 3-turn and a 20-turn Crescendo as the same technique.This change:
AttackStrategy._non_default_params, which returns the given values that differ from their constructor defaults. Each default is read from the nearest class in the MRO whose__init__declares the parameter, so a subclass with its own default is compared with that default, and a subclass that does not re-declare the parameter is compared with its parent's._build_identifierto:CrescendoAttack:max_turns,max_backtracksRedTeamingAttack:max_turns,score_last_turn_onlyPromptSendingAttack:max_attempts_on_failure, inherited bySkeletonKeyAttackandManyShotJailbreakAttackChunkedRequestAttack:chunk_size,total_lengthValues equal to the defaults are left out, as
_create_identifierdoes foruse_score_as_feedback, so default configurations keep their hashes and stored results stay reusable. TAP records its search settings even at their defaults; doing the same here would change every hash of these attacks once. The values are identifier params in the existing identifier JSON, so there is no schema change or migration.Hash changes
best_of_n(19 retries),goat(5 turns) andviolent_durian(3 turns) get new hashes. The other built-in techniques keep theirs.max_turnsparameter ofAssertPolicy,Scam,PsychosocialorAggregationLeakage, orPsychosocial'smax_backtracks=1.technique.executescenario raisesmax_turnsby the number of prepended turns (AttackTechniqueFactory.with_extra_turns), so a run with prepended history now records the raised limit and has a different technique hash from the same technique without history.ManyShotJailbreakAttackandChunkedRequestAttackcontent settings are not included, as described in the issue.Tests and Documentation
tests/unit/executor/attack/core/test_attack_strategy.py:_non_default_paramsreturns None when every value is a default, returns only changed values, compares against a subclass's own default, falls back to the parent's default for subclasses with a narrower signature or**kwargs, and keeps names no class declares.test_crescendo.py,test_red_teaming.py,test_prompt_sending.py(forPromptSendingAttack,SkeletonKeyAttackandManyShotJailbreakAttack) andtest_chunked_request.py: default and explicitly default settings leave the identifier unchanged; non-default settings are recorded and change both the hash and the eval hash.tests/unit/scenario/core/test_atomic_attack.py: atomic attacks that differ only inmax_attempts_on_failureget differenttechnique_eval_hashandlogical_group_idvalues.19 of the 25 new tests fail on
main; the other 6 check that default hashes do not move. The full unit suite has no new failures. No docs or notebooks changed, so JupyText was not needed.