Skip to content

FIX: preserve source_response_id when branching an attack via create_attack_async - #4677

Open
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
microsoft:mainfrom
ManoharPaturi:fix/create-attack-source-response-id
Open

Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
microsoft:mainfrom
ManoharPaturi:fix/create-attack-source-response-id

Conversation

@ManoharPaturi

Copy link
Copy Markdown
Contributor

Description

Fixes #4674

AttackService.create_attack_async now passes the unremapped original source pieces up to cutoff_index to ChatScoringService.continue_manually when branching from an automated attack, so manual_continuation.source_response_id is preserved instead of always being None.

  • load the source conversation messages when source resolves in create_attack_async and filter pieces to message.sequence <= request.cutoff_index
  • pass those original retained_pieces (with "assistant" roles and source UUIDs intact) to continue_manually, matching AttackService._save_conversation_async
  • leave _prepare_conversation_up_to_async unchanged so copied messages still receive simulated roles and fresh UUIDs

Before, branching from an automated attack at cutoff_index=1 where turn 1 is an assistant reply:

manual_continuation.source_attack_result_id: ""
manual_continuation.source_conversation_id: ""
manual_continuation.source_response_id: None

After, on the same branch request:

manual_continuation.source_attack_result_id: ""
manual_continuation.source_conversation_id: ""
manual_continuation.source_response_id: ""

…attack_async

Signed-off-by: ManoharPaturi <186662190+ManoharPaturi@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 18:32

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 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

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.

AttackService.create_attack_async loses manual_continuation.source_response_id when branching from an automated attack

2 participants