Skip to content

BUG: PolicyPuppetryConverter identifies a custom template by its name only #3759

Closed

Description

@Ayoubhm07

Describe the bug

PolicyPuppetryConverter._build_identifier records only the template name (policy_puppetry_converter.py:103). A custom SeedPrompt usually has no name, so two converters that wrap the prompt in different templates share one hash and one default registry name. Found by the registry-wide identifier test from #3477.

Steps/Code to Reproduce

Run on main at 791e12c6e.

import asyncio

from pyrit.converter import PolicyPuppetryConverter
from pyrit.models import SeedPrompt
from pyrit.setup import IN_MEMORY, initialize_pyrit_async


async def main() -> None:
    await initialize_pyrit_async(memory_db_type=IN_MEMORY, silent=True)
    for value in ("<policy>{{ prompt }}</policy>", "<config>allow: {{ prompt }}</config>"):
        converter = PolicyPuppetryConverter(prompt_template=SeedPrompt(value=value, parameters=["prompt"]))
        result = await converter.convert_async(prompt="hello")
        print(result.output_text, converter.get_identifier().unique_name)


asyncio.run(main())

Expected Results

Different templates, different identifiers.

Actual Results

<policy>hello</policy> PolicyPuppetryConverter::8c063411
<config>allow: hello</config> PolicyPuppetryConverter::8c063411

Versions

  • OS: Windows 11
  • Python version: 3.12.0
  • PyRIT version: source checkout of main at 791e12c6e
System:
    python: 3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)]
executable: C:\dev\pyr-main\Scripts\python.exe
   machine: Windows-11-10.0.26300-SP0

Python dependencies:
        pyrit: 1.2.0.dev0
       Cython: None
        numpy: 2.4.6
       openai: 2.54.0
    packaging: 26.3
          pip: 23.2.1
        scipy: 1.17.1
   setuptools: 84.2.1
      sqlite3: None
        torch: None
 transformers: 5.20.2

#3340 identifies PromptTemplateConverter templates by a content hash; the same would fit here. The test proposed in #3477 marks this case as a strict xfail linked to this issue.

Activity

  1. HhH666-ux commented on Nov 9, 2026

    @HhH666-ux
    Contributor

    I'd like to work on this. Plan: include a hash of the configured template value in PolicyPuppetryConverter._build_identifier so custom unnamed templates no longer share one identifier, and add a regression test with two different custom templates.

  2. romanlutz commented on Nov 10, 2026

    @romanlutz
    Contributor

    Ayoub (@Ayoubhm07) would you still like to take this one as well? Same situation as #3760: 电大老baby (@HhH666-ux) opened #4084 without checking the issue thread first. It's a fine PR, so I'm closing it for now pending your answer — if you'd prefer to handle this yourself let me know by 11/11, otherwise I'll reopen and review #4084.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions