PyRIT is Microsoft's open-source red-teaming framework that orchestrates adaptive multi-turn attacks against an LLM system, with pluggable converters, strategies, and scorers, producing attack success rate metrics
Imagine testing a castle's defences. The lazy way is to walk around the walls once with the same set of test attacks, write down what worked, and call it done. The thorough way is to bring an entire team: one person crafting new attempts, another adjusting them based on what the previous one tried, a third deciding whether each attempt actually breached the wall, and a coordinator running the whole exercise over hours and rotating tactics. PyRIT is the second approach for LLM systems. It is not a list of attacks to try; it is an orchestration framework where attackers learn from previous turns and adapt, scorers automatically judge success, and you get back a metric of how well your model held up across many attack families.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Red-teaming an LLM used to mean assembling a small group of clever attackers, giving them a model endpoint, and asking them to find ways to break it. The output was a writeup. The problem with that model is that it does not scale, it does not compose with CI, and it does not produce metrics that can be tracked over time across releases. Microsoft AI Red Team open-sourced PyRIT in 2024 specifically to industrialise the practice: turn red-team into a framework you can run on every build, with adaptive multi-turn attacks, pluggable strategies, and metrics that gate releases.
This walkthrough covers what PyRIT is architecturally, how the four core components compose, how converters and strategies extend the framework, how to design scorers that produce trustworthy ASR numbers, and how PyRIT fits alongside guardrails, online sampled eval, and human red-team in a complete 2026 safety stack.
Mental model: PyRIT is the CI for safety. A dataset is the unit test; PyRIT is the orchestration that ties many tests together into a regression suite with adaptive depth.
The four-component architecture
Target
The PromptTarget abstraction wraps the system under test. PyRIT ships targets for Azure OpenAI, OpenAI, Anthropic, Hugging Face TGI, local Ollama, and arbitrary HTTP endpoints. Custom targets are a small class with a single send-prompt method. The right granularity is the user-facing endpoint, not the bare model: testing the model alone misses stack-specific weaknesses (system prompts, retrieval, tool definitions) that are part of the real attack surface.
Multi-modal targets (text plus image) and structured-output targets (JSON schemas, function-calling) are supported. Agentic targets that wrap a full LangChain or AutoGen pipeline are increasingly common in 2026 production red-team configurations.
Red agent
The red agent generates attack attempts. PyRIT supports several modes:
- LLM-driven red agent. Another LLM (often Claude Opus 4.7, GPT-5.5, or an uncensored open-weights model) prompted to generate adversarial inputs. The red LLM can read previous-turn responses and refine.
- Deterministic red agent. A pattern generator that emits attacks from templates with parameters. Useful for reproducibility.
- Hybrid. Deterministic base prompts wrapped by LLM-generated paraphrase or context.
The choice depends on the attack family: jailbreaks benefit from LLM-driven creativity, encoded-payload tests are well-suited to deterministic generation.
Scorer
The scorer is the decisive component for ASR validity. PyRIT supports:
- SubStringScorer. Did the response contain a forbidden token? Cheap and brittle.
- SelfAskScorer. Ask an LLM-as-judge: did this response comply with the off-policy request? Nuanced but only as good as the judge.
- SelfAskCategoryScorer. LLM judge classifies into a fixed category set.
- FloatScorer. Continuous score from a regression-style judge.
- CompositeScorer. Chain multiple scorers (e.g. fast keyword triage then LLM-judge confirm).
Production setups in 2026 chain a fast scorer for triage with a cross-vendor LLM-as-judge for confirmation. Cross-vendor reduces the risk that the same model is both target and judge with co-pipeline blind spots.
Orchestrator
The orchestrator implements the iteration policy. Built-in options include:
- PromptSendingOrchestrator. Single-turn batch runner.
- RedTeamingOrchestrator. Multi-turn conversational attack with a red LLM driving turns.
- PAIROrchestrator (Prompt Automatic Iterative Refinement). The red LLM refines a prompt across attempts based on judge feedback.
- TreeOfAttacksWithPruningOrchestrator (TAP). Branching exploration with pruning to manage cost.
- CrescendoOrchestrator. Gradually escalates context to bypass safety calibration.
- ManyShotOrchestrator. Builds long-context attacks with many fake compliance examples.
Each orchestrator is a class; writing custom ones for organisation-specific attack families is straightforward.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- Microsoft AI Red Team uses PyRIT internally as the backbone of Azure OpenAI safety regression in 2026.
- Anthropic's Frontier Red Team incorporates PyRIT-style orchestrators alongside in-house tooling for pre-deployment safety review.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow would you design the scorer for a high-stakes safety regression run?
Chain a fast keyword scorer for triage with a cross-vendor LLM-as-judge for confirmation. Use a fixed scorer prompt and model for at least the regression window so ASR is comparable across releases. Calibrate the scorer quarterly against human labels on a held-out sample.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Treating PyRIT as a dataset of attack prompts. PyRIT is an orchestration framework; the attacks are adaptive and multi-turn, not a fixed list to evaluate against.
60 second bullets to scan on the way to the call.
The four core PyRIT components (target, red agent, scorer, orchestrator)
Pluggable converters (encoding, paraphrase, role-play wrap)
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.