Repository navigation
Description
Describe the bug
TemplateSegmentConverter uses the ordered SeedPrompt.parameters list to assign consecutive prompt segments. Reversing that list changes the rendered text, but the identifier includes only the template text hash, parameter count, and seed. Both configurations therefore have the same default registry name, preventing automatic registration of both.
This is not reordering keyword arguments. It is reordering the list used by dict(zip(parameters, segments)).
Source: pyrit/converter/template_segment_converter.py:76-90,110-116 at the tested revision.
Steps/Code to Reproduce
import asyncio
from pyrit.models import SeedPrompt
from pyrit.registry import ConverterRegistry
async def main():
registry = ConverterRegistry()
template = "LEFT[{{left}}] RIGHT[{{right}}]"
first = registry.create_named_instance(
name="source", type_name="TemplateSegmentConverter",
params={
"prompt_template": SeedPrompt(value=template, parameters=["left", "right"]),
"seed": 7,
},
)
second = registry.recreate_instance(
source=first,
params={"prompt_template": SeedPrompt(value=template, parameters=["right", "left"])},
)
print((await first.convert_async(prompt="alpha beta")).output_text)
print((await second.convert_async(prompt="alpha beta")).output_text)
print(first.get_identifier().hash == second.get_identifier().hash)
automatic_names = ConverterRegistry()
automatic_names.instances.register(first)
automatic_names.instances.register(second)
asyncio.run(main())Expected Results
Given the existing ordered-binding behavior, include the ordered parameter names in identity, so differing bindings have distinct hashes/default registry names. Do not silently sort the bindings and change existing prompt output. Document the one-time identifier/name change.
Actual Results
LEFT[alpha] RIGHT[beta]
LEFT[beta] RIGHT[alpha]
True
The registry reproduction rejects the second default-name registration with ValueError: Instance 'TemplateSegmentConverter::cad7c569' already exists.
Related #3717 concerns the same class of identity problem in a different converter. The broader registry-wide test proposal #3477 is closed and does not specifically report these ordered bindings. #2839 concerns short-input sampling, and #3339 changes a different converter's template representation.
Screenshots
N/A.
Versions
Linux; Python 3.12; PyRIT 1.2.0.dev0 at 01ce6ca66a315770b36c7dca1f320668c0d92d7c. Actual SDK/registry reproduction without mocks, network, or inference. Two words and two parameters force a single split; no evolving RNG state is needed. Full package-version output was not collected.
Activity
romanlutz commentedon Nov 5, 2026
Hrushikesh Ramilla (@Hrushikesh-ramilla) and Santosh Todkar (@todkarsant) please check before opening PRs. For both of you and 小卡塔克 (@Goldloli): try to claim an issue with a comment BEFORE you start work. That way, nobody has to waste time and effort. There are literally dozens of open issues and we don't need to claim the same ones multiple times. Thanks.