Skip to content

Include ordered parameter bindings in TemplateSegmentConverter identity - #3972

Closed
Santosh Todkar (todkarsant) wants to merge 1 commit into
microsoft:mainfrom
todkarsant:fix/template-converter-identity-3902
Closed

Santosh Todkar (todkarsant) wants to merge 1 commit into
microsoft:mainfrom
todkarsant:fix/template-converter-identity-3902

Conversation

@todkarsant

Copy link
Copy Markdown

Summary

  • Fixes BUG: TemplateSegmentConverter omits ordered parameter bindings from identity #3902: TemplateSegmentConverter uses the ordered parameters list to map consecutive prompt segments to template placeholders via dict(zip(parameters, segments)). Reversing the parameter list changes the rendered output, but the component identifier previously included only the template text hash, parameter count, and seed -- so two converters with different parameter orderings produced identical identities, preventing both from being registered.
  • Adds ordered_parameters to the identifier's params dict so that different orderings yield distinct identities.
  • Adds three tests verifying: different orderings produce different identifiers, same orderings produce the same identifier, and the ordered_parameters key is present in the identifier params.

Test plan

  • All existing tests in test_template_segment_converter.py continue to pass
  • New test: different parameter orderings produce different identifiers
  • New test: identical parameter orderings produce the same identifier
  • New test: ordered_parameters key is present in identifier params with correct value

🤖 Generated with Claude Code

TemplateSegmentConverter uses the ordered parameters list to assign
consecutive prompt segments via dict(zip(parameters, segments)).
Reversing that list changes the rendered text, but the identifier
previously included only the template text hash, parameter count, and
seed. Both configurations got the same registry name, preventing
registration of both.

Add ordered_parameters to the identifier params dict so that different
orderings produce distinct identities.

Fixes microsoft#3902

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 5, 2026 05:14

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 include ordered parameter bindings in converter identity.

No open issues 🎉

What changed in this PR

Addresses #3902 by including ordered parameter bindings in TemplateSegmentConverter identity, allowing converters with different bindings to receive distinct hashes and default registry names without changing prompt rendering.

Changes:

  • Adds ordered_parameters to identifier parameters.
  • Adds three tests covering different orderings, identical configurations, and the stored parameter list.
File Description
tests/​unit/​converter/​test_template_segment_converter.py Adds regression tests for order-sensitive converter identity.
pyrit/​converter/​template_segment_converter.py Includes ordered parameter names in the identifier and explains their significance.

Review effort: Balanced

@todkarsant

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@romanlutz

Copy link
Copy Markdown
Contributor

Duplicate of #3905

@romanlutz Roman Lutz (romanlutz) marked this as a duplicate of #3905 Nov 5, 2026
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: TemplateSegmentConverter omits ordered parameter bindings from identity

3 participants