Skip to content

FIX: Record turn, retry and request limits in attack identifiers - #4823

Open
barkha1research-ai wants to merge 11 commits into
microsoft:mainfrom
barkha1research-ai:fix-attack-budget-identity
Open

barkha1research-ai wants to merge 11 commits into
microsoft:mainfrom
barkha1research-ai:fix-attack-budget-identity

Conversation

@barkha1research-ai

Copy link
Copy Markdown
Contributor

Description

Fixes #4822.

CrescendoAttack, RedTeamingAttack, PromptSendingAttack and ChunkedRequestAttack did 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 and get_cached_results_for_technique match on that eval hash, so they treated a 3-turn and a 20-turn Crescendo as the same technique.

This change:

  • Adds 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.
  • Adds _build_identifier to:
    • CrescendoAttack: max_turns, max_backtracks
    • RedTeamingAttack: max_turns, score_last_turn_only
    • PromptSendingAttack: max_attempts_on_failure, inherited by SkeletonKeyAttack and ManyShotJailbreakAttack
    • ChunkedRequestAttack: chunk_size, total_length

Values equal to the defaults are left out, as _create_identifier does for use_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

  • Among the built-in techniques, best_of_n (19 retries), goat (5 turns) and violent_durian (3 turns) get new hashes. The other built-in techniques keep theirs.
  • Techniques run with non-default limits get new hashes, for example through the max_turns parameter of AssertPolicy, Scam, Psychosocial or AggregationLeakage, or Psychosocial's max_backtracks=1.
  • The technique.execute scenario raises max_turns by 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.
  • A scenario started before this change with non-default limits cannot be resumed after it, because its planned atomic groups are keyed by the technique hash.
  • Results that runs with non-default limits stored before this change keep the old hash, so they still match default runs.

ManyShotJailbreakAttack and ChunkedRequestAttack content settings are not included, as described in the issue.

Tests and Documentation

  • tests/unit/executor/attack/core/test_attack_strategy.py: _non_default_params returns 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 (for PromptSendingAttack, SkeletonKeyAttack and ManyShotJailbreakAttack) and test_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 in max_attempts_on_failure get different technique_eval_hash and logical_group_id values.

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.

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>
Copilot AI balanced review requested due to automatic review settings December 3, 2026 13:20

Copilot AI 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.

🟢 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

No deployments
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.

BUG: Attack identifiers leave out turn, retry and request limits, so differently budgeted runs share an eval hash

3 participants