FIX: Prune emptied atomic attacks on scenario resume#2210
Open
romanlutz wants to merge 1 commit into
Open
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 52d2518d-ebe5-4888-8189-6146b6503448
behnam-o
approved these changes
Jul 16, 2026
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
On resume,
Scenario._apply_persisted_objectivesrestricts each atomic attack's seed groups to the persisted objective subset viakeep_seed_groups_with_hashes. For scenarios that build one atomic attack per objective (for exampleAdaptiveScenario/TextAdaptive, where every seed group becomes its ownAtomicAttack), any atomic attack whose single objective falls outside the persisted subset gets pruned down to zero seed groups. Before this fix those emptied atomic attacks stayed inself._atomic_attacksand would be scheduled with nothing to run.This change collects only the atomic attacks that still have seed groups after pruning into a
retained_attackslist and reassignsself._atomic_attacks, so emptied attacks no longer linger. Bulk scenarios (a single atomic attack holding all objectives) are unaffected, since their one attack never empties as long as at least one persisted objective survives, which is why the bug stayed latent until the per-objective (adaptive) shape hit resume.Tests and Documentation
test_resume_discards_per_objective_attacks_outside_persisted_subsetintests/unit/scenario/core/test_scenario.py. It uses a per-objective scenario stand-in to assert that emptied atomics are dropped on resume and that every retained atomic still carries its seed groups.tests/unit/scenario/core/test_scenario.pypasses in full (57 passed).doc/code/scenarios/3_adaptive_scenarios.py. It currently fails at cell In[3] due to a pre-existingmainregression that is unrelated to this change: thefliptechnique sets a system-prompt seed at sequence 0 which collides with the objective's user prompt at sequence 0, raisingValidationError: Inconsistent roles found for sequence 0: {'system', 'user'}. That failure is on the fresh-run build path, not the resume-prune path touched here.