Skip to content

FIX: Deep-copy seed metadata when converting SeedGroup prompts to messages - #4078

Open
电大老baby (HhH666-ux) wants to merge 1 commit into
microsoft:mainfrom
HhH666-ux:fix-seed-group-metadata-copy
Open

电大老baby (HhH666-ux) wants to merge 1 commit into
microsoft:mainfrom
HhH666-ux:fix-seed-group-metadata-copy

Conversation

@HhH666-ux

Copy link
Copy Markdown

Description

SeedGroup._prompts_to_messages passed the seed's metadata mapping directly to the derived MessagePiece, so nested values were shared between the seed and every extracted message. Mutating a derived message's metadata therefore also changed the source seed and later extractions.

  • Deep-copy the seed metadata before assigning it to the new message piece.
  • Add a regression test that mutates nested metadata on history and next-message pieces and asserts the source seeds and subsequent extractions stay unchanged.

Fixes #3899

Copilot AI balanced review requested due to automatic review settings November 9, 2026 03:56

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 recorded for the change isolating seed metadata from message mutations.

No open issues 🎉

What changed in this PR

Fixes #3899 by isolating metadata when SeedGroup converts seed prompts into messages, preventing nested message metadata mutations from affecting source seeds.

Changes:

  • Deep-copy seed metadata at the seed-to-message boundary.
  • Add a regression test covering history and next-message mutations, unchanged source seeds, and a subsequent history extraction.
File Description
tests/​unit/​models/​test_seed_group.py Adds regression coverage for nested metadata isolation.
pyrit/​models/​seeds/​seed_group.py Deep-copies metadata when constructing message pieces.

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: SeedGroup messages share nested metadata with source seeds

2 participants