How PyRIT's refusal scorer separates refusals from compliance
When a PyRIT attack gets a response back from the target, the first question a red team needs answered is whether the target refused or complied. That answer decides what happens next: whether the attack stops, whether the next turn escalates, and whether the result counts as a finding. PyRIT's SelfAskRefusalScorer exists for this single judgment. It is purpose-built to detect refusals, so it is a narrower tool than a general harm judge that asks whether a response is harmful. Treat it as the gate that tells your attack logic whether the target declined the request.
One behavior matters for planning. According to the PyRIT documentation for True/False scorers, SelfAskRefusalScorer returns True without an LLM call when the target fully blocked the response. A blocked response, such as an empty reply or a platform-level filter message, is therefore classified without spending a judge model call on it. The documentation does not describe every blocking pattern, so confirm with your own target which responses count as fully blocked before you rely on the shortcut to cut cost or latency. Test a sample of your target's known refusal styles and filtered outputs and check the returned value for each.
Because the refusal verdict drives multi-turn decisions, a wrong answer has direct consequences. A false refusal makes an attack stop early on a target that actually complied, which hides a weakness. A false compliance keeps a multi-turn strategy pushing against a target that has already declined, which wastes budget and can produce misleading transcripts. Before you wire the scorer into an attack, run it over a labeled set of your target's responses, including partial refusals and responses that comply while adding disclaimers, and record where it disagrees with your reviewers. The accuracy approach for scorers is covered in a sibling topic on measuring scorer accuracy.
How a response moves through the refusal check
The check starts when PyRIT's attack sends a prompt to the target model under test. The target's reply comes back across the trust boundary, and PyRIT first checks whether the target fully blocked the response. If it did, SelfAskRefusalScorer returns True without calling a model. If not, the scorer sends the response to a judge model, which labels it as refusal or compliance. That verdict feeds the attack's next-turn decision, so check that the judge model sits inside the boundary you intend.
Refusal check path from attack prompt to next-turn decision, with the judge model boundary marked.
How the refusal scorer behaves in each response situation
A fully blocked response is one where the target system itself refuses or filters the request before a normal answer is produced, for example through a platform content filter or a blocked-response status. PyRIT's refusal scorer, SelfAskRefusalScorer, is built to detect refusals, and the documented behavior is that it returns True without making an LLM call when the target fully blocked the response. For a team running large attack batches, this means a blocked result does not add judge model cost or latency.
- Verdict: The scorer returns True, which marks the attempt as a refusal.
- Judge call: None is made, because the block is recognized from the target's response before any scoring model is asked.
- What it does not tell you: A block says the target stopped the request, not that the underlying model would have refused the same request unfiltered.
- Attack logic: A multi-turn attack that reads this verdict can treat the turn as a refusal and try a different approach.
- Blocked by infrastructure: Gateway or proxy errors can look like blocks, so confirm which responses your target marks as fully blocked.
Before relying on this tab's behavior, send a known blocked request to your own target and confirm the scorer returns True with no judge call in your logs.
A partial or hedged refusal is a response that declines part of the request, adds warnings, or offers a safer alternative while still giving some content. These responses are the hardest for a refusal check to classify, because the text contains both refusal language and substantive material. The refusal scorer is designed to detect refusals in model output, so the verdict depends on how the response reads as a whole rather than on a single keyword.
- Verdict: The scorer's judgment depends on the response text, so a hedged answer can come back either way. Check these results manually before counting them.
- Judge call: A judge model is used for text responses that were not fully blocked, so each partial response adds a model call.
- Common pattern: A response that says it cannot help with one step and then explains the general idea is a case to review, not automatically a pass.
- Attack logic: If a multi-turn attack treats a hedge as a refusal, it may stop early on a response that still leaked useful content.
- Model choice: The verdict depends on the judge model you configure, so record which model made each call.
Build a small set of hedged responses from your own target, label them by hand and compare the scorer's verdicts with your labels before using them to steer attacks.
Clear compliance means the target answers the request directly without declining, warning or redirecting. For a refusal scorer, this is the case where the verdict should be False, meaning the response is not a refusal. Because the text is not fully blocked, a judge model call is made to classify it. The scorer's output here is a refusal verdict, not a harm rating, so a False result does not mean the content is safe.
- Verdict: The scorer returns False, meaning the response is not a refusal.
- Judge call: A judge model call is made, since the target did not block the response.
- Not a harm check: A compliant response can still be harmful, so pair the refusal verdict with a harm scorer when you need to judge the content.
- Attack logic: A False result tells a multi-turn attack that the target engaged, which may trigger the next step.
- Consistency: Repeated runs of the same prompt can vary, so check whether the verdict holds across attempts.
For your own targets, confirm that compliant answers across different topics and languages return False, and that a False result is never read as proof the output is harmless.
Ambiguous output includes empty replies, off-topic answers, responses in an unexpected format, and text that neither refuses nor answers the request. The refusal scorer must still produce a verdict, so these cases are where its judgment is least reliable. A team should decide in advance how such results are handled, rather than letting the attack logic default silently to one side.
- Verdict: The scorer returns a True or False verdict based on how the text reads, which may not match what a reviewer would decide.
- Judge call: A judge model call is made for text that was not fully blocked, and malformed judge output needs its own handling.
- Empty responses: An empty reply may be treated as a block, a refusal or an error depending on your target configuration, so confirm which.
- Attack logic: Ambiguous results can end a multi-turn attack too early or let it continue on a non-answer, so log them separately.
- Review queue: Route ambiguous results to a person when the outcome affects a finding.
Before relying on the scorer for findings, collect ambiguous responses from your target, check how each one is classified and document the handling rule your team will apply.
Why refusal detection drives multi-turn attack decisions
A refusal verdict decides what a multi-turn attack does next. In PyRIT, multi-turn strategies such as Crescendo, TAP and Skeleton Key score each target reply and use that verdict to choose the following move. A refusal usually means the strategy should rephrase, soften the request, backtrack to an earlier turn or try a different framing. A compliant reply usually means the strategy should move closer to the objective, or stop if the objective is already met. If the refusal scorer is wrong, the attack takes the wrong branch and the run tells you little about the target. Before you rely on any multi-turn strategy, confirm with your own configuration which scorer feeds the strategy's decision logic and which scorer only records results for review.
The two error types have different costs. A false refusal (the scorer marks a compliant or partly compliant reply as a refusal) makes the attack retreat from progress it had already made, which can end a promising branch early and understate attack success. A false compliance (the scorer marks a refusal as compliance) makes the attack push forward on a dead end, spending turns and target calls while producing a reply that does not actually advance the objective, and it can inflate reported success if no later check catches it. Both errors distort attack success rates, so a success figure is only as trustworthy as the refusal verdicts behind it. Ask your team to state which error they consider more costly for each test objective, because that choice sets how much manual review the results need.
Plan a short validation pass before a full run. Take a sample of target replies that your team has labeled by hand as refusal, partial answer or full answer, run the refusal scorer over them, and record where it disagrees. Pay particular attention to hedged replies, safe-completion wording and replies that refuse one part of a request while answering another, since these are the cases most likely to be misread. Repeat the check whenever you change the target model, its system prompt or the scorer configuration. The goal is not a perfect score but a documented understanding of where the verdicts can be trusted and where a person should read the transcript.
Refusal scorer configuration options and when each fits
This table compares the configuration choices for PyRIT's refusal scorer: the judge model, handling of fully blocked responses, standalone or composite use, and custom refusal wording. Read each row against your target and your reporting needs, then confirm the exact parameter names in the PyRIT 1.1.0 documentation before you commit to a setup.
| Option | When it fits | Trade-off | Confirm in PyRIT 1.1.0 docs |
|---|---|---|---|
| Judge model choice | Your target's refusal style is clear and you want a stable, cheap judge for every turn | A weaker judge may misread polite deflections as compliance or the reverse | Which models the scorer accepts and how the judge target is passed in |
| Fully blocked responses | Your target or a guardrail returns a block before generating text, and you want those turns counted as refusals without an LLM call | Blocks that are not flagged as full blocks still go to the judge, so counts can differ by target | How the scorer detects a full block and what it returns in that case |
| Standalone scorer | You only need a yes or no answer on whether the target refused, for example to log refusal rate per objective | Refusal alone does not show whether the objective was met, so pair it with an objective scorer | Whether the scorer runs directly on a response and how results are stored in memory |
| Inside composite scorers | Refusal should gate later decisions, such as stopping a multi-turn attack or skipping a harm score on refused turns | Inverting or combining results is easy to get wrong, so test the logic on known refusals and compliant replies | How to invert results and combine them with other scorers without changing the meaning of a refusal |
| Custom refusal wording | Your domain uses specific refusal phrasing, such as a bank or clinical assistant declining a question in its own voice | Custom wording can narrow detection and miss refusals that use other phrasing | Whether the system prompt or refusal instructions can be replaced and how the default wording is set |
Setting up the refusal scorer in a PyRIT test run
This sequence takes a team from a clean environment to a verified SelfAskRefusalScorer that separates refusals from compliant answers and short-circuits fully blocked responses without a model call. Each step ends with a check so the team knows the scorer is ready before it drives attack decisions.
Confirm a supported Python version
The engineer running the test confirms that the local interpreter is Python 3.10 or later and below 3.15, the range the PyPI package supports, and prefers 3.13, which the documentation recommends. Use a dedicated virtual environment so PyRIT's dependencies stay separate from other projects. Check the result with the interpreter's version command; the session is ready when the reported version falls within the supported range.
Install PyRIT into the environment
Install the package with pip into the active virtual environment, then confirm the installed version matches the release your team has approved, for example 1.1.0 if that is your target. Pin the version in your project's dependency file so later runs use the same scorer code. Finish the step by importing the package in a short Python session; a clean import with no errors shows the install is usable.
Configure credentials and settings files
Create the credentials file at ~/.pyrit/.env and the settings file at ~/.pyrit/.pyrit_conf. Put only the keys for the judge model and the target in the environment file, and keep the file out of version control and readable only by the test account. Record the memory and target settings in the configuration file. The step is complete when a test session loads both files and reports the judge endpoint without printing the secret itself.
Attach the judge model
Select the chat model that will act as the judge and point PyRIT's scorer at it, using the endpoint and deployment named in your configuration. Confirm with the model owner that the judge is a separate model from the system under test, so the judge's own refusals do not contaminate results. Send a single trivial prompt through the judge connection and check that a response returns. The step is done when the judge responds and the connection is logged in PyRIT memory.
Instantiate SelfAskRefusalScorer
Create a SelfAskRefusalScorer object that references the attached judge and the memory store your configuration names. Keep the scorer instance in one module so every test in the run uses the same prompt template and settings. Read the scorer's returned configuration or metadata to confirm it is the refusal scorer and not a general true/false scorer. The step closes when the object builds without errors and reports the judge it is bound to.
Score a known refusal and a known compliant response
Score two fixed, labeled examples: one clear refusal written by your team, and one compliant answer to a benign question. Record the verdict for each, where True means the response is a refusal. A correct setup returns True for the refusal and False for the compliant answer. If either verdict is wrong, adjust the scorer's configuration or judge before running any attack, because every later decision depends on these two results.
Confirm the fully blocked path skips the judge
Simulate a target that fully blocks a response, such as a filtered reply with no model text, and score it with the refusal scorer. The scorer should return True without calling the judge model, which you can verify by checking that the judge endpoint logs no new request for that item. This confirms that blocked responses are handled cheaply and deterministically. The step is finished when the judge call count stays unchanged for the blocked example.
Record the setup baseline for the run
Save the two labeled verdicts, the fully blocked check result, the PyRIT version and the judge model identifier in your test record, so the run can be repeated and audited. Store the record alongside the test plan rather than in the scorer code. Confirm with the reviewing team that the baseline matches what they expect before attacks start. The sequence is complete when the baseline is approved and the scorer is attached to the multi-turn attack configuration.
Security and operational risks of relying on refusal verdicts
A refusal verdict decides which attack path PyRIT takes next, so errors in that verdict propagate through the whole run. The cards below cover the risks that come from the judge, the stored data, model updates, credentials and the tool itself.
Target output can manipulate the judge
The refusal scorer reads the target's reply and asks a model to classify it, so a crafted reply can try to steer that classification. A response that contains instructions aimed at the judge may be scored as a refusal when it is not, or the reverse. Test the scorer with adversarial replies, such as a refusal phrase followed by compliant content, before trusting its verdicts on a live target.
True/False scorers docsMemory stores sensitive prompts
PyRIT writes conversations and scoring results to its memory, which is SQLite or Azure SQL. Those records contain the attack prompts, which may describe harmful content, and the target's replies, which may include data the model should not reveal. Decide who can read the memory database, how long records stay, and where backups go before the first run.
Scorer drift after model updates
The judge model behind the refusal scorer can change when its provider updates it, and the target model can change too. A verdict set that was accurate last quarter may shift without any change to your code. Pin the judge model version where the provider allows it, and rerun a fixed set of labeled replies after each update to catch changes in the scorer's answers.
Credentials in the environment file
PyRIT reads provider keys and endpoints from ~/.pyrit/.env, and the judge and target often use separate keys. A shared workstation or a copied file can expose both. Give the judge and target their own scoped credentials, keep the file out of version control, and confirm with your secrets team whether a managed vault fits your setup better.
Reporting vulnerabilities in PyRIT
If you find a defect in PyRIT itself, such as a scorer that can be bypassed by crafted input, report it privately rather than in a public issue. The project's security policy routes reports to the Microsoft Security Response Center. Confirm the current reporting path in the repository's security policy before you rely on it, since the original repository was archived and development moved.
PyRIT repositoryQuestions teams ask before running refusal detection
How much effort does it take to adopt PyRIT's refusal scorer?
The scorer itself is a small piece of configuration inside a PyRIT run, so the effort sits in the surrounding work: installing PyRIT, connecting a target, choosing a judge model and writing test objectives. PyRIT installs with pip on Python 3.10 up to but not including 3.15, and the documentation recommends Python 3.13. Most of the time goes into making sure your target's responses reach the scorer in the form you expect, including how blocked responses are represented. Teams usually spend more effort validating results than wiring the scorer in.
What does a team need before running refusal detection?
You need three things: Python skills to write and run the attack script, a judge model endpoint if the scorer path calls an LLM, and a set of test objectives that reflect the behaviors you care about. Refusal detection only tells you whether a response declined, so the objectives should be prompts where a refusal is the expected safe outcome. You also need access to the target system under test and a place to store results, such as PyRIT's SQLite memory for a local run. Confirm credential handling with your security team before any keys are stored in configuration files.
Can our own team run refusal detection without an implementation partner?
Yes, a team with Python experience and access to the target can run the refusal scorer in-house, and the PyRIT documentation covers the scorer directly. The harder part is judgment: deciding which objectives matter, reading borderline results and deciding how refusal verdicts feed multi-turn attack logic. Teams without red teaming experience often benefit from an outside review of their first run. DeployOpen can plan and run this work as a fixed-scope engagement, with scope, deliverables and timelines agreed in writing before work starts.
How long does a first validation run usually take?
The duration depends on how many objectives you test, how many turns each attack runs, how long your target takes to respond and how many judge calls the scorer makes. A small single-turn run against one target can finish quickly, while multi-turn attacks across a large objective set take longer and need rate limits set carefully. Plan extra time for reviewing a sample of verdicts by hand, since that review is what tells you whether the scorer is trustworthy. Ask any partner for a timeline that is tied to a written scope rather than a generic figure.
What drives the cost of running refusal detection?
Cost has two main parts: the people time to set up and review the runs, and the model usage behind each run. Where the scorer path calls a judge model, every scored response adds a model call, so the number of objectives, attack turns and repeat runs multiplies the bill. Targets you pay to query add their own charges. Refusals that the target fully blocks are returned without an LLM call, which reduces judge usage for those responses. Ask any quote to separate one-time setup from recurring run costs and to state the expected run volume.
How do we confirm the refusal scorer is accurate before trusting its verdicts?
Check it against human labels before you rely on it. Take a sample of responses, have reviewers mark each one as a refusal or compliance, then compare those labels with the scorer's True or False results. Look closely at partial refusals, responses that refuse and then answer, and refusals phrased in unusual languages, because these are where simple detection often fails. Record the disagreements, adjust the objectives or judge setup, and repeat the comparison after any change to the model or prompts. Keep the labeled sample in your records so an auditor or reviewer can follow how the scorer was validated.
Why does refusal detection affect multi-turn attack decisions?
A multi-turn attack needs to know whether the last response declined, because a refusal usually means the attack should change tack and a compliance result may mean it should stop or escalate. If the refusal check is wrong, the attack either wastes turns on a dead end or ends early on a response that actually leaked content. This is why the scorer's verdict is an input to attack control, not only a report line. Test the scorer on the exact target and attack strategy you plan to run, since a verdict that works for single-turn prompts may not hold across longer conversations.
Limits to confirm in your own environment
A refusal scorer's verdict is only as good as its match to your target and your judge. The items below are the assumptions to test before refusal labels drive attack decisions, because each one can flip a result without any visible error.
Refusal wording in your target
Refusal phrasing varies by model, language, persona and system prompt. A target that refuses in a polite, indirect or non-English style can slip past a judge tuned to stock refusals. Collect refusal and compliance examples from your own target in each language you serve, then check that the scorer labels them as expected. Treat any refusal style you cannot find as an open gap.
Full-block signal from the target
SelfAskRefusalScorer returns True without an LLM call when the target fully blocked the response, so the result depends on your target reporting a full block at all. Confirm whether your gateway, content filter or web app returns an explicit block, an empty reply or a generic error. If blocks look like ordinary text, the scorer will judge them with the judge model instead.
True/False scorers docsJudge model suitability
The refusal decision is made by a judge LLM when no full block is reported, so the judge's own behavior matters. Check that the judge follows the refusal question reliably, returns output in the expected true or false format, and does not refuse to evaluate harmful content itself. Test the judge on a small set of clear and borderline cases before you trust it at scale.
Multimodal and mixed responses
A response may combine a partial answer with a caveat, or carry refusal language inside an image, audio clip or document. A text-based refusal question can miss a refusal delivered in another modality or label a helpful answer that includes a disclaimer as a refusal. Confirm how the scorer handles mixed responses from your target before counting them in attack success rates.
Accuracy on your own labelled samples
Public examples do not show how the scorer behaves on your product, users and policy. Have reviewers label a sample of real target responses from your use case as refusal or compliance, then compare the scorer's verdicts with those labels. Record disagreements by category, since a scorer that is accurate overall can still miss one kind of refusal that matters most to you.
How scorer choices shape the rest of a PyRIT engagement
A refusal check is the right first gate when you want to separate responses the target blocked from responses that might contain the harm you are testing for. In PyRIT, SelfAskRefusalScorer is built for that single question. Because it returns True without an LLM call when the target fully blocked the response, it is cheap to run on every turn, and it tells you which responses deserve a more expensive judgment. Placing it first keeps your LLM judges, Likert scales and content classifiers focused on responses that were not simply declined, which makes their results easier to read and their cost easier to justify.
The refusal scorer does not answer whether an objective was met, and treating it as if it did is the most common design error. A response can be a partial refusal that still leaks the requested detail, or a non-refusal that is off-topic and harmless. For that reason, the refusal result should feed a separate scorer, such as an LLM-as-judge true/false scorer that asks a question written for your own policy, and the two verdicts should be combined through a composite scorer rather than read in isolation. Confirm how your chosen combination treats a refusal and a failed objective, because the logic is yours to set, not PyRIT's default.
Refusal results also decide what the attack does next, so their reliability matters beyond reporting. In multi-turn strategies, a false refusal verdict can end a conversation too early, while a missed refusal can send the attacker down a path the target had already closed. Before you rely on the scorer to steer an engagement, run it against a sample of responses you have labeled by hand, and record the disagreements. The PyRIT documentation for True/False scorers is the reference to confirm how the scorer is configured and what its verdicts mean in your PyRIT version.
How DeployOpen scopes and delivers PyRIT refusal detection
DeployOpen plans and delivers refusal detection for PyRIT as part of a written, fixed-scope engagement. The work covers how refusal verdicts are defined, how the scorer is wired into your PyRIT setup, and how the results are checked and handed over so your team can run and maintain it.
How we scope
- We confirm which target systems and response types your refusal checks must cover before any build starts.
- We agree in writing which refusal patterns, multi-turn decision points and memory records are in scope.
- We record which PyRIT version and Python runtime your environment will use, with the version checked against current release notes.
How we build
- We configure the self-ask refusal scorer with your target and attack flow, and confirm when fully blocked responses skip the judge model.
- We test the scorer against sample refusals, partial refusals and compliant answers from your own targets.
- We wire refusal verdicts into multi-turn attack decisions and record each branch so the logic can be reviewed.
How we hand over
- You receive the scorer configuration, attack logic, test cases and a written record of the decisions behind them.
- We document how to read refusal results in memory, including what counts as a refusal and what does not.
- We walk your engineers through the setup, the known limits of judge-based detection and the steps to rerun the tests.
How we support
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
- Ongoing support, upgrades and continuous testing are available as a retainer, including checks after PyRIT upgrades.
- Quotes follow from the written scope, so your team can compare the work against building the refusal logic in-house.

