FIX Include subdirectory jailbreak templates in listings#1498
Open
biefan wants to merge 3 commits intomicrosoft:mainfrom
Open
FIX Include subdirectory jailbreak templates in listings#1498biefan wants to merge 3 commits intomicrosoft:mainfrom
biefan wants to merge 3 commits intomicrosoft:mainfrom
Conversation
hannahwestra25
approved these changes
Mar 24, 2026
- Use random.sample instead of random.choices in get_jailbreak_templates to avoid returning duplicate template names when num_templates is set - Replace hardcoded 'nova.yaml' assertions with structural checks that verify subdirectory templates are included without depending on a specific file - Add JAILBREAK_TEMPLATES_PATH import to test files for structural assertions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts: # tests/unit/scenarios/test_jailbreak.py
romanlutz
approved these changes
Apr 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TextJailBreakand the AIRT jailbreak scenariorandom.choices(with replacement) torandom.sample(without replacement) inget_jailbreak_templates()to avoid returning duplicate template namesProblem
TextJailBreakalready resolves template names from subdirectories such aspliny/amazon/nova.yaml, butget_jailbreak_templates()only scanstemplates/*.yamlat the top level.This creates an inconsistent API surface: a template name can be loaded successfully via
template_file_name, but the same name is missing from the advertised template list and is rejected byJailbreak(..., jailbreak_names=[...])validation.Changes
text_jailbreak.pyJAILBREAK_TEMPLATES_PATH.glob('*.yaml')withcls._get_template_cache().keys()inget_jailbreak_templates()to include subdirectory templates (72 previously-invisible templates now appear, 162 total vs 90 top-level)sorted()for deterministic cross-platform ordering (previously depended on filesystem glob order)random.choicestorandom.samplesonum_templatesreturns distinct templates without duplicatesTests
Jailbreak(jailbreak_names=[...])accepts subdirectory template namesTesting
pytest tests/unit/datasets/test_jailbreak_text.py tests/unit/scenarios/test_jailbreak.py -q