Repository navigation
FIX: Keep a scenario running after an objective-specific error - #4829
Behnam (behnam-o) wants to merge 1 commit into
Conversation
A scenario stopped starting atomic attacks as soon as any objective errored, so one bad objective, such as a garbled adversarial reply, left every unstarted atomic attack without results. Classify each failed objective's error chain instead. New atomic attacks stop only for errors every remaining objective would hit: rejected credentials, a missing model or deployment, connection failures and timeouts, and rate-limit or server errors that outlast the target's retries. As a safety net, the same root error failing three distinct objectives also stops them. Other errors stay on their objective; the run still ends failed and resume re-runs only those objectives. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The failure tracker can stop valid queued attacks when a single prompt introduces an invalid HTTP header, because it treats LocalProtocolError as a system-wide failure. Separately, when attack execution and error-result persistence both fail, authentication or connection errors wrapped in an ExceptionGroup are missed, allowing the scenario to keep starting atomic attacks despite a system-wide failure.
2 open issues
What changed in this PR
Changes PyRIT scenario scheduling to continue after objective-specific errors, complementing #4298’s retry/resume ordering fix.
Changes:
- Adds failure classification and a three-objective repeated-error stopping threshold.
- Adds regression coverage for continuation, stopping, and selective resume.
- Updates resiliency documentation and flowcharts.
| File | Description |
|---|---|
tests/unit/scenario/core/test_scenario.py |
Tests scenario continuation and stopping conditions. |
tests/unit/scenario/core/test_scenario_retry.py |
Tests resuming only errored objectives. |
tests/unit/scenario/core/test_objective_failure_tracker.py |
Tests error classification and repeated-failure tracking. |
pyrit/scenario/core/scenario.py |
Uses the tracker to decide whether to start more attacks. |
pyrit/scenario/core/_objective_failure_tracker.py |
Implements failure classification and tracking. |
doc/code/scenarios/0_scenarios.py |
Updates resiliency explanations and flowchart comments. |
doc/code/scenarios/0_scenarios.ipynb |
Mirrors the documentation updates in the notebook. |
Review effort: Balanced
| system_wide_types = ( | ||
| ClientAuthenticationError, | ||
| APIConnectionError, | ||
| httpx.TransportError, |
| if isinstance(error, system_wide_types): | ||
| return True |
|
I think a better policy may be, once an atomic attack reports an execution error, stop starting new attacks, let in-flight work finish, and let https://microsoft.github.io/PyRIT/latest/code/setup/resiliency/ |

Description
A scenario stopped starting new atomic attacks as soon as any objective errored, whatever the error. A single objective-specific failure, such as a garbled adversarial reply that later fails prompt hashing with
UnicodeEncodeError, left every unstarted atomic attack without results, and a resume could stop again at the next such error. This keeps the run going and stops early only for errors that every remaining objective would hit.ObjectiveFailureTracker. It follows each failed objective's error chain past the attack's wrapper, because neither the component label norPyritException.status_codeis reliable. New atomic attacks stop for:FAILEDwithScenarioPartialFailureException, and resume re-runs only the objectives that errored. An atomic attack that raises outright still stops new attacks, as before.Related: #4158, and #4298, which runs unstarted attacks before failed ones on resume. This PR changes the stop rule within a single run.
Before / After. The reproduction uses two atomic attacks (
first: objectives A and B;second: objective C), withmax_concurrency=1andmax_retries=0. The target's reply to B contains a lone surrogate, so storing it raisesUnicodeEncodeError, labeledobjective_target. The script then resumes the same scenario against a healthy target.If the target returns a 401 for B instead, both versions stop before
second. The new version logs why:Scenario '...' won't start further atomic attacks: an objective failed with a system-wide error (AuthenticationError: ...).🤖 Generated with Claude Code