Jailbreak templates in PyRIT: what they test and when to use them
Jailbreak templates test whether your AI application can be talked out of its safety behavior using wrapper prompts that many attackers already use. A team that must show how its application holds up against known jailbreak patterns needs a repeatable way to apply those patterns, and PyRIT ships a bundled jailbreak template library for that purpose. PyRIT v1.1.0 added 488 TrustAIRLab in-the-wild jailbreak templates, collected from prompts observed in the wild. A template is a wrapper: a block of text that surrounds an objective, such as a request the model should refuse, and tries to change how the model reads that request. The objective stays the same while the wrapper varies, so the test measures the model's response to the framing rather than to the request alone.
Teams usually need templates in three situations: before a release, when they want to check that a model or system prompt change has not reopened a known weakness, and when a security review or customer questionnaire asks which jailbreak patterns were tested. Templates are also useful because they are inexpensive to run at volume and easy to explain to non-specialists. Confirm with your own environment how many templates a given run will use, since the Jailbreak scenario samples a small random set by default and that sample can differ between runs unless you pin it.
Templates are not enough on their own. A wrapper tests known phrasing, so a model or filter that handles these patterns may still fail on new framing, on multi-turn pressure, or on the harms your application can actually cause. Pair template runs with objectives drawn from your own use cases, and with multi-turn strategies where the risk depends on conversation history. Also plan how you will score results, because a template run without a reliable scorer produces counts that do not show whether anything harmful was said. Record which templates, objectives and scorer versions were used so the results can be repeated after the next change.
Running templates through the Jailbreak scenario or directly
The Jailbreak scenario is the packaged route. It takes the bundled template library, selects a set of templates, applies them to your target and scores the responses, so a team can get a first signal without building an attack pipeline. By default it runs a small random sample of templates, which keeps runs short but means two runs can exercise different templates. The selection is controlled by num_jailbreaks to widen the sample and jailbreak_names to pin specific templates. Use the scenario for a repeatable baseline and for regression checks where you want a known set each time.
- Selection settings: Decide whether you want a random sample or a pinned list, and record which setting you used. A pinned list is easier to repeat in CI, while a random sample gives broader but less predictable coverage.
- Target configuration: Confirm the target is the deployed system you mean to test, including its system prompt, tools and content filters, since the scenario reports results against that exact configuration.
- Scorer choice: Confirm which scorer decides success and that it matches the harm you care about, because the scenario result is only as meaningful as its scorer.
- Memory location: Confirm where conversations are stored so every run can be reviewed and reproduced later.
- Run record: Keep the template names, sample size, PyRIT version and target version together so the run can be repeated.
Check which templates were actually used, how many succeeded and whether the sample was large enough to say anything about the parts of the target you are responsible for.
Direct attacks are the custom route. Your team loads the templates it wants from the bundled library, builds the prompts and runs them through a chosen attack and target in Python, so you control the template list, the conversation handling and the scoring logic. This route suits teams testing one application flow, adding their own templates or combining templates with converters and scorers that the packaged scenario does not use. It takes more engineering work and needs a clear record of every choice you made.
- Template list: Choose templates by harm category and by the application's realistic misuse paths, and record the exact names so the list can be reproduced.
- Attack and target setup: Confirm which attack class and target you wire together, and that the target points at the environment you intend to test.
- Scoring code: Decide which scorer or custom logic marks a success, and check it against a sample of responses you review by hand.
- Concurrency and limits: Set rate limits and retries that match the target's quotas so failures are not mistaken for refusals.
- Reproducibility: Store the script, configuration and memory export in version control so a reviewer can rerun it.
Check that every skipped template has a stated reason, that scorer decisions were spot checked, and that errors and timeouts are reported separately from successful and failed attacks.
Whichever route you use, the results need the same review before anyone treats them as a finding. A success count on its own says little, because it depends on which templates ran, how the target was configured and how strictly the scorer judged. Review a sample of successful and unsuccessful conversations directly, and separate true policy failures from answers that only look harmful to a keyword check. Keep the results tied to a specific target version so a later change can be compared fairly.
- Conversation review: Read the full transcripts for successful attacks, not only the score, to confirm the target actually produced disallowed content.
- Scorer agreement: Compare the scorer's decisions with reviewer judgments on the same sample and note disagreements.
- Errors and skips: Separate timeouts, blocked requests and skipped templates from genuine refusals, since each means something different.
- Template coverage: Record which templates and harm categories were tested, so gaps are visible.
- Comparison baseline: Keep the previous run's settings so changes in results can be traced to changes in the target.
Before sharing results, confirm that the report states the selection method, sample size and target version, so readers can judge how far the conclusions reach.
Which template selection option fits which test
This table compares the Jailbreak scenario's default sampling, num_jailbreaks and jailbreak_names, plus a full library run against a team-curated subset. Read each row as a test type and check which selection option matches its purpose. The main takeaway is that random sampling suits broad coverage, while pinned templates suit regression tests that must rerun the same attacks.
| Selection option | What it does | Best fit for |
|---|---|---|
| Default random sample | Runs a small random sample of templates each time the scenario runs | Quick broad checks where varied coverage matters more than repeatability |
| num_jailbreaks | Widens the number of templates the scenario draws from the library | Broader coverage runs before a release or after a model change |
| jailbreak_names | Pins the scenario to the specific templates you name | Regression tests that must rerun the same known attacks |
| Full library | Covers the bundled library, including the TrustAIRLab in-the-wild set | Periodic deep coverage runs; expect longer runtime and more review effort |
| Team-curated subset | Holds only templates your team has seen used against your application | Ongoing regression suites tied to your real threat history |
| Mixed approach | Pins a core set by name and adds a sampled or wider draw on top | Teams that need stable regression results plus fresh coverage each cycle |
| Pinned names with a custom template | Combines named library templates with team-added templates in one run | Testing patterns observed in your own incidents or reports |
Setting up a jailbreak template run in PyRIT
This sequence takes a team from a clean Python environment to a reviewed set of jailbreak template attacks against the application under test. Each step ends with a check so you know the run is storing evidence you can review and reproduce.
Install PyRIT on a supported Python version
Create an isolated virtual environment and install PyRIT with pip from the PyPI package, using a Python version from 3.10 up to but not including 3.15. The PyRIT documentation recommends Python 3.13, so use that unless your platform team requires otherwise. Confirm the install by importing the package in Python and checking the version it reports against the release you intend to test with, such as v1.1.0, which added the TrustAIRLab templates.
Configure credentials and settings files
Put the API keys and endpoint secrets for your target and any scorer model in ~/.pyrit/.env, and set run-wide options such as memory and defaults in ~/.pyrit/.pyrit_conf. Keep the .env file out of source control and restrict its file permissions to the account running the tests. Confirm the setup by running a trivial script that loads the configuration and prints the target settings with secret values masked, so you know the keys are read from the intended files.
Point a target at the application under test
Create a target object that sends prompts to the application you are testing, using a built-in target for a model endpoint or a custom HTTP or WebSocket target for your own application. Use the same system prompt, tools and guardrails that real users reach, because a test against a bare model will not show what your application does. Confirm the target by sending one benign prompt and checking that the response comes back in the expected shape and is stored in memory.
Choose the template selection
Decide how many templates the run will use and whether to pin specific ones. The Jailbreak scenario runs a small random sample by default, so set num_jailbreaks to widen the sample or jailbreak_names to pin named templates when you need repeatable coverage across runs. Record the chosen selection and the template source in your run notes. Confirm the selection by printing the number of templates loaded and the names chosen, and check that the count matches what you expected from the bundled library.
Run the jailbreak scenario
Start the Jailbreak scenario against the target with your chosen objectives and selection, either through the scanner command or from a Python script if you need custom handling. Keep concurrency and retries at settings your target can absorb, and watch for rate limit errors that would make results unreliable. Confirm the run finished by checking that every selected template produced an attempt record and that no attempts stopped with unhandled errors.
Review conversations and results in memory
Open the stored conversations for the run in PyRIT memory and read the attack transcripts, not only the scores. Check which templates produced responses that the scorer flagged, and confirm that a flagged result actually contains the unsafe content rather than a refusal the scorer misread. Export the conversations for review and keep the run identifier so the same selection can be repeated after a fix. Confirm the review is complete when each flagged result has a reviewer note and the run can be reloaded from memory.
Adding templates your team has seen used against you
Your own jailbreak templates are often the most useful part of a PyRIT run, because they reflect attacks aimed at your application rather than at a generic benchmark. Start by capturing each template from the places where it actually appeared: incident tickets, chat transcripts flagged by moderation, application logs and abuse reports from users or partners. For each one, keep the exact wording of the template, not a paraphrase, and note the target it was aimed at. Before any template goes into the repository, remove personal data, customer identifiers, credentials, internal system names and anything else that should not travel with a test asset. Replace removed details with neutral placeholders so the template still works as an attack shape.
Record provenance alongside the text. For every template, store where it came from, the date it was first observed, the date it was last seen, and which incident or report it relates to. Store the custom set in version control with a changelog, so a reviewer can see when a template was added, edited or retired. Tie each template to the objectives it was run with, for example by recording the objective identifiers in the same file or in the results metadata. That link lets you answer later whether a change in attack success came from the model, the template or the objective set. Load the custom set alongside the bundled library, and confirm with the PyRIT documentation how the Jailbreak scenario combines both sources in your version, since selection behavior determines whether your templates actually run.
Before sharing a custom set outside the team, get a review from security and legal owners. Confirm that no template contains customer data, that wording copied from third-party sources is permitted for redistribution under its own license, and that disclosing a working attack shape will not expose a live weakness in a production system. Check whether any template is still effective against your application; a template that is already mitigated may still be worth keeping as a regression case, but it should be labeled as such. Keep the internal version as the authoritative copy, and treat external sharing as a separate, approved export.
Security and operational risks of running jailbreak templates
Jailbreak templates are built to make a model produce content it should refuse, so every run creates sensitive material and live traffic. The cards below cover what that output, the stored conversations, the credentials and the target endpoints expose, and what to check before a run starts.
Harmful output in memory and exports
A successful jailbreak leaves the harmful completion in PyRIT memory and in any exported conversation file. Treat that content as sensitive data: decide who may read it, where it is stored, and how long it stays. Confirm the storage location of the SQLite file or Azure SQL database before the first run, and check whether exports are written to shared drives or CI artifacts that broader groups can open.
Access control on stored conversations
PyRIT memory stores conversations and results in SQLite or Azure SQL, and a shared database lets any user with access query every template's responses. Restrict file permissions on the database or the Azure SQL access role to the red team, and confirm who can run exports. Record which operator ran which template so results can be traced later.
PyRIT docsCredentials in env files
PyRIT reads target and scorer credentials from ~/.pyrit/.env, and a copied or committed file exposes every model key it holds. Keep the file out of repositories and images, scope each key to the minimum model access the test needs, and rotate keys after a red team exercise. Prefer a managed secret store where your organization already runs one.
Rate limits and cost on targets
A jailbreak run sends many prompts, and multi-turn attempts multiply them. Each request consumes quota and, on pay-per-token endpoints, money that the test team may not have budgeted. Set request limits and spending alerts on the target account before running a full template set, and ask the target owner what throughput limits apply to the test key.
Keeping test traffic off production
Pointing a template run at a production chat endpoint can put adversarial prompts in front of real users, pollute analytics and trip abuse monitoring. Run against a staging deployment or a dedicated test tenant, label test sessions where the platform allows it, and agree a window with the service owner. Confirm that the target's logs will mark these requests as testing.
Retaining custom templates
Templates your team writes from attacks seen in production describe working exploits. Store them in a restricted repository with an owner, a review date and a rule for when they are retired. Decide whether a template that describes a live weakness is removed after the fix ships, and document that decision so the library does not keep a usable attack after its target has changed.
How a template run flows from selection to findings
A run starts with the template choice: the bundled library, pinned names from jailbreak_names, or a sample sized by num_jailbreaks, with custom templates added alongside. Each selected template is wrapped around the objective and sent to the target. The scorer judges each response, and PyRIT memory records the conversations and results in SQLite or Azure SQL. Check the selection first, since a random sample can miss the templates you care about, then review scored findings in memory before drawing conclusions.
Template selection feeds the attack, and every result lands in memory for review.
Questions teams ask before running jailbreak templates
What drives the cost of running PyRIT jailbreak templates?
The cost depends on four drivers: access to the target, the number of templates you run, the effort to score responses, and the time your reviewers spend on results. Template volume is the easiest to control, because the Jailbreak scenario runs a small random sample by default and num_jailbreaks or jailbreak_names widen or pin the selection. Scoring effort grows with each template and each target, especially if you use an LLM judge that needs its own model access. When you request a quote, ask the provider to separate one-time setup from recurring runs, and to state which target endpoints, scorers and review hours are included.
How long does a first jailbreak template run take to set up?
The setup time depends mostly on your environment, not on PyRIT itself. A team that already has a Python 3.13 environment, a reachable target and approved model credentials can start quickly, while a team that needs network approvals, a custom HTTP or WebSocket adapter, or a shared memory database will spend longer on those steps first. PyRIT installs with pip and supports Python 3.10 up to but not including 3.15. Ask for a written plan that lists each environment dependency and who must approve it before the first run.
What must our team provide before a jailbreak template engagement starts?
A jailbreak template engagement needs four inputs from your side:
- Target access, including endpoints, test credentials and a non-production environment where possible
- Objectives that reflect the harms your application can cause
- An approved harm scope that your risk owner has signed off
- A named reviewer who can judge whether flagged responses are real findings
Without these, the work stalls at the first run, because the template results only mean something when someone with authority can decide what counts as a failure.
Can one internal engineer run PyRIT jailbreak templates alone?
One engineer with Python and API experience can run the Jailbreak scenario on a single target, provided the target access, objectives and scoring method are already settled. The harder part is judgment, not execution: deciding which templates are relevant, reviewing borderline responses and explaining results to security and product owners. Teams often keep one engineer as the operator and assign a second person to review results. If your engineer is new to red teaming, ask a partner to review the first run so the scoring and the harm scope are checked before the results are reported.
Which parts of a jailbreak template run recur after the first pass?
The recurring costs are the ones tied to each new run: model usage for the target and any judge, engineer time to refresh templates, and reviewer time for new results. The one-time costs are the environment setup, target adapter work and the first scope agreement. Templates also change. PyRIT v1.1.0 added 488 TrustAIRLab in-the-wild jailbreak templates, so a team that runs against the full set should plan review time for a larger result set than it had in earlier versions. Confirm with your provider whether retesting after a model or prompt change is part of the agreed scope.
What risks should we check before pointing jailbreak templates at a production system?
Jailbreak templates are designed to push a model past its safety behavior, so they can produce harmful outputs and can flood logs or consume quota on a live service. Confirm that the target owner has approved the test, that the endpoint is rate limited, and that memory and logs are stored where your data handling rules allow. Check which templates will run, and make sure any output containing sensitive content is handled under your incident process. Many teams start in a staging environment that mirrors production configuration.
Does a jailbreak template run give us compliance evidence?
A run produces records of what was sent, what came back and how each response was scored, which can support an internal assessment. It does not by itself satisfy an audit or certification. DeployOpen prepares systems, controls and evidence for compliance assessments but does not issue audit reports, attestations or certifications; independent auditors and certification bodies do. Ask your auditor early which records they will need, such as scope, dates, objectives, scoring method and reviewer decisions, and plan your memory retention to keep them.
How DeployOpen scopes and delivers PyRIT jailbreak testing
DeployOpen plans, runs and documents PyRIT jailbreak testing inside your own infrastructure, as part of a fixed-scope engagement agreed in writing. We decide which templates and scenario settings match your application, build the test setup with your team, and hand over the results, configuration and template records so your own staff can rerun them.
How we scope
- Agree which applications, endpoints and user flows the jailbreak tests will reach before any run starts.
- Decide whether to use the bundled TrustAIRLab set, a pinned selection of template names, or a wider random sample.
- Record the templates your team has seen used against you and how they will be added to the test set.
- Confirm the scope, deliverables and timeline in writing before work begins.
How we build
- Install PyRIT and configure targets, scorers and memory in your environment, with credentials kept in your own secrets setup.
- Set up the Jailbreak scenario with the agreed template selection, sample size and scoring criteria for your application.
- Add custom templates from your incident history, converted into the format the scenario loads and checked before use.
- Run the tests against a staging copy of your application and review scored conversations with your team.
How we hand over
- Deliver the scenario configuration, template selection and custom template files for your repository.
- Document each run with the template versions used, scoring results and the conversations behind each finding.
- Provide a findings report with remediation advice and a retest of fixed issues against the same template set.
- Walk your security and engineering staff through how to rerun the scenario without DeployOpen.
How we support
- Ongoing support is available as a retainer, covering reruns after model or prompt changes and new template releases.
- Retainers can include periodic updates to PyRIT versions and review of newly added templates from the research set.
- Ask your DeployOpen contact which items a retainer covers and how changes to scope are quoted and agreed in writing.
- Support terms, response expectations and any service levels are stated in the written agreement, not assumed.

