Repository navigation
FIX: preserve source_response_id when branching an attack via create_attack_async - #4677
Open
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
Conversation
…attack_async Signed-off-by: ManoharPaturi <186662190+ManoharPaturi@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change to preserve original assistant response IDs when creating manual branches.
No open issues 🎉
What changed in this PR
Fixes #4674 by preserving the original assistant response ID when creating a manual branch from an automated attack.
Changes:
- Passes original source pieces within the cutoff to continuation tracking, while leaving copied-message roles and UUIDs unchanged.
- Adds regression coverage for cutoffs that include or exclude assistant responses.
| File | Description |
|---|---|
tests/unit/backend/test_attack_service.py |
Verifies source attack, conversation, and response IDs for both cutoff cases. |
pyrit/backend/services/attack_service.py |
Uses original source pieces to preserve continuation provenance. |
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 #4674
AttackService.create_attack_asyncnow passes the unremapped original source pieces up tocutoff_indextoChatScoringService.continue_manuallywhen branching from an automated attack, somanual_continuation.source_response_idis preserved instead of always beingNone.sourceresolves increate_attack_asyncand filter pieces tomessage.sequence <= request.cutoff_indexretained_pieces(with"assistant"roles and source UUIDs intact) tocontinue_manually, matchingAttackService._save_conversation_async_prepare_conversation_up_to_asyncunchanged so copied messages still receive simulated roles and fresh UUIDsBefore, branching from an automated attack at
cutoff_index=1where turn 1 is an assistant reply:After, on the same branch request: